TARGET=mccl ifeq ($(shell go env GOOS),windows) EXEC_NAME=${TARGET}.exe else EXEC_NAME=${TARGET} endif DESTDIR:= PREFIX:=/usr/local VERSION=0.1.1 FLAGS:=-buildmode=pie -modcacherw -mod=readonly -trimpath LDFLAGS:= -ldflags "-s -w -X main.programVersion=${VERSION}" .PHONY: ${TARGET} install uninstall clean ${TARGET}: ifeq ($(shell go env GOOS),windows) go build -o bin/$@.exe ${LDFLAGS} ${FLAGS} cmd/$@/main.go else go build -o bin/$@ ${LDFLAGS} ${FLAGS} cmd/$@/main.go endif install: install -Dm 0755 bin/${EXEC_NAME} ${DESTDIR}${PREFIX}/bin/${EXEC_NAME} uninstall: rm ${DESTDIR}${PREFIX}/bin/${EXEC_NAME} clean: rm -f bin/*