Skip to content

Commit

Permalink
create makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed Jul 31, 2024
1 parent 305fd15 commit fd2cff9
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Makefile for tlin

# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOCLEAN=$(GOCMD) clean
GOGET=$(GOCMD) get
BINARY_NAME=tlin
BINARY_UNIX=$(BINARY_NAME)_unix
BINARY_WINDOWS=$(BINARY_NAME).exe
BINARY_MAC=$(BINARY_NAME)_mac

# Main package path
MAIN_PACKAGE=./cmd/tlin

# Build the project
all: test build

build:
$(GOBUILD) -o $(BINARY_NAME) -v $(MAIN_PACKAGE)

# Cross compilation
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v $(MAIN_PACKAGE)

build-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_WINDOWS) -v $(MAIN_PACKAGE)

build-mac:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_MAC) -v $(MAIN_PACKAGE)

test:
$(GOTEST) -v ./...

clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
rm -f $(BINARY_WINDOWS)
rm -f $(BINARY_MAC)

run:
$(GOBUILD) -o $(BINARY_NAME) -v $(MAIN_PACKAGE)
./$(BINARY_NAME)

# Cross compilation
build-all: build-linux build-windows build-mac

# Dependencies
deps:
$(GOGET) -v ./...

# Install golangci-lint
install-linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

# Run golangci-lint
lint:
golangci-lint run

.PHONY: all build test clean run deps build-linux build-windows build-mac build-all install-linter lint

0 comments on commit fd2cff9

Please sign in to comment.