rules.mk

changeset 51
2d95d77aa954
parent 29
a2715cff4288
child 82
895f6304179d
equal deleted inserted replaced
50:855953c2f413 51:2d95d77aa954
1 ## 1 ##
2 ## Some make rules 2 ## Some make rules
3 ## 3 ##
4 4
5 ###################################### 5 ######################################
6
7 ifdef MODULE
8 ifneq ($(STATIC_MODULES),1)
9 TARGETS := $(TARGETS) $(MODULE).so
10 else
11 TARGETS := $(TARGETS) $(MODULE).a
12 endif
13 endif
14
6 15
7 ifdef SUBDIRS 16 ifdef SUBDIRS
8 17
9 all: subdirs $(TARGETS) 18 all: subdirs $(TARGETS)
10 19
11 clean: subdirs-clean _clean 20 clean: subdirs-clean _clean
12 21
13 realclean: subdirs-realclean _realclean 22 realclean: subdirs-realclean _clean _realclean
14 23
15 depend: subdirs-depend _depend 24 depend: subdirs-depend _depend
16 25
17 else 26 else
18 27
19 all: $(TARGETS) 28 all: $(TARGETS)
20 29
21 clean: _clean 30 clean: _clean
22 31
23 realclean: _realclean 32 realclean: _clean _realclean
24 33
25 depend: _depend 34 depend: _depend
26 35
27 endif 36 endif
28 37
36 45
37 endif 46 endif
38 47
39 ###################################### 48 ######################################
40 49
50 OBJS=$(subst .c,.o,$(SOURCES))
51
52 ifdef MAKE_EXPORTS
53
54 TO_CLEAN := $(TO_CLEAN) exports.c
55
56 OBJS := $(OBJS) exports.o
57
58 exports.c: $(SOURCES)
59 $(PERL) $(TOPDIR)/mkexports.pl $(MAKE_EXPORTS) exports.c $(SOURCES)
60
61 endif
62
63 ifdef MODULE
64
65 ifneq ($(STATIC_MODULES),1)
66
67 $(MODULE).so: $(OBJS) $(EXT_OBJS)
68 $(CC) $(CFLAGS) $(LDFLAGS) $(MODULE_LDFLAGS) $(OBJS) $(EXT_OBJS) -o $@
69
70 module_install:
71 $(INSTALLDIR) $(MODULEDIR)
72 $(INSTALL) -m $(BIN_MODE) $(MODULE).so $(MODULEDIR)
73 # $(STRIP) $(MODULEDIR)/$(MODULE).so
74
75 else
76
77 $(MODULE).a: $(OBJS)
78 $(AR) $(ARFLAGS) $@ $+
79 $(RANLIB) $@
80
81 module_install:
82
83 endif
84
85 .c.o:
86 $(CC) $(CFLAGS) $(MODULE_CFLAGS) -c $< -o $@
87
88 else
89
41 .c.o: 90 .c.o:
42 $(CC) $(CFLAGS) -c $< -o $@ 91 $(CC) $(CFLAGS) -c $< -o $@
43 92
44 ifdef OBJS 93 endif
45 94
46 _clean: 95 _clean:
47 rm -f core $(DEPEND_FILE) $(OBJS) 96 rm -f core $(DEPEND_FILE) $(OBJS) $(TO_CLEAN)
48 97
98 _realclean:
99 rm -f $(TARGETS) $(TO_REALCLEAN)
100
101
102 ifdef SOURCES
49 _depend: 103 _depend:
50 $(MAKE_DEPEND) *.c 104 $(MAKE_DEPEND) $(SOURCES)
51
52 else 105 else
53
54 _clean:
55
56 _depend: 106 _depend:
57 107
58 endif 108 endif
59
60 _realclean: _clean
61 rm -f $(TARGETS)
62
63 109
64 ###################################### 110 ######################################
65 111
66 subdirs: 112 subdirs:
67 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done 113 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done

mercurial