2024-03-19 13:50:13 +01:00
|
|
|
#export GOPATH=$(shell pwd)/GO
|
|
|
|
#export GOBIN=$(GOPATH)/bin
|
|
|
|
#export PATH=$(GOBIN):$(shell echo $${PATH})
|
2024-02-27 07:22:57 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
GOCMD=go
|
2023-02-02 13:11:04 +01:00
|
|
|
GOBUILD=$(GOCMD) build # -compiler gccgo -gccgoflags -O3
|
2024-06-01 17:26:16 +02:00
|
|
|
GOGENERATE=$(GOCMD) generate
|
2022-02-24 07:26:55 +01:00
|
|
|
GOCLEAN=$(GOCMD) clean
|
|
|
|
GOTEST=$(GOCMD) test
|
|
|
|
GOGET=$(GOCMD) get
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
BUILD_DIR=build
|
2023-02-02 13:11:04 +01:00
|
|
|
OBITOOLS_PREFIX:=
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
PACKAGES_SRC:= $(wildcard pkg/*/*.go pkg/*/*/*.go)
|
|
|
|
PACKAGE_DIRS:=$(sort $(patsubst %/,%,$(dir $(PACKAGES_SRC))))
|
|
|
|
PACKAGES:=$(notdir $(PACKAGE_DIRS))
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
OBITOOLS_SRC:= $(wildcard cmd/obitools/*/*.go)
|
|
|
|
OBITOOLS_DIRS:=$(sort $(patsubst %/,%,$(dir $(OBITOOLS_SRC))))
|
|
|
|
OBITOOLS:=$(notdir $(OBITOOLS_DIRS))
|
2022-01-14 15:21:00 +01:00
|
|
|
|
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
define MAKE_PKG_RULE
|
2024-06-01 17:26:16 +02:00
|
|
|
pkg-$(notdir $(1)): $(1) pkg/obioptions/version.go
|
2022-02-24 07:26:55 +01:00
|
|
|
@echo -n - Building package $(notdir $(1))...
|
|
|
|
@$(GOBUILD) ./$(1) \
|
|
|
|
2> pkg-$(notdir $(1)).log \
|
|
|
|
|| cat pkg-$(notdir $(1)).log
|
|
|
|
@rm -f pkg-$(notdir $(1)).log
|
|
|
|
@echo Done.
|
|
|
|
endef
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
define MAKE_OBITOOLS_RULE
|
2024-06-01 17:26:16 +02:00
|
|
|
$(OBITOOLS_PREFIX)$(notdir $(1)): $(BUILD_DIR) $(1) pkg/obioptions/version.go
|
2022-02-24 07:26:55 +01:00
|
|
|
@echo -n - Building obitool $(notdir $(1))...
|
|
|
|
@$(GOBUILD) -o $(BUILD_DIR)/$(OBITOOLS_PREFIX)$(notdir $(1)) ./$(1) \
|
|
|
|
2> $(OBITOOLS_PREFIX)$(notdir $(1)).log \
|
|
|
|
|| cat $(OBITOOLS_PREFIX)$(notdir $(1)).log
|
|
|
|
@rm -f $(OBITOOLS_PREFIX)$(notdir $(1)).log
|
|
|
|
@echo Done.
|
|
|
|
endef
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2024-06-01 17:26:16 +02:00
|
|
|
GIT=$(shell which git 2>&1 >/dev/null && which git)
|
|
|
|
GITDIR=$(shell ls -d .git 2>/dev/null && echo .git || echo)
|
|
|
|
ifneq ($(strip $(GIT)),)
|
|
|
|
ifneq ($(strip $(GITDIR)),)
|
|
|
|
COMMIT_ID:=$(shell $(GIT) log -1 HEAD --format=%h)
|
|
|
|
LAST_TAG:=$(shell $(GIT) describe --tags $$($(GIT) rev-list --tags --max-count=1) | \
|
|
|
|
tr '_' ' ')
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
OUTPUT:=$(shell mktemp)
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
all: obitools
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
packages: $(patsubst %,pkg-%,$(PACKAGES))
|
|
|
|
obitools: $(patsubst %,$(OBITOOLS_PREFIX)%,$(OBITOOLS))
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2023-03-21 22:02:18 +07:00
|
|
|
update-deps:
|
|
|
|
go get -u ./...
|
|
|
|
|
2023-08-27 17:22:51 +02:00
|
|
|
test:
|
|
|
|
$(GOTEST) ./...
|
2025-02-19 13:17:36 +01:00
|
|
|
|
2025-02-19 13:45:43 +01:00
|
|
|
obitests: obitools
|
2025-02-19 13:17:36 +01:00
|
|
|
for t in $$(find obitests -name test.sh -print) ; do \
|
2025-02-19 13:58:52 +01:00
|
|
|
bash $${t} ; \
|
2025-02-19 13:17:36 +01:00
|
|
|
done
|
2023-08-27 17:22:51 +02:00
|
|
|
|
2023-02-23 23:45:41 +01:00
|
|
|
man:
|
|
|
|
make -C doc man
|
|
|
|
obibook:
|
|
|
|
make -C doc obibook
|
|
|
|
doc: man obibook
|
2022-05-27 11:53:29 +03:00
|
|
|
|
|
|
|
macos-pkg:
|
|
|
|
@bash pkgs/macos/macos-installer-builder-master/macOS-x64/build-macos-x64.sh \
|
|
|
|
OBITools \
|
|
|
|
0.0.1
|
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir -p $@
|
2022-01-14 15:21:00 +01:00
|
|
|
|
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
$(foreach P,$(PACKAGE_DIRS),$(eval $(call MAKE_PKG_RULE,$(P))))
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2022-02-24 07:26:55 +01:00
|
|
|
$(foreach P,$(OBITOOLS_DIRS),$(eval $(call MAKE_OBITOOLS_RULE,$(P))))
|
2022-01-14 15:21:00 +01:00
|
|
|
|
2024-06-01 17:26:16 +02:00
|
|
|
pkg/obioptions/version.go: .FORCE
|
|
|
|
ifneq ($(strip $(COMMIT_ID)),)
|
|
|
|
@cat $@ \
|
|
|
|
| sed -E 's/^var _Commit = "[^"]*"/var _Commit = "'$(COMMIT_ID)'"/' \
|
|
|
|
| sed -E 's/^var _Version = "[^"]*"/var _Version = "'"$(LAST_TAG)"'"/' \
|
|
|
|
> $(OUTPUT)
|
|
|
|
|
|
|
|
@diff $@ $(OUTPUT) 2>&1 > /dev/null \
|
|
|
|
|| echo "Update version.go : $@ to $(LAST_TAG) ($(COMMIT_ID))" \
|
|
|
|
&& mv $(OUTPUT) $@
|
|
|
|
|
|
|
|
@rm -f $(OUTPUT)
|
|
|
|
endif
|
|
|
|
|
2025-02-19 13:17:36 +01:00
|
|
|
.PHONY: all packages obitools man obibook doc update-deps obitests .FORCE
|
2024-06-01 17:26:16 +02:00
|
|
|
.FORCE:
|