diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-09 16:29:55 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-22 15:00:16 -0500 |
commit | e9e4de6729a846c4c99754371c0d1738a0238381 (patch) | |
tree | daf679a7eb5e997d9294599a2b0a4041d6159ef0 | |
parent | ee91e39147039693f9f4063e319b836adb8401bf (diff) |
Provide standard Makefile rules for clients of liblitmus
We avoid doing the same thing over and over in all repositories using
liblitmus if we just pull in common rules & configurations from
liblitmus. This gives us the ability to cross-compile for free.
-rw-r--r-- | Makefile | 27 | ||||
-rw-r--r-- | inc/depend.makefile | 22 |
2 files changed, 46 insertions, 3 deletions
@@ -41,8 +41,11 @@ unistd-x86_64 = unistd.h unistd_64.h | |||
41 | # default: unistd.h | 41 | # default: unistd.h |
42 | unistd-${ARCH} ?= unistd.h | 42 | unistd-${ARCH} ?= unistd.h |
43 | 43 | ||
44 | # by default we use the local version | ||
45 | LIBLITMUS ?= . | ||
46 | |||
44 | # where to find header files | 47 | # where to find header files |
45 | headers = -Iinclude -Iarch/${include-${ARCH}}/include | 48 | headers = -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/${include-${ARCH}}/include |
46 | 49 | ||
47 | # combine options | 50 | # combine options |
48 | CPPFLAGS = ${flags-api} ${flags-${ARCH}} -DARCH=${ARCH} ${headers} | 51 | CPPFLAGS = ${flags-api} ${flags-${ARCH}} -DARCH=${ARCH} ${headers} |
@@ -50,7 +53,7 @@ CFLAGS = ${flags-debug} | |||
50 | LDFLAGS = ${flags-${ARCH}} | 53 | LDFLAGS = ${flags-${ARCH}} |
51 | 54 | ||
52 | # how to link against liblitmus | 55 | # how to link against liblitmus |
53 | liblitmus-flags = -L. -llitmus | 56 | liblitmus-flags = -L${LIBLITMUS} -llitmus |
54 | 57 | ||
55 | # Force gcc instead of cc, but let the user specify a more specific version if | 58 | # Force gcc instead of cc, but let the user specify a more specific version if |
56 | # desired. | 59 | # desired. |
@@ -72,7 +75,24 @@ rt-apps = cycles base_task rt_launch rtspin release_ts measure_syscall \ | |||
72 | 75 | ||
73 | .PHONY: all lib clean dump-config | 76 | .PHONY: all lib clean dump-config |
74 | 77 | ||
75 | all: ${all} | 78 | all: ${all} inc/config.makefile |
79 | |||
80 | # Write a distilled version of the flags for clients of the library. Ideally, | ||
81 | # this should depend on liblitmus.a, but that requires LIBLITMUS to be a | ||
82 | # private override. Private overrides are only supported starting with make | ||
83 | # 3.82, which is not yet in common use. | ||
84 | inc/config.makefile: LIBLITMUS = $${LIBLITMUS} | ||
85 | inc/config.makefile: Makefile | ||
86 | @printf "%-15s= %-20s\n" \ | ||
87 | ARCH ${ARCH} \ | ||
88 | CFLAGS '${CFLAGS}' \ | ||
89 | LDFLAGS '${LDFLAGS}' \ | ||
90 | LDLIBS '${liblitmus-flags}' \ | ||
91 | CPPFLAGS '${CPPFLAGS}' \ | ||
92 | CC '${shell which ${CC}}' \ | ||
93 | LD '${shell which ${LD}}' \ | ||
94 | AR '${shell which ${AR}}' \ | ||
95 | > $@ | ||
76 | 96 | ||
77 | dump-config: | 97 | dump-config: |
78 | @echo Build configuration: | 98 | @echo Build configuration: |
@@ -95,6 +115,7 @@ clean: | |||
95 | rm -f ${rt-apps} | 115 | rm -f ${rt-apps} |
96 | rm -f *.o *.d *.a test_catalog.inc | 116 | rm -f *.o *.d *.a test_catalog.inc |
97 | rm -f ${imported-headers} | 117 | rm -f ${imported-headers} |
118 | rm -f inc/config.makefile | ||
98 | 119 | ||
99 | # ############################################################################## | 120 | # ############################################################################## |
100 | # Kernel headers. | 121 | # Kernel headers. |
diff --git a/inc/depend.makefile b/inc/depend.makefile new file mode 100644 index 0000000..4d10534 --- /dev/null +++ b/inc/depend.makefile | |||
@@ -0,0 +1,22 @@ | |||
1 | # Generic dependency resolution. Part of liblitmus so that we don't have to | ||
2 | # carry it around in every project using liblitmus. | ||
3 | |||
4 | obj-all = ${sort ${foreach target,${all},${obj-${target}}}} | ||
5 | |||
6 | # rule to generate dependency files | ||
7 | %.d: %.c | ||
8 | @set -e; rm -f $@; \ | ||
9 | $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ | ||
10 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | ||
11 | rm -f $@.$$$$ | ||
12 | |||
13 | ifeq ($(MAKECMDGOALS),) | ||
14 | MAKECMDGOALS += all | ||
15 | endif | ||
16 | |||
17 | ifneq ($(filter-out clean,$(MAKECMDGOALS)),) | ||
18 | |||
19 | # Pull in dependencies. | ||
20 | -include ${obj-all:.o=.d} | ||
21 | |||
22 | endif | ||