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