forked from isayme/xdns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
81 lines (62 loc) · 1.99 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#-----------------------------------------------------------
# general use makefile file.
# for unix like OS, special for c language.
#-----------------------------------------------------------
#-----------------------------------------------------------
# to use this makefile, generally change variables below
#-----------------------------------------------------------
# binarys to be created
BINS := test xdns
# libs to be created
LIBS := liblog.so libthread.so libbm.so \
liblist.so libudp.so libdaemon.so libthreadpool.so \
libconfig.so libmm.so
#-----------------------------------------------------------
# compiler tool
CC := gcc
# compile option to the executables
CFLAGS := -g -Wall -O3 -DLINUX -Iinc
CXXFLAGS := $(CFLAGS)
#compile option to .so
SOFLAGS := -g -DLINUX -shared -fPIC -Iinc
LDFLAGS := -Wl,-rpath,bin,-rpath, \
-Lbin \
-lpthread -llog -lthread -ldaemon -lbm \
-llist -ludp -lthreadpool -lconfig -lmm
# vpath indicate the searching path of the according file type
SRCDIR := src $(shell ls -d src/*)
vpath %.c $(SRCDIR)
vpath %.h inc
vpath %.so bin
vpath % bin
vpath %.cpp $(SRCDIR)
.PHONY: all libs bins install uninstall
all : libs bins
libs : $(LIBS)
bins : $(BINS)
clean :
cd bin;\
rm -f $(LIBS);\
rm -f $(BINS);\
cd ..;
# common rules goes here, if the compiling procedure of your module matches one,
# no need to list it in SpecialRules
%.so : %.c
$(CC) $^ $(SOFLAGS) -o $@
mv $@ bin/
% : %.c
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
mv $@ bin/
#-----------------------------------------------------------
# for special libs/bins, add some lines like below
#-----------------------------------------------------------
#libso_example.so: so_example.c so_prerequisite1.c so_prerequisite2.c
# $(CC) $(SOFLAGS) -o $@ $^
# mv $@ bin/
#bin_example : bin_example.c bin_prerequisite1.c bin_prerequisite2.c
# $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
# mv $@ bin/
#-----------------------------------------------------------
xdns : xdns.c
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
mv $@ bin/