diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 80 |
1 files changed, 3 insertions, 77 deletions
@@ -1,78 +1,4 @@ | |||
1 | OBJS:=$(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) | 1 | .PHONY: pymake |
2 | USRCS:=$(wildcard src/unit/*.cpp) | ||
3 | UOBJS:=$(patsubst %.cpp,%.o,$(USRCS)) | ||
4 | UNIT:=$(foreach ut,$(patsubst %.cpp,%,$(wildcard src/unit/*.cpp)),unit/$(notdir $(ut))) | ||
5 | TOBJS:=$(patsubst %.cpp,%.o,$(wildcard src/test/*.cpp)) | ||
6 | TDIRS:=$(filter-out %.o %.cpp %.h %.d,$(wildcard src/test/*)) | ||
7 | TESTS:=$(patsubst src/test/%.o,tests/%,$(TOBJS)) $(patsubst src/test/%,tests/%,$(TDIRS)) | ||
8 | ATOBJS:=$(TOBJS) $(patsubst %.cpp,%.o,$(foreach dr,$(TDIRS),$(wildcard $(dr)/*.cpp))) | ||
9 | LIB:=libbu++.a | ||
10 | DATE:=$(shell date +%F) | ||
11 | |||
12 | TXTCPP:="\ g++:\ \ \ " | ||
13 | TXTLNK:="\ \ ld:\ \ \ " | ||
14 | TXTDEP:="\ dep:\ \ \ " | ||
15 | TXTARC:="\ \ ar:\ \ \ " | ||
16 | |||
17 | .PHONY: all clean dist tests depclean cleanapi | ||
18 | .SILENT: clean $(OBJS) $(TOBJS) $(ATOBJS) $(UNIT) $(UOBJS) $(TESTS) $(patsubst %.o,%.d,$(OBJS) $(TOBJS) $(ATOBJS) $(UOBJS) $(TESTS)) $(LIB) | ||
19 | |||
20 | all: libbu++.a | ||
21 | |||
22 | depclean: | ||
23 | -rm $(patsubst %.o,%.d,$(OBJS) $(ATOBJS) $(UOBJS)) | ||
24 | |||
25 | -include $(patsubst %.o,%.d,$(OBJS) $(ATOBJS) $(UOBJS)) | ||
26 | |||
27 | clean: | ||
28 | -rm $(OBJS) $(ATOBJS) $(UOBJS) $(TESTS) $(LIB) | ||
29 | |||
30 | # This bit I cribbed from the docs, seems to work great though! | ||
31 | %.d: %.cpp | ||
32 | echo "$(TXTDEP)$@" | ||
33 | g++ $(CXXFLAGS) -Isrc -M $(CPPFLAGS) $< | sed 's,\($(notdir $*)\)\.o[: ]*,$(dir $*)\1.o $@: ,g' > $@ | ||
34 | |||
35 | %.o: %.cpp | ||
36 | echo "$(TXTCPP)$@" | ||
37 | g++ -fPIC $(CXXFLAGS) -Isrc $(foreach dr,$(filter $(dir $@),$(foreach ddr,$(TDIRS),$(ddr)/)),-I$(dr)) -ggdb -c -o $@ $< | ||
38 | |||
39 | $(LIB): $(OBJS) | ||
40 | echo "$(TXTARC)$@" | ||
41 | ar cr $(LIB) $(OBJS) | ||
42 | |||
43 | $(TESTS): $(ATOBJS) $(LIB) | ||
44 | echo "$(TXTLNK)$@" | ||
45 | g++ $(LDFLAGS) -ggdb $(filter %$(patsubst tests/%,%,$@).o, $(TOBJS) ) $(patsubst %.cpp,%.o,$(wildcard $(filter %$(patsubst tests/%,%,$@), $(TDIRS))/*.cpp)) -L. -lbu++ -ldl -o $@ | ||
46 | |||
47 | $(UNIT): $(USRCS) $(LIB) | ||
48 | echo "$(TXTLNK)$@" | ||
49 | g++ $(LDFLAGS) -ggdb -Isrc -Isrc/unit src/$@.cpp -L. -lbu++ -lcpptest -o $@ | ||
50 | |||
51 | tests: $(TESTS) | ||
52 | |||
53 | unit: $(UNIT) | ||
54 | |||
55 | dist: clean depclean | ||
56 | mkdir libbu++-$(DATE) | ||
57 | cp -a --target-directory=libbu++-$(DATE) Makefile src | ||
58 | tar --exclude=\.svn -c libbu++-$(DATE) | bzip2 -9 > libbu++-$(DATE).tar.bz2 | ||
59 | rm -Rf libbu++-$(DATE) | ||
60 | |||
61 | install: libbu++.a | ||
62 | cat src/*.h | grep -v "#include \"" - > libbu++.h | ||
63 | cp -a libbu++.a $(PREFIX)/lib | ||
64 | cp -a libbu++.h $(PREFIX)/include | ||
65 | |||
66 | cleanapi: | ||
67 | -rm -Rf api | ||
68 | |||
69 | api: $(SRC) | ||
70 | -rm -Rf api | ||
71 | doxygen | ||
72 | make -C api/latex | ||
73 | |||
74 | #tests: $(TOBJS) $(LIB) | ||
75 | # for file in $(patsubst src/test/%.o,%,$(TOBJS)); \ | ||
76 | # do g++ -o $$file src/test/$$file.o -L. -lbu++; \ | ||
77 | # done | ||
78 | 2 | ||
3 | pymake: | ||
4 | pymake | ||