forked from c2biz/go-cookie-monster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (42 loc) · 1.43 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Binary names (Windows targets only)
EXE_NAME=go-cookie-monster.exe
DLL_NAME=go-cookie-monster.dll
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
# Determine platform-specific variables
ifeq ($(OS),Windows_NT)
# Windows-specific settings
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
RM_F := Remove-Item -Force -Recurse -ErrorAction Ignore
# For Windows builds
BUILD_CMD_EXE = $$env:CGO_ENABLED=1; $$env:GOARCH='amd64'; $$env:GOOS='windows'; $(GOBUILD)
BUILD_CMD_DLL = $$env:CGO_ENABLED=1; $$env:GOARCH='amd64'; $$env:GOOS='windows'; $(GOBUILD) -buildmode=c-shared
else
# Unix-like system settings (Linux/MacOS)
RM_F := rm -f
# Cross-compilation settings
BUILD_CMD_EXE = GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ $(GOBUILD)
BUILD_CMD_DLL = GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ $(GOBUILD) -buildmode=c-shared
endif
all: build-exe build-dll
build-exe exe:
$(BUILD_CMD_EXE) -o $(EXE_NAME) .
build-dll dll:
$(BUILD_CMD_DLL) -o $(DLL_NAME) ./dll
test:
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
$(RM_F) $(EXE_NAME)
$(RM_F) $(DLL_NAME)
$(RM_F) $(DLL_NAME:.dll=.h)
run: build-exe
./$(EXE_NAME)
deps:
$(GOGET) ./...
.PHONY: all build-exe exe build-dll dll test clean run deps