2
# Common Makefile rules to build a library module. Following variables need
3
# to be set before including this file:
6
# Name of the module. Source is in src/$(MODULE), and the build directory
7
# (with configure-generated config files) is in build/$(ARCH)/$(MODULE).
10
# (optional) list of module specific source files in addition to init.c and the
11
# files generated from the headers (types, functions etc.)
15
$(error You have to define $$MODULE)
18
all: module_$(MODULE) dummy
23
# Read state file if exists. Don't use :=, because then the new state (if
24
# changed) wouldn't be used in the submake invocation. May be overridden on
26
FILE := $(wildcard build/make.state)
31
ifeq ($(wildcard build/$(ARCH)/$(MODULE)/config.make), )
32
$(error Library $(ARCH)/$(MODULE) not yet configured)
35
# $(warning Building $(ARCH) $(MODULE)...)
37
# include the config file
38
include build/$(ARCH)/$(MODULE)/config.make
41
$(warning The module $(MODULE) is not buildable.)
2
46
# -- general configuration --
52
DYNLINK_PREFIX :=$(MODULE)
53
BINDIR =build/$(ARCH)/
54
DEVMOD :=build/$(ARCH)/gnomedev.so
7
55
# -- end general configuration --
57
# -- non-core-module settings --
58
ifeq ($(COREMODULE), )
59
SRC :=init generated module $(SRC)
60
OFILES =$(SRC) types globals fundamentals
63
# $(error Build the gnome module first)
69
# Run make with "H=" as an argument to show all build commands; otherwise
70
# just show each build target.
78
# how to recursively call make (if required)
79
submake = $(MAKE) -r --no-print-directory
82
module_$(MODULE): $(ODIR)$(MODULE)$(DLLEXT)
86
$H rm -f $(addprefix $(ODIR),$(addsuffix .$O,$(OFILES)) $(CLEAN)) \
87
$(ODIR)$(MODULE)$(DLLEXT) \
88
$(ODIR)constants* $(ODIR)functions* $(ODIR)link.[ch] \
89
$(ODIR)types.* $(ODIR)fundamentals.* \
90
$(ODIR)types.xml $(ODIR)globals.c $(ODIR)generated.c \
94
$H rm -f $(ODIR)config.{h,lua,make}
96
size: $(addprefix $(ODIR), $(addsuffix .$O,$(OFILES)))
97
$H size -t $(addprefix $(ODIR), $(addsuffix .$O,$(OFILES)))
98
$H size $(ODIR)$(MODULE)$(DLLEXT)
9
103
.PHONY: tags wc tar install mrproper clean tests config_h doc size
10
.PRECIOUS: ${ODIR}gtkdata.%.txt ${ODIR}gtkdata.%.c ${ODIR}%.keys ${ODIR}%.mph
12
OFILES :=types.$(O) gtk2.$(O) data.$(O) enum.$O voidptr.$O \
13
call.$(O) callback.$(O) channel.$(O) gvalue.$(O) override.$(O) \
14
debug.$(O) widget.$(O) widget_types.$(O) widget_meta.$(O) \
15
gtkdata.structs.$(O) _override.$(O)
16
LH :=src/luagtk.h ${ODIR}config.h
18
# -- runtime linking? --
104
.PRECIOUS: $(ODIR)%.txt $(ODIR)%.c
106
# headers for dependencies
107
DEP :=include/common.h include/module.h $(ODIR)config.h
19
109
ifeq ($(DYNLINK), 0)
26
# -- is cmph available? --
27
ifeq ($(HAVE_CMPH), 1)
28
OFILES +=hash-functions.$O hash-cmph.$O hash-$(CMPH_ALGO).$O \
29
_funclist_$(CMPH_ALGO).$O _enumlist_$(CMPH_ALGO).$O
31
OFILES +=hash-simple.$(O) ${HASH}.$(O) _funclist.$(O) _enumlist.$(O)
34
# -- is libgtkhtml available? --
35
ifeq ($(HAVE_HTML), 1)
36
MAKE_XML_FLAGS +=--enable-gtkhtml
39
gtk2dll: build-tests ${ODIR}${ODLL}
42
$H script/configure $(ARCH)
45
# test that calling works properly. For Win32, requires wine to be installed.
46
build-tests: ${ODIR}test-vararg-ok
48
${ODIR}test-%-ok: ${ODIR}test-%${EXESUFFIX}
49
$H $(CROSS_RUN) $^ && touch $@
51
${ODIR}test-vararg${EXESUFFIX}: src/test-vararg.c
53
$H $(CC) $(CFLAGS) -I $(ODIR) -Wall -o $@ $^
55
# rule to build the library.
57
${ODIR}${ODLL}: $(addprefix ${ODIR}, ${OFILES})
59
$H $(CC) ${LDFLAGS} -shared -o $@ $^ ${LIBFFI_LIB} ${EXTRA_LIB} ${LIBS}
61
${ODIR}debug.$(O): src/debug.c
63
$H ${CC} ${CFLAGS} -I lua-5.1/src -c -o $@ $<
65
${ODIR}_funclist.c: ${ODIR}gtkdata.funcs.txt ${ODIR}generate src/luagtk_hash.h
67
$H ${ODIR}generate -s 4096 -o $@ -n hash_info_funcs -d -f $<
69
${ODIR}_enumlist.c: ${ODIR}gtkdata.enums.txt ${ODIR}generate src/luagtk_hash.h
71
$H ${ODIR}generate -s 4096 -o $@ -n hash_info_enums -d -f $<
73
${ODIR}_override.c: ${ODIR}override.luac ${ODIR}file2c
75
$H ${ODIR}file2c override < $< > $@
77
${ODIR}gtkdata.%.txt ${ODIR}gtkdata.%.c ${ODIR}gtkdata.%.h: ${ODIR}types.xml \
78
script/parse-xml.lua src/fundamental.lua \
79
src/char_ptr_handling.txt script/xml-types.lua script/xml-parser.lua \
80
script/xml-output.lua script/common.lua src/include_types.txt
81
@echo "Generating Gtk Data..."
82
$H script/parse-xml.lua "${ODIR}" "$<" "$(ARCH)"
116
# configure hash files depending on the setting in build/make.state.
117
ifeq ($(COREMODULE), )
118
OFILES +=functions constants
120
ifeq ($(HAVE_CMPH), 1)
121
OFILES +=hash-functions hash-cmph hash-$(HASH_METHOD)
123
OFILES +=hash-simple # hash-$(HASH_METHOD) $(HASH)
128
$(ODIR)$(MODULE)$(DLLEXT): $(addprefix $(ODIR),$(addsuffix .$O,$(OFILES)))
130
$H $(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
84
132
# if config.h changes, chances are that make-xml must be run again.
85
${ODIR}types.xml: script/make-xml.lua $(ODIR)config.h
87
$H script/make-xml.lua $(MAKE_XML_FLAGS) "$@" $(ARCH)
89
${ODIR}%.$(O): ${ODIR}%.c
133
${ODIR}types.xml: script/make-xml.lua $(ODIR)config.h $(ODIR)config.lua $(IDIR)/spec.lua
135
$H script/make-xml.lua "$(ODIR)"
137
# changed spec.lua - must reconfigure. This may or may not change config.lua,
138
# but to avoid configures every time, the timestamp is updated.
139
$(ODIR)config.lua: $(IDIR)/spec.lua
141
$H script/configure.lua $(CONFIG_ARGS) $(MODULE)
144
$(ODIR)%.$O: $(ODIR)%.c
91
146
$H ${CC} ${CFLAGS} -c -o $@ $<
95
${ODIR}luagtk_ffi.h: ${ODIR}ffi-types
97
$H ${ODIR}ffi-types > $@
99
${ODIR}ffi-types.$(O): src/ffi-types.c
101
$H ${HOSTCC} ${CFLAGS} -o $@ -c $<
103
${ODIR}ffi-types: ${ODIR}ffi-types.$(O)
105
$H ${HOSTCC} -o $@ $< -lffi
109
${ODIR}%.keys: ${ODIR}%.txt
111
$H sed 's/,.*$$//' < $^ > $@
113
# -c gives the effort expended to finding a minimal hash function. lower
114
# value = more effort. 2.0 is about the minimum.
115
${ODIR}%.$(CMPH_ALGO).mph: ${ODIR}%.keys
117
$H $(CMPH_BIN) -a $(CMPH_ALGO) -m $@ -g $^
119
${ODIR}_funclist_$(CMPH_ALGO).c: ${ODIR}hash-cmph-generate \
120
${ODIR}gtkdata.funcs.$(CMPH_ALGO).mph
122
$H ${ODIR}hash-cmph-generate ${ODIR}gtkdata.funcs.$(CMPH_ALGO).mph \
123
${ODIR}gtkdata.funcs.txt "funcs" > $@
125
${ODIR}_enumlist_$(CMPH_ALGO).c: ${ODIR}hash-cmph-generate \
126
${ODIR}gtkdata.enums.$(CMPH_ALGO).mph
128
$H ${ODIR}hash-cmph-generate ${ODIR}gtkdata.enums.$(CMPH_ALGO).mph \
129
${ODIR}gtkdata.enums.txt "enums" > $@
131
${ODIR}hash-fch.$(O): src/hash-fch.c
133
$H ${CC} ${CFLAGS} -c -o $@ ${CMPH_CFLAGS} $<
135
${ODIR}hash-bdz.$(O): src/hash-bdz.c
137
$H ${CC} ${CFLAGS} -c -o $@ ${CMPH_CFLAGS} $<
139
# -- helper programs for simple and cmph hash, to be compiled with HOSTCC --
141
${ODIR}generate.$(O): src/generate.c
143
$H ${HOSTCC} ${CFLAGS} -c -o $@ $<
145
${ODIR}generate: ${ODIR}generate.$(O) ${ODIR}${HASH}-native.$(O)
147
$H ${HOSTCC} -o $@ $^
149
${ODIR}file2c: src/file2c.c
151
$H ${HOSTCC} -o $@ $^
153
${ODIR}hash-cmph-generate: ${ODIR}hash-cmph-generate.$(O)
155
$H ${HOSTCC} -g -o $@ $^ $(CMPH_LIBS)
157
${ODIR}hash-cmph-generate.$O: src/hash-cmph-generate.c
159
$H ${HOSTCC} -g -o $@ ${CMPH_CFLAGS} -I ${ODIR} -c $<
148
$(ODIR)%.$O: $(IDIR)/%.c $(DEP)
150
$H $(CC) $(CFLAGS) -c -o $@ $<
152
# module.c is code required by modules to hook up with the core module and
153
# must therefore be compiled into each module.
154
$(ODIR)module.$O: include/module.c $(DEP)
156
$H $(CC) $(CFLAGS) -c -o $@ $<
159
# - Dependencies for modules -
160
$(ODIR)init.$O: $(IDIR)/init.c
161
$(ODIR)constants.$O: include/lg-hash.h
162
$(ODIR)functions.$O: include/lg-hash.h
163
$(ODIR)types.$O: include/common.h $(ODIR)config.h
161
166
# -- dynamic runtime linking --
162
167
linkh: ${ODIR}link.h
163
${ODIR}link.c ${ODIR}link.h: src/linklist.txt script/make-link.lua \
168
${ODIR}link.c ${ODIR}link.h: $(IDIR)/spec.lua script/make-link.lua \
166
$H script/make-link.lua ${ODIR}types.xml src/linklist.txt \
167
${ODIR}link.h ${ODIR}link.c
171
$H script/make-link.lua ${ODIR}types.xml $(IDIR)/spec.lua \
172
${ODIR}link.h ${ODIR}link.c $(DYNLINK_PREFIX)_dynlink
174
# Generation of data from the XML file
176
$(ODIR)functions.txt $(ODIR)constants.txt $(ODIR)types.c \
177
$(ODIR)globals.c $(ODIR)fundamentals.c $(ODIR)generated.c: \
178
${ODIR}types.xml script/parse-xml.lua include/fundamental.lua \
179
$(ODIR)config.lua $(DEVMOD) $(IDIR)/spec.lua
181
$H script/parse-xml.lua "${ODIR}" "$<" "$(ODIR)config.lua"
183
ifeq ($(COREMODULE), )
186
# Update the timestamp of parse-xml.lua whenever one of its parts changes.
187
# This in turn forces rebuilding its output.
188
script/parse-xml.lua: script/xml-types.lua script/xml-parser.lua \
189
script/xml-output.lua script/xml-const.lua
193
#${ODIR}_override.c: ${ODIR}override.luac ${ODIR}file2c
195
# $H ${ODIR}file2c override < $< > $@
198
# -- hash generation --
200
$(ODIR)%.c: $(ODIR)%.txt $(DEVMOD)
202
$H lua -lgnomedev -e 'gnomedev.generate_hash("$<", "$*", "$@")'
169
204
# -- general rules --
171
${ODIR}%-native.$(O): src/%.c
173
$H ${HOSTCC} ${CFLAGS} -c -o $@ $<
175
${ODIR}%.$(O): src/%.c
206
${ODIR}%.$O: $(IDIR)/%.c
177
208
$H ${CC} ${CFLAGS} -c -o $@ $<
210
$(ODIR)%.$O: $(ODIR)%.c
212
$H $(CC) $(CFLAGS) -c -o $@ $<
214
${ODIR}%.s: $(IDIR)/%.c
181
216
$H ${CC} ${CFLAGS} -S -o $@ $<
218
${ODIR}%.c: $(IDIR)/%.c
185
220
$H ${CC} ${CFLAGS} -E -o $@ $<
187
222
# could use -s to remove debugging info
188
${ODIR}%.luac: src/%.lua
223
${ODIR}%.luac: $(IDIR)/%.lua
192
# -- special targets --
196
$H rm -f ${ODIR}${ODLL} ${ODIR}generate ${ODIR}_*.c ${ODIR}*.$(O)
197
$H rm -f ${ODIR}file2c ${ODIR}override.luac ${ODIR}hash-cmph-generate
198
$H rm -f ${ODIR}ffi-types
202
$H rm -f ${ODIR}gtkdata.* ${ODIR}hash-fch-* ${ODIR}config.* \
203
${ODIR}types.xml ${ODIR}ffi-ofs ${ODIR}link.[ch] \
204
${ODIR}luagtk_ffi.h ${ODIR}cmph_types.h \
205
${ODIR}test-*-ok ${ODIR}test-*${EXESUFFIX}
207
# you need to be root for this!
209
$(LIBINSTALL) ${ODIR}${ODLL} $(INDIR1)/${ODLL}
210
$(LIBFINAL) $(INDIR1)
211
mkdir -p $(INDIR2)/gtk
212
cp -a lib $(INDIR2)/gtk/
216
(cd ..; ln -s lua-gtk lua-gtk-${VERSION}; \
217
tar czvfh tar/lua-gtk-${VERSION}.tar.gz \
218
--exclude build --exclude CVS --exclude mingw \
219
--exclude tags --exclude ".*.swp" --exclude attic \
220
--exclude private --exclude win32 --exclude funclist \
221
lua-gtk-${VERSION}; \
222
rm lua-gtk-${VERSION})
225
wc src/*.{c,h,lua} script/*.lua lib/*.lua
227
size: $(addprefix ${ODIR}, ${OFILES})
237
cvs diff -u | diffstat
239
# Requires an improved version of luadoc that can read C files
241
$H luadoc -d build/reference lib src/*.c
242
( cd html_in; ../script/gen-html.lua )
245
# src/call.c src/callback.c \
246
# src/channel.c src/override.c
249
@echo "Usage: make.sh [architecture] [target]"
250
@echo " architecture: optional, may be linux-i386, linux-amd64 or win32-i386"
251
@echo " target: optional, default is all, also known:"
252
@echo " help, doc, install, clean, mrproper and maybe more."
254
funclist: all ${ODIR}gtkdata.funcs.txt
255
$H script/funclist.lua ${ODIR}gtkdata.funcs.txt > $@
259
${ODIR}call.$O: ${ODIR}luagtk_ffi.h ${LH}
260
${ODIR}callback.$O: ${LH}
261
${ODIR}channel.$O: ${LH}
262
${ODIR}data.$O: ${LH} src/luagtk_hash.h
263
${ODIR}debug.$O: ${LH}
264
${ODIR}gtk2.$O: ${LH}
265
${ODIR}gtkdata.structs.$O: $(LH) ${ODIR}gtkdata.structs.c
266
${ODIR}gvalue.$O: ${LH}
267
${ODIR}hash-cmph-generate.$O: $(LH) src/hash-cmph.h
268
${ODIR}hash-functions.$O: $(LH) src/hash-cmph.h
269
${ODIR}hash-cmph.$O: $(LH) src/hash-cmph.h
270
${ODIR}hash-fch.$O: $(LH) src/hash-cmph.h
271
${ODIR}hash-bdz.$O: $(LH) src/hash-cmph.h
272
${ODIR}interface.$O: ${LH}
273
${ODIR}override.$O: ${LH}
274
${ODIR}types.$O: $(LH) ${ODIR}gtkdata.types.c ${ODIR}luagtk_ffi.h
275
${ODIR}enum.$O: $(LH)
276
${ODIR}voidptr.$O: $(LH)
277
${ODIR}widget.$O: ${LH}
278
${ODIR}widget_meta.$O: ${LH}
279
${ODIR}widget_types.$O: ${LH}