aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile183
1 files changed, 171 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index bb8fffa..5a86b33 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,176 @@
1.PHONY: all-32 all-64 all-sparc clean purge 1# figure out what kind of host we are running on
2host-arch := $(shell uname -m | \
3 sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/)
2 4
3all-32: 5# ##############################################################################
4 echo "Legacy warning: Building is done with scons." 6# User variables
5 ARCH=x86 scons
6all-64:
7 ARCH=x86_64 scons
8 7
9all-sparc: 8# user variables can be specified in the environment or in a .config file
10 ARCH=sparc64 scons 9-include .config
10
11# ARCH -- what architecture are we compiling for?
12ARCH ?= ${host-arch}
13
14# LITMUS_KERNEL -- where to find the litmus kernel?
15LITMUS_KERNEL ?= ../litmus2010
16
17
18# ##############################################################################
19# Internal configuration.
20
21# compiler flags
22flags-debug = -Wall -g -Wdeclaration-after-statement
23flags-api = -D_XOPEN_SOURCE=600 -D_GNU_SOURCE
24flags-link-rt = -static
25
26# architecture-specific flags
27flags-i386 = -m32
28flags-x86_64 = -m64
29flags-sparc64 = -mcpu=v9 -m64
30# default: none
31
32# name of the directory that has the arch headers in the Linux source
33include-i386 = x86
34include-x86_64 = x86
35include-sparc64 = sparc
36# default: the arch name
37include-${ARCH} ?= ${ARCH}
38
39# where to find header files
40headers = -Iinclude \
41 -I${LITMUS_KERNEL}/include/ \
42 -I${LITMUS_KERNEL}/arch/${include-${ARCH}}/include
43
44# combine options
45CPPFLAGS = ${flags-api} ${flags-${ARCH}} ${headers}
46CFLAGS = ${flags-debug}
47LDFLAGS = ${flags-${ARCH}}
48
49# how to link against liblitmus
50liblitmus-flags = -L. -llitmus
51
52# Force gcc instead of cc, but let the user specify a more specific version if
53# desired.
54ifeq (${CC},cc)
55CC = gcc
56endif
57
58# incorporate cross-compiler (if any)
59CC := ${CROSS_COMPILE}${CC}
60LD := ${CROSS_COMPILE}${LD}
61AR := ${CROSS_COMPILE}${AR}
62
63# ##############################################################################
64# Targets
65
66all = lib ${rt-apps}
67rt-apps = cycles base_task rt_launch rtspin release_ts measure_syscall \
68 base_mt_task runtests
69
70.PHONY: all lib clean dump-config
71
72all: ${all}
73
74dump-config:
75 @echo Build configuration:
76 @printf "%-15s= %-20s\n" \
77 ARCH ${ARCH} \
78 LITMUS_KERNEL "${LITMUS_KERNEL}" \
79 CROSS_COMPILE "${CROSS_COMPILE}" \
80 headers "${headers}" \
81 CFLAGS "${CFLAGS}" \
82 LDFLAGS "${LDFLAGS}" \
83 CPPFLAGS "${CPPFLAGS}" \
84 CC "${CC}" \
85 CPP "${CPP}" \
86 LD "${LD}" \
87 AR "${AR}" \
88 obj-all "${obj-all}"
11 89
12clean: 90clean:
13 echo "Legacy warning: Building is now done with scons." 91 rm -f ${rt-apps}
14 scons -c 92 rm -f *.o *.d *.a test_catalog.inc
93
94
95# ##############################################################################
96# liblitmus
97
98lib: liblitmus.a
99
100# all .c file in src/ are linked into liblitmus
101vpath %.c src/
102obj-lib = $(patsubst src/%.c,%.o,$(wildcard src/*.c))
103
104liblitmus.a: ${obj-lib}
105 ${AR} rcs $@ $+
106
107# ##############################################################################
108# Tests suite.
109
110# tests are found in tests/
111vpath %.c tests/
112
113src-runtests = $(wildcard tests/*.c)
114obj-runtests = $(patsubst tests/%.c,%.o,${src-runtests})
115
116# generate list of tests automatically
117test_catalog.inc: $(filter-out tests/runner.c,${src-runtests})
118 tests/make_catalog.py $+ > $@
119
120.SECONDARY: test_catalog.inc
121
122tests/runner.c: test_catalog.inc
123
124
125# ##############################################################################
126# Tools that link with liblitmus
127
128# these source files are found in bin/
129vpath %.c bin/
130
131obj-cycles = cycles.o
132
133obj-base_task = base_task.o
134
135obj-base_mt_task = base_mt_task.o
136ldf-base_mt_task = -pthread
137
138obj-rt_launch = rt_launch.o common.o
139
140obj-rtspin = rtspin.o common.o
141lib-rtspin = -lrt
142
143obj-release_ts = release_ts.o
144
145obj-measure_syscall = null_call.o
146lib-measure_syscall = -lm
147
148# ##############################################################################
149# Build everything that depends on liblitmus.
150
151.SECONDEXPANSION:
152${rt-apps}: $${obj-$$@} liblitmus.a
153 $(CC) -o $@ $(LDFLAGS) ${ldf-$@} $(filter-out liblitmus.a,$+) $(LOADLIBS) $(LDLIBS) ${lib-$@} ${liblitmus-flags}
154
155# ##############################################################################
156# Dependency resolution.
157
158vpath %.c bin/ src/ tests/
159
160obj-all = ${sort ${foreach target,${all},${obj-${target}}}}
161
162# rule to generate dependency files (straight from make manual)
163%.d: %.c
164 @set -e; rm -f $@; \
165 $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
166 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
167 rm -f $@.$$$$
168
169ifeq ($(MAKECMDGOALS),)
170MAKECMDGOALS += all
171endif
172
173ifneq ($(filter-out dump-config clean,$(MAKECMDGOALS)),)
174-include ${obj-all:.o=.d}
175endif
15 176
16purge: clean
17 rm -rf .sconf_temp .sconsign.dblite