6 ifeq ($(PRELOAD_MODULES),1)
7 MODULE_TARGETS := $(MODULE).a $(MODULE).lc
9 MODULE_TARGETS := $(MODULE).so $(MODULE).lc
11 TARGETS := $(TARGETS) $(MODULE_TARGETS)
15 LUA_COMPILED := $(subst .lua,.lc, $(LUA_SOURCES))
16 TARGETS := $(TARGETS) $(LUA_COMPILED)
21 ######################################
25 .PHONY: subdirs-realclean
26 .PHONY: subdirs-depend
27 .PHONY: subdirs-install
32 all: subdirs _exports $(TARGETS)
34 clean: subdirs-clean _clean
36 realclean: subdirs-realclean _clean _realclean
38 depend: subdirs-depend _depend
40 install: subdirs-install _install
46 ######################################
51 DEPEND_DEPENDS += $(EXPORTS_H)
53 TO_CLEAN := $(TO_CLEAN) $(EXPORTS_C) $(EXPORTS_H)
55 _exports: $(EXPORTS_C)
57 $(EXPORTS_H): $(EXPORTS_C)
59 $(EXPORTS_C): $(SOURCES) $(MKEXPORTS_EXTRA_DEPS)
60 $(MKEXPORTS) -module $(MAKE_EXPORTS) -o $(EXPORTS_C) -h $(EXPORTS_H) \
61 $(SOURCES) $(MKEXPORTS_EXTRAS)
63 # Exports documentation
64 ######################################
66 EXPORTS_DOC = exports.tex
68 TO_CLEAN := $(TO_CLEAN) $(EXPORTS_DOC)
70 _exports_doc: $(EXPORTS_DOC)
72 $(EXPORTS_DOC): $(SOURCES) $(LUA_SOURCES) $(MKEXPORTS_EXTRA_DEPS)
73 $(MKEXPORTS) -mkdoc -module $(MAKE_EXPORTS) -o $(EXPORTS_DOC) \
74 $(SOURCES) $(LUA_SOURCES) $(MKEXPORTS_EXTRAS)
85 # Compilation and linking
86 ######################################
88 OBJS=$(subst .c,.o,$(SOURCES) $(EXPORTS_C))
92 ifneq ($(PRELOAD_MODULES),1)
94 CC_PICFLAGS=-fPIC -DPIC
95 LD_SHAREDFLAGS=-shared
98 $(CC) $(CC_PICFLAGS) $(CFLAGS) -c $< -o $@
100 $(MODULE).so: $(OBJS) $(EXT_OBJS)
101 $(CC) $(LD_SHAREDFLAGS) $(LDFLAGS) $(OBJS) $(EXT_OBJS) -o $@
104 module_install: module_stub_install
105 $(INSTALLDIR) $(MODULEDIR)
106 $(INSTALLBIN) $(MODULE).so $(MODULEDIR)
108 else # PRELOAD_MODULES
114 $(CC) $(CFLAGS) -c $< -o $@
116 $(MODULE).a: $(OBJS) $(EXT_OBJS)
117 $(AR) $(ARFLAGS) $@ $+
120 module_install: module_stub_install
122 endif # PRELOAD_MODULES
125 $(INSTALLDIR) $(LCDIR)
126 $(INSTALL) -m $(DATA_MODE) $(MODULE).lc $(LCDIR)
131 echo "ioncore.load_module('$(MODULE)')" | $(LUAC) -o $@ -
134 LUA_SOURCES += $(MODULE_STUB)
142 $(CC) $(CFLAGS) -c $< -o $@
149 ######################################
152 $(RM) -f $(TO_CLEAN) core $(DEPEND_FILE) $(OBJS)
155 $(RM) -f $(TO_REALCLEAN) $(TARGETS)
158 ######################################
164 $(INSTALLDIR) $(LCDIR)
165 for i in $(LUA_COMPILED); do \
166 $(INSTALL) -m $(DATA_MODE) $$i $(LCDIR); \
170 $(INSTALLDIR) $(ETCDIR)
171 for i in $(ETC); do \
172 $(INSTALL) -m $(DATA_MODE) $$i $(ETCDIR); \
176 ######################################
180 _depend: $(DEPEND_DEPENDS)
183 ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE)))
184 include $(DEPEND_FILE)
190 ######################################
195 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
198 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i depend; done
201 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
204 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
207 set -e; for i in $(INSTALL_SUBDIRS); do $(MAKE) -C $$i install; done
212 ######################################
214 TO_CLEAN += potfiles_c potfiles_lua
217 echo "$(SOURCES)"|tr ' ' '\n' > potfiles_c
218 echo "$(LUA_SOURCES) $(ETC)"|tr ' ' '\n' > potfiles_lua
221 ######################################
224 INSTALLBIN ?= $(INSTALL) $(INSTALL_STRIP) -m $(BIN_MODE)