forked from christianhujer/aceunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (88 loc) · 3.35 KB
/
Makefile
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
102
103
104
105
106
107
108
#subs:=lib test examples #$(patsubst %/Makefile,%,$(wildcard */Makefile))
include recurse.mk
## all: Build and test AceUnit (library, generator, and integration).
## clean: Remove all generated files.
## lib-all: Build and self-test the AceUnit library.
test-all examples-all: lib-all
versions:=c90 c99 c11 c17 c2x gnu90 gnu99 gnu11 gnu17 gnu2x
## compiler-test: Test AceUnit with different versions of C.
compiler-test: $(versions:%=compiler-test-%)
compiler-test-%:
$(MAKE) clean
$(MAKE) CFLAGS+="-std=$*" CVERSION:=$*
PREFIX?=/usr/local/
MANDIR?=share/man
VERSION:=$(shell cat VERSION)
FILES_TO_INSTALL:=\
$(DESTDIR)$(PREFIX)/bin/aceunit \
$(DESTDIR)$(PREFIX)/include/aceunit.h \
$(DESTDIR)$(PREFIX)/include/aceunit.mk \
$(DESTDIR)$(PREFIX)/lib/libaceunit-abort.a \
$(DESTDIR)$(PREFIX)/lib/libaceunit-fork.a \
$(DESTDIR)$(PREFIX)/lib/libaceunit-setjmp.a \
$(DESTDIR)$(PREFIX)/lib/libaceunit-simple.a \
$(DESTDIR)$(PREFIX)/share/aceunit/nm.ac \
$(DESTDIR)$(PREFIX)/share/aceunit/objdump.ac \
$(DESTDIR)$(PREFIX)/share/aceunit/readelf.ac \
$(DESTDIR)$(PREFIX)/share/doc/aceunit/copyright \
$(DESTDIR)$(PREFIX)/$(MANDIR)/man1/aceunit.1 \
$(DESTDIR)$(PREFIX)/$(MANDIR)/man3/aceunit.3
.PHONY: build
## build Build the AceUnit library without running any tests.
build:
$(MAKE) -C lib libs
.PHONY: install
## install: Install AceUnit for the local system (Unix/POSIX/Cygwin/MinGW).
install: $(FILES_TO_INSTALL)
INSTALL_SCRIPT:=$(or $(BSD_INSTALL_SCRIPT),install)
INSTALL_DATA:=$(or $(BSD_INSTALL_DATA),install -m 644)
$(DESTDIR)$(PREFIX)/bin/aceunit: bin/aceunit
install -d $(dir $@)
$(INSTALL_SCRIPT) $^ $@
$(DESTDIR)$(PREFIX)/%: %
install -d $(dir $@)
$(INSTALL_DATA) $^ $@
$(DESTDIR)$(PREFIX)/include/aceunit.mk: include/aceunit.mk
install -d $(dir $@)
sed -e 's#$${PREFIX}#$(PREFIX)#' <$< >$@
lib/%:
$(MAKE) -C lib/ $*
.PHONY: uninstall
## uninstall: Remove AceUnit from the local system (Unix/POSIX/Cygwin/MinGW).
uninstall:
$(RM) $(FILES_TO_INSTALL)
.PHONY: dist
## dist: Creates source and binary distribution archives.
dist: dist-src dist-bin
.PHONY: dist-src
## dist-src: Creates source distribution archives.
dist-src: archive:=aceunit-$(VERSION)-src
dist-src:
mkdir -p dist-src/
git archive -o dist-src/$(archive).tar --prefix $(archive)/ HEAD .
<dist-src/$(archive).tar gzip -9 >dist-src/$(archive).tar.gz
<dist-src/$(archive).tar bzip2 -9 >dist-src/$(archive).tar.bz2
<dist-src/$(archive).tar xz -9 >dist-src/$(archive).tar.xz
.PHONY: dist-bin
## dist-bin: Creates a binary distribution archive.
dist-bin: os:=$(shell uname -s)
dist-bin: hw:=$(shell uname -m)
dist-bin: archive:=aceunit-$(VERSION)-bin-$(os)-$(hw)
dist-bin: TARCFLAGS:=$(if $(filter bsdtar,$(firstword $(shell tar --version))),--uid=0 --gid=0,--owner=0 --group=0 --mode='og-w')
dist-bin:
mkdir -p dist-bin/$(archive)/
$(MAKE) DESTDIR=dist-bin/$(archive)/ PREFIX=/usr/ install
tar $(TARCFLAGS) -c -f dist-bin/$(archive).tar -C dist-bin/ $(archive)/
<dist-bin/$(archive).tar gzip -9 >dist-bin/$(archive).tar.gz
<dist-bin/$(archive).tar bzip2 -9 >dist-bin/$(archive).tar.bz2
<dist-bin/$(archive).tar xz -9 >dist-bin/$(archive).tar.xz
.PHONY: help
## help: Print this help text.
help:
@sed -En 's/^## ?//p' $(MAKEFILE_LIST)
.PHONY: debug
.ONESHELL: debug
debug:
echo subs=$(subs)
echo targets=$(targets)
echo recurse_template='$(recurse_template)'