File: Makefile

package info (click to toggle)
libfiu 1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ansic: 2,633; python: 973; makefile: 599; sh: 309
file content (85 lines) | stat: -rw-r--r-- 1,922 bytes parent folder | download
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

CFLAGS += -std=c99 -pedantic -Wall
ALL_CFLAGS = -I../../libfiu/ -L../../libfiu/ \
	-D_XOPEN_SOURCE=600 -D_GNU_SOURCE -fPIC -DFIU_ENABLE=1 $(CFLAGS)

ifdef DEBUG
ALL_CFLAGS += -g
endif

ifdef PROFILE
ALL_CFLAGS += -g -pg -fprofile-arcs -ftest-coverage
endif

# Note we pass -O0 (after $CFLAGS) to explicitly disable optimizations;
# otherwise, the compiler may inline or optimize away some of the functions
# under test, causing false positives.
# See https://bugs.debian.org/1097184 for an example.
ALL_CFLAGS += -O0

ifneq ($(V), 1)
	NICE_CC = @echo "  CC  $@"; $(CC)
	NICE_RUN = @echo "  RUN $<"; \
		   LD_LIBRARY_PATH=../../libfiu/ \
		   LD_PRELOAD="../../preload/run/fiu_run_preload.so \
		   	../../preload/posix/fiu_posix_preload.so"
	NICE_GEN = @echo "  GEN $@"; ./generate-test
else
	NICE_CC = $(CC)
	NICE_RUN = LD_LIBRARY_PATH=../../libfiu/ \
		   LD_PRELOAD="../../preload/run/fiu_run_preload.so \
		   	../../preload/posix/fiu_posix_preload.so"
	NICE_GEN = ./generate-test
endif

default: tests

all: tests


CONF := $(wildcard tests/*.conf)
GEN_BIN := $(patsubst %.conf,%.bin,$(CONF))

tests: $(patsubst %,%-run,$(GEN_BIN))

%-run: %
	$(NICE_RUN) ./$<

# .bin from .c
%.bin: %.c build-flags
	$(NICE_CC) $(ALL_CFLAGS) $< -lfiu -o $@

# .c from .conf
%.c: %.conf generate-test
	$(NICE_GEN) -c $< -o $@

# Useful for manually generating the C-files, that otherwise get deleted as
# intermediates.
c-files: $(patsubst %.conf,%.c,$(CONF))


BF = $(ALL_CFLAGS) ~ $(PREFIX)
build-flags: .force-build-flags
	@if [ x"$(BF)" != x"`cat build-flags 2>/dev/null`" ]; then \
		if [ -f build-flags ]; then \
			echo "build flags changed, rebuilding"; \
		fi; \
		echo "$(BF)" > build-flags; \
	fi


#
# Cleanup
#

clean:
	rm -f $(GEN_BIN) $(patsubst %.bin,%.c,$(GEN_BIN))
	rm -f *.bb *.bbg *.da *.gcov *.gcda *.gcno gmon.out build-flags

FORCE:

.PHONY: default all clean \
	tests c-tests py-tests \
	.force-build-flags