-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (83 loc) · 3.65 KB
/
Makefile
File metadata and controls
101 lines (83 loc) · 3.65 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
MVN := mvn
DOCKER := docker
VERSION := $(shell xmllint --xpath "/*/*[local-name()='version']/text()" pom.xml)
TARGET_NAR_LINUX_32 := $(addprefix target/nar/hyphen-$(VERSION)-i386-Linux-gpp-,executable shared)
TARGET_NAR_LINUX_X64 := $(addprefix target/nar/hyphen-$(VERSION)-amd64-Linux-gpp-,executable shared)
TARGET_NAR_LINUX_ARM64 := $(addprefix target/nar/hyphen-$(VERSION)-aarch64-Linux-gpp-,executable shared)
TARGET_NAR_MAC_32 := $(addprefix target/nar/hyphen-$(VERSION)-i386-MacOSX-gpp-,executable shared)
TARGET_NAR_MAC_X64 := $(addprefix target/nar/hyphen-$(VERSION)-x86_64-MacOSX-gpp-,executable shared)
TARGET_NAR_MAC_ARM64 := $(addprefix target/nar/hyphen-$(VERSION)-aarch64-MacOSX-gpp-,executable shared)
TARGET_NAR_WIN_32 := $(addprefix target/nar/hyphen-$(VERSION)-i586-mingw32msvc-gpp-,executable shared)
TARGET_NAR_WIN_64 := $(addprefix target/nar/hyphen-$(VERSION)-x86_64-w64-mingw32-gpp-,executable shared)
.PHONY : all
all : compile-linux compile-windows
compile-linux : $(TARGET_NAR_LINUX_32) $(TARGET_NAR_LINUX_X64) $(TARGET_NAR_LINUX_ARM64)
compile-windows : $(TARGET_NAR_WIN_32) $(TARGET_NAR_WIN_64)
ifeq ($(shell uname -s),Darwin)
all : compile-macosx
ifeq ($(shell uname -m),x86_64)
compile-macosx : $(TARGET_NAR_MAC_X64)
else
compile-macosx : $(TARGET_NAR_MAC_ARM64)
endif
endif
.PHONY : clean
clean :
$(MVN) clean
DOCKER_IMAGE_ := libhyphen-nar_debian_
# can not use --platform linux/amd64,linux/arm64 (see https://github.com/docker/buildx/issues/59)
.PHONY : docker-images
docker-images :
if ! $(DOCKER) images | grep $(DOCKER_IMAGE_)amd64 || ! $(DOCKER) images | grep $(DOCKER_IMAGE_)arm64; then \
$(DOCKER) buildx create --use --name=mybuilder \
--driver docker-container \
--driver-opt image=moby/buildkit:buildx-stable-1 && \
if ! $(DOCKER) images | grep $(DOCKER_IMAGE_)amd64; then \
$(DOCKER) buildx build --platform linux/amd64 \
-t $(DOCKER_IMAGE_)amd64 \
--load \
Dockerfile; \
fi && \
if ! $(DOCKER) images | grep $(DOCKER_IMAGE_)arm64; then \
$(DOCKER) buildx build --platform linux/arm64 \
-t $(DOCKER_IMAGE_)arm64 \
--load \
Dockerfile; \
fi ; \
$(DOCKER) buildx rm mybuilder; \
fi
mvn-on-linux = $(MAKE) docker-images && \
$(DOCKER) run --platform linux/$(call strip,$1) \
--rm \
-v "$(CURDIR):/root/src" \
-v "$(CURDIR)/.m2/repository:/root/.m2/repository" \
-w "/root/src" \
-it $(DOCKER_IMAGE_)$(call strip,$1) \
mvn $2
$(TARGET_NAR_LINUX_32) :
$(call mvn-on-linux, amd64, test -Dos.arch=i386)
$(TARGET_NAR_LINUX_X64) :
$(call mvn-on-linux, amd64, test)
$(TARGET_NAR_LINUX_ARM64) :
$(call mvn-on-linux, arm64, test)
$(TARGET_NAR_MAC_32) :
[[ "$$(uname -s)" == Darwin ]]
$(MVN) test -Dos.arch=i386
$(TARGET_NAR_MAC_X64) :
[[ "$$(uname -s)" == Darwin && "$$(uname -m)" == x86_64 ]]
$(MVN) test
$(TARGET_NAR_MAC_ARM64) :
[[ "$$(uname -s)" == Darwin && "$$(uname -m)" == arm64 ]]
$(MVN) test
$(TARGET_NAR_WIN_32) :
$(call mvn-on-linux, amd64, test -Pcross-compile -Dhost.os=w64-mingw32 -Dos.arch=i686)
$(TARGET_NAR_WIN_64) :
$(call mvn-on-linux, amd64, test -Pcross-compile -Dhost.os=w64-mingw32 -Dos.arch=x86_64)
snapshot :
[[ $(VERSION) == *-SNAPSHOT ]]
$(MVN) nar:nar-package install:install deploy:deploy
release :
[[ $(VERSION) != *-SNAPSHOT ]]
$(MVN) nar:nar-package jar:jar gpg:sign install:install deploy:deploy -Psonatype-deploy
install :
$(MVN) nar:nar-prepare-package nar:nar-package jar:jar install:install