# ## # Take a note - you MUST set CGO_ENABLED to true for cross-compilation ## # # PROJECT_NAME := "alchemyst-go" PKG := "lab.zaar.be/thefish/$(PROJECT_NAME)" GO=$(shell which go) CWD=$(shell pwd) OS=$(shell basename $(shell echo $@ | tr '.' '/' )) DISTFOLDER=$(CWD)/dist/$(OS) PKG_VER=$(shell git describe --tags | head) LDFLAGS="-X \"main.versionInfo=${PKG_VER}-${CI_PIPELINE_ID} built at $(shell date) on $(shell hostname) with $(shell go version)\"" .PHONY: all build test all: build test build: distclean build.deps build.game # build.game: build.game.linux64 build.game.win64 build.game.mac build.game: build.game.linux64 build.game.win64 build.deps: GIT_SSL_NO_VERIFY=true $(GO) mod vendor build.game.linux64: php update-config-version.php cp $(CWD)/vendor/lab.zaar.be/thefish/bearlibterminal/libBearLibTerminal.so $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ cp -r $(CWD)/assets $(DISTFOLDER) && \ $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && \ strip $(DISTFOLDER)/game && \ chmod +x $(DISTFOLDER)/game && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* build.game.win64: php update-config-version.php cp $(CWD)/lib/win64/BearLibTerminal.dll $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ cp -r $(CWD)/assets $(DISTFOLDER) && \ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ $(GO) build -o $(DISTFOLDER)/game.exe -ldflags $(LDFLAGS) $(CWD)/cmd/game/main.go && \ /usr/bin/x86_64-w64-mingw32-strip $(DISTFOLDER)/game.exe && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* # OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && build.game.mac: cp $(CWD)/lib/mac/libBearLibTerminal.dylib $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ cp -r $(CWD)/assets $(DISTFOLDER) && \ OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=clang CXX=clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && \ strip $(DISTFOLDER)/game.exe && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* test: $(GO) test -v $(go list ./... | grep -v /vendor/) distclean: cd $(CWD)/dist && find . -type f -not \( -name .gitkeep -o -name README \) -delete && \ find . -type d -not \( -name .gitkeep -o -name linux64 -o -name win64 -o -name mac \) -delete