-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.env
49 lines (33 loc) · 896 Bytes
/
Makefile.env
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
CC=g++
MAKE=make
AR=ar cr
RM= -rm -rf
CXXFLAGS+= -g -Wall -std=c++11 -Wno-sign-compare
LDFLAGS+=
SHELL:=/bin/bash
dirs:=$(shell find . -maxdepth 2 -type f -name "Makefile")
dirs:=$(filter ./%/Makefile,$(dirs))
SUBDIRS:=$(dirs)
SRCS=$(wildcard *.cc)
OBJS=$(patsubst %.cc,obj/%.o,$(SRCS))
DEPENDS=$(patsubst %.cc,depend/%.d,$(SRCS))
%.build:
+@$(MAKE) -C $(dir $*) all
testall:
for testitem in $(ALLTESTBINS);do ./$$(testitem);done
for dir in $(SUBDIRS);\
do $(MAKE) -C $$(dir) testall;
done
$(DEPENDS):depend/%.d:%.cc
@test -d depend || mkdir depend;
set -e;rm -f $@;\
$(CC) -MM $(CXXFLAGS) $< > $@.$$$$;\
sed 's,\($*\)\.o[:]*,\1.o $@:,g' < $@.$$$$ > $@;\
rm $@.$$$$
-include $(DEPENDS)
$(OBJS):obj/%.o:%.cc
@test -d obj || mkdir obj
$(CC) -c $< -o $@ $(CXXFLAGS)
.DEFAULT_GOAL :=
all:$(addsuffix .build,$(dirs)) $(ALLBINS) $(ALLLIBS) $(ALLTESTBINS)
.PHONY:testall