aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-11-09 16:29:55 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-11-22 15:00:16 -0500
commite9e4de6729a846c4c99754371c0d1738a0238381 (patch)
treedaf679a7eb5e997d9294599a2b0a4041d6159ef0
parentee91e39147039693f9f4063e319b836adb8401bf (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--Makefile27
-rw-r--r--inc/depend.makefile22
2 files changed, 46 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 54f4b57..0738648 100644
--- a/Makefile
+++ b/Makefile
@@ -41,8 +41,11 @@ unistd-x86_64 = unistd.h unistd_64.h
41# default: unistd.h 41# default: unistd.h
42unistd-${ARCH} ?= unistd.h 42unistd-${ARCH} ?= unistd.h
43 43
44# by default we use the local version
45LIBLITMUS ?= .
46
44# where to find header files 47# where to find header files
45headers = -Iinclude -Iarch/${include-${ARCH}}/include 48headers = -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/${include-${ARCH}}/include
46 49
47# combine options 50# combine options
48CPPFLAGS = ${flags-api} ${flags-${ARCH}} -DARCH=${ARCH} ${headers} 51CPPFLAGS = ${flags-api} ${flags-${ARCH}} -DARCH=${ARCH} ${headers}
@@ -50,7 +53,7 @@ CFLAGS = ${flags-debug}
50LDFLAGS = ${flags-${ARCH}} 53LDFLAGS = ${flags-${ARCH}}
51 54
52# how to link against liblitmus 55# how to link against liblitmus
53liblitmus-flags = -L. -llitmus 56liblitmus-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
75all: ${all} 78all: ${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.
84inc/config.makefile: LIBLITMUS = $${LIBLITMUS}
85inc/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
77dump-config: 97dump-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
4obj-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
13ifeq ($(MAKECMDGOALS),)
14MAKECMDGOALS += all
15endif
16
17ifneq ($(filter-out clean,$(MAKECMDGOALS)),)
18
19# Pull in dependencies.
20-include ${obj-all:.o=.d}
21
22endif