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
)
19 ifdef EXTRA_EXECUTABLE
20 EXECUTABLE
:= $(EXTRA_EXECUTABLE
)
21 BINDIR_
:= $(EXTRABINDIR
)
26 EXECUTABLE_
:= $(EXECUTABLE
)$(BIN_SUFFIX
)
27 TARGETS
:= $(TARGETS
) $(EXECUTABLE_
)
32 ######################################
36 .PHONY
: subdirs-realclean
37 .PHONY
: subdirs-depend
38 .PHONY
: subdirs-install
43 all: subdirs _exports
$(TARGETS
)
45 clean: subdirs-clean _clean
47 realclean: subdirs-realclean _clean _realclean
49 depend
: subdirs-depend _depend
51 install: subdirs-install _install
57 ######################################
62 DEPEND_DEPENDS
+= $(EXPORTS_H
)
64 TO_CLEAN
:= $(TO_CLEAN
) $(EXPORTS_C
) $(EXPORTS_H
)
66 _exports
: $(EXPORTS_C
)
68 $(EXPORTS_H
): $(EXPORTS_C
)
70 $(EXPORTS_C
): $(SOURCES
) $(MKEXPORTS_EXTRA_DEPS
)
71 $(MKEXPORTS
) -module
$(MAKE_EXPORTS
) -o
$(EXPORTS_C
) -h
$(EXPORTS_H
) \
72 $(SOURCES
) $(MKEXPORTS_EXTRAS
)
74 # Exports documentation
75 ######################################
77 EXPORTS_DOC
= exports.
tex
79 TO_CLEAN
:= $(TO_CLEAN
) $(EXPORTS_DOC
)
81 _exports_doc
: $(EXPORTS_DOC
)
83 $(EXPORTS_DOC
): $(SOURCES
) $(LUA_SOURCES
) $(MKEXPORTS_EXTRA_DEPS
)
84 $(MKEXPORTS
) -mkdoc
-module
$(MAKE_EXPORTS
) -o
$(EXPORTS_DOC
) \
85 $(SOURCES
) $(LUA_SOURCES
) $(MKEXPORTS_EXTRAS
)
96 # Compilation and linking
97 ######################################
99 OBJS
=$(subst .c
,.o
,$(SOURCES
) $(EXPORTS_C
))
106 ifeq ($(PRELOAD_MODULES
),1)
107 EXT_OBJS
+= $(foreach mod
, $(MODULE_LIST
), $(MODULE_PATH
)/$(mod
)/$(mod
).a
)
108 DEPEND_DEPENDS
+= preload.c
110 TO_CLEAN
+= preload.c
111 else # !PRELOAD_MODULES
112 LDFLAGS
+= $(EXPORT_DYNAMIC
)
113 WHOLEA
= -Wl
,-whole-archive
114 NO_WHOLEA
= -Wl
,-no-whole-archive
115 endif # !PRELOAD_MODULES
118 $(LUA
) $(TOPDIR
)/build
/mkpreload.lua
$(MODULE_LIST
) > preload.c
123 ifeq ($(RELOCATABLE
),1)
124 DEFINES
+= -DCF_RELOCATABLE_BIN_LOCATION
=\"$(BINDIR_
)/$(EXECUTABLE
)\"
127 DEFINES
+= -DCF_EXECUTABLE
=\"$(EXECUTABLE
)\"
129 $(EXECUTABLE_
): $(OBJS
) $(EXT_OBJS
)
130 $(CC
) $(OBJS
) $(WHOLEA
) $(EXT_OBJS
) $(NO_WHOLEA
) $(LDFLAGS
) -o
$@
133 $(INSTALLDIR
) $(DESTDIR
)$(BINDIR_
)
134 $(INSTALLBIN
) $(EXECUTABLE_
) $(DESTDIR
)$(BINDIR_
)
141 ifneq ($(PRELOAD_MODULES
),1)
143 CC_PICFLAGS
=-fPIC
-DPIC
144 LD_SHAREDFLAGS
=-shared
146 %.o
: %.c
$(EXPORTS_H
)
147 $(CC
) $(CC_PICFLAGS
) $(CFLAGS
) -c
$< -o
$@
149 # notion might not link to Xext, so modules will have to link to it themselves
153 $(MODULE
).so
: $(OBJS
) $(EXT_OBJS
)
154 $(CC
) $(LD_SHAREDFLAGS
) $(LDFLAGS
) $(OBJS
) $(EXT_OBJS
) $(LIBS
) -o
$@
157 module_install
: module_stub_install
158 $(INSTALLDIR
) $(DESTDIR
)$(MODULEDIR
)
159 $(INSTALLBIN
) $(MODULE
).so
$(DESTDIR
)$(MODULEDIR
)
161 else # PRELOAD_MODULES
166 %.o
: %.c
$(EXPORTS_H
)
167 $(CC
) $(CFLAGS
) -c
$< -o
$@
169 $(MODULE
).a
: $(OBJS
) $(EXT_OBJS
)
170 $(AR
) $(ARFLAGS
) $@
$+
173 module_install
: module_stub_install
175 endif # PRELOAD_MODULES
178 $(INSTALLDIR
) $(DESTDIR
)$(LCDIR
)
179 $(INSTALL
) -m
$(DATA_MODE
) $(MODULE
).lc
$(DESTDIR
)$(LCDIR
)
184 echo
"ioncore.load_module('$(MODULE)')" |
$(LUAC
) -o
$@
-
187 LUA_SOURCES
+= $(MODULE_STUB
)
194 %.o
: %.c
$(EXPORTS_H
)
195 $(CC
) $(CFLAGS
) -c
$< -o
$@
202 ######################################
205 $(RM
) -f
$(TO_CLEAN
) core
$(DEPEND_FILE
) $(OBJS
)
208 $(RM
) -f
$(TO_REALCLEAN
) $(TARGETS
)
211 ######################################
217 $(INSTALLDIR
) $(DESTDIR
)$(LCDIR
)
218 for i in
$(LUA_COMPILED
); do \
219 $(INSTALL
) -m
$(DATA_MODE
) $$i $(DESTDIR
)$(LCDIR
); \
223 $(INSTALLDIR
) $(DESTDIR
)$(ETCDIR
)
224 for i in
$(ETC
); do \
225 $(INSTALL
) -m
$(DATA_MODE
) $$i $(DESTDIR
)$(ETCDIR
); \
229 ######################################
233 _depend
: $(DEPEND_DEPENDS
)
236 ifeq ($(DEPEND_FILE
),$(wildcard $(DEPEND_FILE
)))
237 include $(DEPEND_FILE
)
243 ######################################
248 set
-e
; for i in
$(SUBDIRS
); do
$(MAKE
) -C
$$i; done
251 set
-e
; for i in
$(SUBDIRS
); do
$(MAKE
) -C
$$i depend
; done
254 set
-e
; for i in
$(SUBDIRS
); do
$(MAKE
) -C
$$i clean; done
257 set
-e
; for i in
$(SUBDIRS
); do
$(MAKE
) -C
$$i realclean; done
260 set
-e
; for i in
$(INSTALL_SUBDIRS
); do
$(MAKE
) -C
$$i install; done
265 ######################################
267 TO_CLEAN
+= potfiles_c potfiles_lua
270 echo
"$(SOURCES)"|tr
' ' '\n' > potfiles_c
271 echo
"$(LUA_SOURCES) $(ETC)"|tr
' ' '\n' > potfiles_lua
274 ######################################
277 INSTALLBIN ?
= $(INSTALL
) $(INSTALL_STRIP
) -m
$(BIN_MODE
)