6 DEFINES += -DCF_RELOCATABLE
10 ifeq ($(PRELOAD_MODULES),1)
11 MODULE_TARGETS := $(MODULE).a $(MODULE).lc
13 MODULE_TARGETS := $(MODULE).so $(MODULE).lc
15 TARGETS := $(TARGETS) $(MODULE_TARGETS)
19 LUA_COMPILED := $(subst .lua,.lc, $(LUA_SOURCES))
20 TARGETS := $(TARGETS) $(LUA_COMPILED)
25 ######################################
29 .PHONY: subdirs-realclean
30 .PHONY: subdirs-depend
31 .PHONY: subdirs-install
36 all: subdirs _exports $(TARGETS)
38 clean: subdirs-clean _clean
40 realclean: subdirs-realclean _clean _realclean
42 depend: subdirs-depend _depend
44 install: subdirs-install _install
50 ######################################
55 DEPEND_DEPENDS += $(EXPORTS_H)
57 TO_CLEAN := $(TO_CLEAN) $(EXPORTS_C) $(EXPORTS_H)
59 _exports: $(EXPORTS_C)
61 $(EXPORTS_H): $(EXPORTS_C)
63 $(EXPORTS_C): $(SOURCES) $(MKEXPORTS_EXTRA_DEPS)
64 $(MKEXPORTS) -module $(MAKE_EXPORTS) -o $(EXPORTS_C) -h $(EXPORTS_H) \
65 $(SOURCES) $(MKEXPORTS_EXTRAS)
67 # Exports documentation
68 ######################################
70 EXPORTS_DOC = exports.tex
72 TO_CLEAN := $(TO_CLEAN) $(EXPORTS_DOC)
74 _exports_doc: $(EXPORTS_DOC)
76 $(EXPORTS_DOC): $(SOURCES) $(LUA_SOURCES) $(MKEXPORTS_EXTRA_DEPS)
77 $(MKEXPORTS) -mkdoc -module $(MAKE_EXPORTS) -o $(EXPORTS_DOC) \
78 $(SOURCES) $(LUA_SOURCES) $(MKEXPORTS_EXTRAS)
89 # Compilation and linking
90 ######################################
92 OBJS=$(subst .c,.o,$(SOURCES) $(EXPORTS_C))
96 ifneq ($(PRELOAD_MODULES),1)
98 CC_PICFLAGS=-fPIC -DPIC
99 LD_SHAREDFLAGS=-shared
102 $(CC) $(CC_PICFLAGS) $(CFLAGS) -c $< -o $@
104 $(MODULE).so: $(OBJS) $(EXT_OBJS)
105 $(CC) $(LD_SHAREDFLAGS) $(LDFLAGS) $(OBJS) $(EXT_OBJS) -o $@
108 module_install: module_stub_install
109 $(INSTALLDIR) $(MODULEDIR)
110 $(INSTALL) -m $(BIN_MODE) $(MODULE).so $(MODULEDIR)
112 else # PRELOAD_MODULES
118 $(CC) $(CFLAGS) -c $< -o $@
120 $(MODULE).a: $(OBJS) $(EXT_OBJS)
121 $(AR) $(ARFLAGS) $@ $+
124 module_install: module_stub_install
126 endif # PRELOAD_MODULES
129 $(INSTALLDIR) $(LCDIR)
130 $(INSTALL) -m $(DATA_MODE) $(MODULE).lc $(LCDIR)
135 echo "ioncore.load_module('$(MODULE)')" | $(LUAC) -o $@ -
138 LUA_SOURCES += $(MODULE_STUB)
146 $(CC) $(CFLAGS) -c $< -o $@
153 ######################################
156 $(RM) -f $(TO_CLEAN) core $(DEPEND_FILE) $(OBJS)
159 $(RM) -f $(TO_REALCLEAN) $(TARGETS)
162 ######################################
168 $(INSTALLDIR) $(LCDIR)
169 for i in $(LUA_COMPILED); do \
170 $(INSTALL) -m $(DATA_MODE) $$i $(LCDIR); \
174 $(INSTALLDIR) $(ETCDIR)
175 for i in $(ETC); do \
176 $(INSTALL) -m $(DATA_MODE) $$i $(ETCDIR); \
180 ######################################
184 _depend: $(DEPEND_DEPENDS)
187 ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE)))
188 include $(DEPEND_FILE)
194 ######################################
199 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
202 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i depend; done
205 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
208 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
211 set -e; for i in $(INSTALL_SUBDIRS); do $(MAKE) -C $$i install; done
216 ######################################
218 TO_CLEAN += potfiles_c potfiles_lua
221 echo "$(SOURCES)"|tr ' ' '\n' > potfiles_c
222 echo "$(LUA_SOURCES) $(ETC)"|tr ' ' '\n' > potfiles_lua