-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.mk
47 lines (34 loc) · 864 Bytes
/
common.mk
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
ifndef PREFIX
PREFIX := /usr/local
endif
ifdef MINGW
bin_suffix := .exe
endif
ifndef CXX
CXX := g++
endif
ifndef LIBPNG_CONFIG
LIBPNG_CONFIG := libpng-config
endif
make_cflags := -Wall -I$(PNGPP) -I$(PREFIX)/include $(shell $(LIBPNG_CONFIG) --cflags) $(CFLAGS)
make_ldflags := -L$(PREFIX)/lib $(shell $(LIBPNG_CONFIG) --ldflags) $(LDFLAGS)
ifndef NDEBUG
make_cflags := $(make_cflags) -g
make_ldflags := $(make_ldflags) -g
endif
deps := $(sources:.cpp=.dep)
objects := $(sources:.cpp=.o)
bins := $(sources:.cpp=$(bin_suffix))
all: $(deps) $(bins)
%$(bin_suffix): %.o
$(CXX) -o $@ $< $(make_ldflags)
%.o: %.cpp
$(CXX) -c -o $@ $< $(make_cflags)
%.dep: %.cpp
$(CXX) -M $(CPPFLAGS) $(make_cflags) $< -o- | \
sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@
clean: clean-deps
rm -f $(bins) $(objects)
clean-deps:
rm -f $(deps)
.PHONY: all clean clean-deps