File: Makefile.subdirs

package info (click to toggle)
flint 2.5.2-19
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 30,308 kB
  • sloc: ansic: 289,367; cpp: 11,210; python: 1,280; sh: 649; makefile: 283
file content (96 lines) | stat: -rw-r--r-- 2,819 bytes parent folder | download | duplicates (4)
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
QUIET_CC  = @echo '   ' CC  ' ' $@;

AT=@
comma=,

SOURCES = $(wildcard *.c)

HEADERS = $(wildcard ../*.h)
TEST_HEADERS = $(wildcard *.h)

OBJS = $(patsubst %.c, $(BUILD_DIR)/$(MOD_DIR)_%.o, $(SOURCES))

LOBJS = $(patsubst %.c, $(BUILD_DIR)/%.lo, $(SOURCES))
MOD_LOBJ = $(BUILD_DIR)/../$(MOD_DIR).lo

ifndef USER_SET_TESTS
	TEST_SOURCES = $(wildcard test/*.c)
	TESTXX_SOURCES = $(wildcard test/*.cpp)
else
	TL = $(subst $(comma), ,$(USER_SET_TESTS))
	TEST_SOURCES = $(foreach test, $(TL), $(wildcard test/t-$(test).c))
	TESTXX_SOURCES = $(foreach test, $(TL), $(wildcard test/t-$(test).cpp))
endif

PROF_SOURCES = $(wildcard profile/*.c)

TUNE_SOURCES = $(wildcard tune/*.c)

TESTS = $(patsubst %.c, $(BUILD_DIR)/%$(EXEEXT), $(TEST_SOURCES)) \
        $(patsubst %.cpp, $(BUILD_DIR)/%$(EXEEXT), $(TESTXX_SOURCES))

TESTS_RUN = $(patsubst %, %_RUN, $(TESTS))

VALGRIND_RUN = $(patsubst %, %_VALGRIND_RUN, $(TESTS))

PROFS = $(patsubst %.c, $(BUILD_DIR)/%$(EXEEXT), $(PROF_SOURCES))

TUNE = $(patsubst %.c, %$(EXEEXT), $(TUNE_SOURCES))

all: shared static

shared: $(MOD_LOBJ)

static: $(OBJS)

profile: $(PROFS)

-include $(patsubst %, %.d, $(PROFS))

$(BUILD_DIR)/profile/%$(EXEEXT): profile/%.c $(BUILD_DIR)/../profiler.o
	$(QUIET_CC) $(CC) $(CFLAGS) -std=gnu99 $(INCS) $< $(BUILD_DIR)/../profiler.o -o $@ $(LIBS)  -MMD -MP -MF $@.d -MT "$@" -MT "$@.d"

tune: $(TUNE_SOURCES) $(HEADERS)
	$(AT)$(foreach prog, $(TUNE), $(CC) $(CFLAGS) $(INCS) $(prog).c -o $(BUILD_DIR)/$(prog) $(LIBS) || exit $$?;)

-include $(OBJS:.o=.d)

$(BUILD_DIR)/$(MOD_DIR)_%.o: %.c
	$(QUIET_CC) $(CC) $(CFLAGS) $(INCS) -c $< -o $@ -MMD -MP -MF "$(BUILD_DIR)/$(MOD_DIR)_$*.d" -MT "$(BUILD_DIR)/$(MOD_DIR)_$*.d" -MT "$@"

$(MOD_LOBJ): $(LOBJS)
	$(QUIET_CC) $(CC) $(ABI_FLAG) -r $^ -o $@ -nostdlib

-include $(LOBJS:.lo=.d)

$(BUILD_DIR)/%.lo: %.c
	$(QUIET_CC) $(CC) $(PIC_FLAG) $(CFLAGS) $(INCS) -c $< -o $@ -MMD -MP -MF "$(BUILD_DIR)/$*.d" -MT "$(BUILD_DIR)/$*.d" -MT "$@"

clean:
	rm -rf $(BUILD_DIR) $(MOD_LOBJ)

tests: $(TESTS)

check: tests $(TESTS_RUN)

valgrind: tests $(VALGRIND_RUN)

-include $(patsubst %, %.d, $(TESTS))

ifeq ($(FLINT_SHARED), 0)
$(BUILD_DIR)/test/%$(EXEEXT): $(BUILD_DIR)/../../libflint.a
endif

$(BUILD_DIR)/test/%$(EXEEXT): test/%.c $(BUILD_DIR)/../../test_helpers.o
	$(QUIET_CC) $(CC) $(CFLAGS) $(INCS) $< $(BUILD_DIR)/../../test_helpers.o -o $@ $(LIBS) -MMD -MP -MF $@.d -MT "$@" -MT "$@.d"

$(BUILD_DIR)/test/%$(EXEEXT): test/%.cpp $(BUILD_DIR)/../../test_helpers.o
	$(QUIET_CC) $(CXX) $(CFLAGS) $(INCS) $< $(BUILD_DIR)/../../test_helpers.o -o $@ $(LIBS) -MMD -MP -MF $@.d -MT "$@" -MT "$@.d"

%_RUN: %
	@$<

%_VALGRIND_RUN: %
	valgrind --track-origins=yes --leak-check=full --show-reachable=yes --log-file="$*.valgrind" $<

.PHONY: profile tune clean check tests all shared static valgrind %_RUN %_VALGRIND_RUN