Files
pmg/Makefile
T

45 lines
1.0 KiB
Makefile
Raw Normal View History

2025-04-21 21:13:23 +05:30
GO := go
BIN_DIR := bin
# Platform detection
ifeq ($(OS),Windows_NT)
BINARY_EXT := .exe
# Detect if we are in a Unix-like shell on Windows (e.g. Git Bash)
# If 'uname' is available, we assume a Unix-like shell
ifneq ($(shell uname -s 2>/dev/null),)
MKDIR_P := mkdir -p $(BIN_DIR)
RM_RF := rm -rf $(BIN_DIR)
else
MKDIR_P := if not exist $(BIN_DIR) mkdir $(BIN_DIR)
RM_RF := if exist $(BIN_DIR) rmdir /s /q $(BIN_DIR)
endif
else
BINARY_EXT :=
MKDIR_P := mkdir -p $(BIN_DIR)
RM_RF := rm -rf $(BIN_DIR)
SHELL := /bin/bash
endif
BIN := $(BIN_DIR)/pmg$(BINARY_EXT)
2025-05-16 09:41:48 +05:30
GITCOMMIT := $(shell git rev-parse HEAD)
VERSION := "$(shell git describe --tags --abbrev=0)-$(shell git rev-parse --short HEAD)"
2025-08-21 23:01:30 +05:30
GO_CFLAGS=-X 'github.com/safedep/pmg/internal/version.Commit=$(GITCOMMIT)' -X 'github.com/safedep/pmg/internal/version.Version=$(VERSION)'
2025-05-16 09:41:48 +05:30
GO_LDFLAGS=-ldflags "-w $(GO_CFLAGS)"
2025-04-21 21:13:23 +05:30
.PHONY: all pmg create_bin clean test
2025-04-21 21:13:23 +05:30
all: pmg
pmg: create_bin
2025-05-16 09:41:48 +05:30
$(GO) build ${GO_LDFLAGS} -o $(BIN) main.go
2025-04-21 21:13:23 +05:30
create_bin:
$(MKDIR_P)
2025-04-21 21:13:23 +05:30
clean:
$(RM_RF)
test:
go test ./...