-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Makefile
61 lines (45 loc) · 1.45 KB
/
Makefile
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
#OPT ?= -O2 -DNDEBUG
# (B) Debug mode, w/ full line-level debugging symbols
OPT ?= -g2
# (C) Profiling mode: opt, but w/debugging symbols
# OPT ?= -O2 -g2 -DNDEBUG
$(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" ./build_config 1>&2)
include config.mk
CFLAGS += -I. $(PLATFORM_CCFLAGS) $(OPT)
CXXFLAGS += -I. $(PLATFORM_CXXFLAGS) $(OPT)
LDFLAGS += $(PLATFORM_LDFLAGS)
LIBS += $(PLATFORM_LIBS)
HANDY_SOURCES += $(shell find handy -name '*.cc')
HANDY_OBJECTS = $(HANDY_SOURCES:.cc=.o)
TEST_SOURCES = $(shell find test -name '*.cc')
TEST_OBJECTS = $(TEST_SOURCES:.cc=.o)
EXAMPLE_SOURCES += $(shell find examples -name '*.cc')
EXAMPLES = $(EXAMPLE_SOURCES:.cc=)
KW_SOURCES += $(shell find 10m -name '*.cc')
KW = $(KW_SOURCES:.cc=)
LIBRARY = libhandy.a
TARGETS = $(LIBRARY) handy_test $(EXAMPLES) $(KW)
default: $(TARGETS)
handy_examples: $(EXAMPLES)
$(EXAMPLES): $(LIBRARY)
$(KW): $(LIBRARY)
install: libhandy.a
mkdir -p $(PREFIX)/usr/local/include/handy
cp -f handy/*.h $(PREFIX)/usr/local/include/handy
cp -f libhandy.a $(PREFIX)/usr/local/lib
uninstall:
rm -rf $(PREFIX)/usr/local/include/handy $(PREFIX)/usr/local/lib/libhandy.a
clean:
-rm -f $(TARGETS)
-rm -f */*.o
$(LIBRARY): $(HANDY_OBJECTS)
rm -f $@
$(AR) -rs $@ $(HANDY_OBJECTS)
handy_test: $(TEST_OBJECTS) $(LIBRARY)
$(CXX) $^ -o $@ $(LDFLAGS) $(LIBS)
.cc.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
.cc:
$(CXX) -o $@ $< $(CXXFLAGS) $(LDFLAGS) $(LIBRARY) $(LIBS)