Mon, 07 May 2012 15:25:18 +0200
-DCF_NO_GETTEXT option to system.mk
6 | 1 | ## |
2 | ## Some make rules | |
3 | ## | |
4 | ||
82 | 5 | ifdef MODULE |
6 | ifeq ($(PRELOAD_MODULES),1) | |
7 | MODULE_TARGETS := $(MODULE).a $(MODULE).lc | |
8 | else | |
9 | MODULE_TARGETS := $(MODULE).so $(MODULE).lc | |
10 | endif | |
11 | TARGETS := $(TARGETS) $(MODULE_TARGETS) | |
12 | endif | |
6 | 13 | |
82 | 14 | ifdef LUA_SOURCES |
15 | LUA_COMPILED := $(subst .lua,.lc, $(LUA_SOURCES)) | |
16 | TARGETS := $(TARGETS) $(LUA_COMPILED) | |
51 | 17 | endif |
18 | ||
19 | ||
82 | 20 | # Main targets |
21 | ###################################### | |
22 | ||
23 | .PHONY: subdirs | |
24 | .PHONY: subdirs-clean | |
25 | .PHONY: subdirs-realclean | |
26 | .PHONY: subdirs-depend | |
27 | .PHONY: subdirs-install | |
28 | .PHONY: _install | |
29 | .PHONY: _depend | |
6 | 30 | |
31 | all: subdirs $(TARGETS) | |
32 | ||
33 | clean: subdirs-clean _clean | |
34 | ||
51 | 35 | realclean: subdirs-realclean _clean _realclean |
6 | 36 | |
37 | depend: subdirs-depend _depend | |
38 | ||
39 | install: subdirs-install _install | |
40 | ||
41 | ||
82 | 42 | # Exports |
6 | 43 | ###################################### |
44 | ||
51 | 45 | ifdef MAKE_EXPORTS |
46 | ||
47 | TO_CLEAN := $(TO_CLEAN) exports.c | |
48 | ||
82 | 49 | EXPORTS_C = exports.c |
51 | 50 | |
51 | exports.c: $(SOURCES) | |
82 | 52 | $(MKEXPORTS) -module $(MAKE_EXPORTS) -o exports.c $(SOURCES) |
53 | ||
54 | else # !MAKE_EXPORTS | |
55 | ||
56 | EXPORTS_C = | |
51 | 57 | |
82 | 58 | endif # !MAKE_EXPORTS |
59 | ||
60 | ||
61 | # Compilation and linking | |
62 | ###################################### | |
63 | ||
64 | OBJS=$(subst .c,.o,$(SOURCES) $(EXPORTS_C)) | |
51 | 65 | |
66 | ifdef MODULE | |
67 | ||
82 | 68 | ifneq ($(PRELOAD_MODULES),1) |
69 | ||
70 | CC_PICFLAGS=-fPIC -DPIC | |
71 | LD_SHAREDFLAGS=-shared | |
72 | ||
73 | %.o: %.c | |
74 | $(CC) $(CC_PICFLAGS) $(CFLAGS) -c $< -o $@ | |
51 | 75 | |
76 | $(MODULE).so: $(OBJS) $(EXT_OBJS) | |
82 | 77 | $(CC) $(LD_SHAREDFLAGS) $(LDFLAGS) $(OBJS) $(EXT_OBJS) -o $@ |
51 | 78 | |
82 | 79 | |
80 | module_install: module_stub_install | |
51 | 81 | $(INSTALLDIR) $(MODULEDIR) |
82 | $(INSTALL) -m $(BIN_MODE) $(MODULE).so $(MODULEDIR) | |
82 | 83 | |
84 | else # PRELOAD_MODULES | |
51 | 85 | |
82 | 86 | PICOPT=-fPIC -DPIC |
87 | LINKOPT=-shared | |
51 | 88 | |
82 | 89 | %.o: %.c |
90 | $(CC) $(CFLAGS) -c $< -o $@ | |
91 | ||
92 | $(MODULE).a: $(OBJS) $(EXT_OBJS) | |
51 | 93 | $(AR) $(ARFLAGS) $@ $+ |
94 | $(RANLIB) $@ | |
95 | ||
82 | 96 | module_install: module_stub_install |
51 | 97 | |
82 | 98 | endif # PRELOAD_MODULES |
51 | 99 | |
82 | 100 | module_stub_install: |
101 | $(INSTALLDIR) $(LCDIR) | |
102 | $(INSTALL) -m $(DATA_MODE) $(MODULE).lc $(LCDIR) | |
51 | 103 | |
82 | 104 | ifndef MODULE_STUB |
105 | ||
106 | $(MODULE).lc: | |
107 | echo "ioncore.load_module('$(MODULE)')" | $(LUAC) -o $@ - | |
51 | 108 | else |
109 | ||
82 | 110 | LUA_SOURCES += $(MODULE_STUB) |
111 | ||
112 | endif #MODULE_STUB | |
113 | ||
114 | else # !MODULE | |
115 | ||
116 | ||
117 | %.o: %.c | |
9 | 118 | $(CC) $(CFLAGS) -c $< -o $@ |
6 | 119 | |
82 | 120 | |
121 | endif# !MODULE | |
122 | ||
123 | ||
124 | # Clean rules | |
125 | ###################################### | |
126 | ||
127 | _clean: | |
128 | $(RM) -f $(TO_CLEAN) core $(DEPEND_FILE) $(OBJS) | |
129 | ||
130 | _realclean: | |
131 | $(RM) -f $(TO_REALCLEAN) $(TARGETS) | |
132 | ||
133 | # Lua rules | |
134 | ###################################### | |
135 | ||
136 | %.lc: %.lua | |
137 | $(LUAC) -o $@ $< | |
138 | ||
139 | lc_install: | |
140 | $(INSTALLDIR) $(LCDIR) | |
141 | for i in $(LUA_COMPILED); do \ | |
142 | $(INSTALL) -m $(DATA_MODE) $$i $(LCDIR); \ | |
143 | done | |
144 | ||
145 | etc_install: | |
146 | $(INSTALLDIR) $(ETCDIR) | |
147 | for i in $(ETC); do \ | |
148 | $(INSTALL) -m $(DATA_MODE) $$i $(ETCDIR); \ | |
149 | done | |
150 | ||
151 | # Dependencies | |
152 | ###################################### | |
153 | ||
154 | ifdef SOURCES | |
155 | ||
156 | _depend: $(DEPEND_DEPENDS) | |
157 | $(MAKE_DEPEND) | |
158 | ||
159 | ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE))) | |
160 | include $(DEPEND_FILE) | |
161 | endif | |
162 | ||
51 | 163 | endif |
6 | 164 | |
82 | 165 | # Subdirectories |
166 | ###################################### | |
51 | 167 | |
82 | 168 | ifdef SUBDIRS |
6 | 169 | |
170 | subdirs: | |
9 | 171 | set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done |
6 | 172 | |
173 | subdirs-depend: | |
9 | 174 | set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i depend; done |
6 | 175 | |
176 | subdirs-clean: | |
9 | 177 | set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done |
6 | 178 | |
179 | subdirs-realclean: | |
9 | 180 | set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done |
6 | 181 | |
182 | subdirs-install: | |
9 | 183 | set -e; for i in $(INSTALL_SUBDIRS); do $(MAKE) -C $$i install; done |
6 | 184 | |
82 | 185 | endif |
186 | ||
187 | # Localisation | |
6 | 188 | ###################################### |
189 | ||
82 | 190 | TO_CLEAN += potfiles_c potfiles_lua |
191 | ||
192 | _potfiles: | |
193 | echo "$(SOURCES)"|tr ' ' '\n' > potfiles_c | |
194 | echo "$(LUA_SOURCES) $(ETC)"|tr ' ' '\n' > potfiles_lua |