~ubuntu-branches/ubuntu/natty/lua-gtk/natty

« back to all changes in this revision

Viewing changes to script/Makefile.common

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Tassi
  • Date: 2009-05-17 18:16:21 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090517181621-9kmdd82nxg54jsio
* new upstream snapshot comprising many more GNOME libraries:
    Gtk, GDK, GLib, Pango, Atk, Libxml2, Cairo, Clutter, Gtkhtml, 
    GtkSourceView, Gio, Gtkspell and GConf. 
* new upstream release includes a new configure script written in Lua,
  no more bashisms there (Closes: #507205)
* renamed binary packages to liblua5.1-gnome-*
* updated standards-version to 3.8.1, no changes needed
* patch to load .so.* version of libraries and not .so (that was requiring
  -dev packages) (Closes: #522087)
* removed redundant Architecture line from the source stanza of control
  (Closes: #498120)
* updated copyright file, Wolfgang Oertl holds it for 2009 too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
 
2
# Common Makefile rules to build a library module.  Following variables need
 
3
# to be set before including this file:
 
4
#
 
5
# MODULE
 
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).
 
8
#
 
9
# SRC
 
10
# (optional) list of module specific source files in addition to init.c and the
 
11
# files generated from the headers (types, functions etc.)
 
12
#
 
13
 
 
14
ifeq ($(MODULE), )
 
15
 $(error You have to define $$MODULE)
 
16
endif
 
17
 
 
18
all: module_$(MODULE) dummy
 
19
 
 
20
dummy:
 
21
        @true
 
22
 
 
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
 
25
# the command line.
 
26
FILE := $(wildcard build/make.state)
 
27
ifneq ($(FILE), )
 
28
    include $(FILE)
 
29
endif
 
30
 
 
31
ifeq ($(wildcard build/$(ARCH)/$(MODULE)/config.make), )
 
32
    $(error Library $(ARCH)/$(MODULE) not yet configured)
 
33
endif
 
34
 
 
35
# $(warning Building $(ARCH) $(MODULE)...)
 
36
 
 
37
# include the config file
 
38
include build/$(ARCH)/$(MODULE)/config.make
 
39
 
 
40
ifdef NOT_AVAILABLE
 
41
  $(warning The module $(MODULE) is not buildable.)
 
42
module_$(MODULE):
 
43
        @true
 
44
else
 
45
 
2
46
# -- general configuration --
3
 
HASH    :=hash-$(HASHF)
 
47
#HASH   :=hash-$(HASHF)
4
48
O       :=o
5
49
LIBINSTALL := cp
6
50
LIBFINAL := touch
 
51
IDIR    :=src/$(MODULE)
 
52
DYNLINK_PREFIX :=$(MODULE)
 
53
BINDIR  =build/$(ARCH)/
 
54
DEVMOD  :=build/$(ARCH)/gnomedev.so
7
55
# -- end general configuration --
8
56
 
 
57
# -- non-core-module settings --
 
58
ifeq ($(COREMODULE), )
 
59
SRC     :=init generated module $(SRC)
 
60
OFILES  =$(SRC) types globals fundamentals
 
61
 
 
62
#$(DEVMOD):
 
63
#       $(error Build the gnome module first)
 
64
 
 
65
else
 
66
OFILES  =$(SRC)
 
67
endif
 
68
 
 
69
# Run make with "H=" as an argument to show all build commands; otherwise
 
70
# just show each build target.
 
71
H       :=@
 
72
ifeq ($(H), @)
 
73
 I      =@echo $@
 
74
else
 
75
 I      :=
 
76
endif
 
77
 
 
78
# how to recursively call make (if required)
 
79
submake = $(MAKE) -r --no-print-directory
 
80
 
 
81
 
 
82
module_$(MODULE): $(ODIR)$(MODULE)$(DLLEXT)
 
83
 
 
84
# cleanup
 
85
clean:
 
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 \
 
91
                $(ODIR)parse-xml.log
 
92
 
 
93
mrproper: clean
 
94
        $H rm -f $(ODIR)config.{h,lua,make}
 
95
 
 
96
size: $(addprefix $(ODIR), $(addsuffix .$O,$(OFILES)))
 
97
        $H size -t $(addprefix $(ODIR), $(addsuffix .$O,$(OFILES)))
 
98
        $H size $(ODIR)$(MODULE)$(DLLEXT)
 
99
 
 
100
wc:
 
101
        $H wc $(IDIR)/*.[ch]
 
102
 
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
11
 
 
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
17
 
 
18
 
# -- runtime linking? --
 
104
.PRECIOUS: $(ODIR)%.txt $(ODIR)%.c
 
105
 
 
106
# headers for dependencies
 
107
DEP     :=include/common.h include/module.h $(ODIR)config.h
 
108
 
19
109
ifeq ($(DYNLINK), 0)
20
 
LIBS    :=${GTK_LIBS}
21
 
else
22
 
OFILES  +=link.$(O)
23
 
LH      +=${ODIR}link.h
24
 
endif
25
 
 
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
30
 
else
31
 
OFILES  +=hash-simple.$(O) ${HASH}.$(O) _funclist.$(O) _enumlist.$(O)
32
 
endif
33
 
 
34
 
# -- is libgtkhtml available? --
35
 
ifeq ($(HAVE_HTML), 1)
36
 
MAKE_XML_FLAGS  +=--enable-gtkhtml
37
 
endif
38
 
 
39
 
gtk2dll: build-tests ${ODIR}${ODLL}
40
 
 
41
 
config configure:
42
 
        $H script/configure $(ARCH)
43
 
 
44
 
 
45
 
# test that calling works properly.  For Win32, requires wine to be installed.
46
 
build-tests: ${ODIR}test-vararg-ok
47
 
 
48
 
${ODIR}test-%-ok: ${ODIR}test-%${EXESUFFIX}
49
 
        $H $(CROSS_RUN) $^ && touch $@
50
 
 
51
 
${ODIR}test-vararg${EXESUFFIX}: src/test-vararg.c
52
 
        $I
53
 
        $H $(CC) $(CFLAGS) -I $(ODIR) -Wall -o $@ $^
54
 
 
55
 
# rule to build the library.
56
 
 
57
 
${ODIR}${ODLL}: $(addprefix ${ODIR}, ${OFILES})
58
 
        $I
59
 
        $H $(CC) ${LDFLAGS} -shared -o $@ $^ ${LIBFFI_LIB} ${EXTRA_LIB} ${LIBS}
60
 
 
61
 
${ODIR}debug.$(O): src/debug.c
62
 
        $I
63
 
        $H ${CC} ${CFLAGS} -I lua-5.1/src -c -o $@ $<
64
 
 
65
 
${ODIR}_funclist.c: ${ODIR}gtkdata.funcs.txt ${ODIR}generate src/luagtk_hash.h
66
 
        $I
67
 
        $H ${ODIR}generate -s 4096 -o $@ -n hash_info_funcs -d -f $<
68
 
 
69
 
${ODIR}_enumlist.c: ${ODIR}gtkdata.enums.txt ${ODIR}generate src/luagtk_hash.h
70
 
        $I
71
 
        $H ${ODIR}generate -s 4096 -o $@ -n hash_info_enums -d -f $<
72
 
 
73
 
${ODIR}_override.c: ${ODIR}override.luac ${ODIR}file2c
74
 
        $I
75
 
        $H ${ODIR}file2c override < $< > $@
76
 
 
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)"
 
110
LIBS    +=$(GTK_LIBS)
 
111
else
 
112
OFILES  +=link
 
113
DEP     +=$(ODIR)link.h
 
114
endif
 
115
 
 
116
# configure hash files depending on the setting in build/make.state.
 
117
ifeq ($(COREMODULE), )
 
118
 OFILES +=functions constants
 
119
else
 
120
 ifeq ($(HAVE_CMPH), 1)
 
121
  OFILES        +=hash-functions hash-cmph hash-$(HASH_METHOD)
 
122
 else
 
123
  OFILES        +=hash-simple # hash-$(HASH_METHOD) $(HASH)
 
124
 endif
 
125
endif
 
126
 
 
127
# the target library
 
128
$(ODIR)$(MODULE)$(DLLEXT): $(addprefix $(ODIR),$(addsuffix .$O,$(OFILES)))
 
129
        $I
 
130
        $H $(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
83
131
 
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
86
 
        $I
87
 
        $H script/make-xml.lua $(MAKE_XML_FLAGS) "$@" $(ARCH)
88
 
 
89
 
${ODIR}%.$(O): ${ODIR}%.c
 
133
${ODIR}types.xml: script/make-xml.lua $(ODIR)config.h $(ODIR)config.lua $(IDIR)/spec.lua
 
134
        $I
 
135
        $H script/make-xml.lua "$(ODIR)"
 
136
 
 
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
 
140
        $I
 
141
        $H script/configure.lua $(CONFIG_ARGS) $(MODULE)
 
142
        $H touch "$@"
 
143
 
 
144
$(ODIR)%.$O: $(ODIR)%.c
90
145
        $I
91
146
        $H ${CC} ${CFLAGS} -c -o $@ $<
92
147
 
93
 
# -- ffi magic --
94
 
 
95
 
${ODIR}luagtk_ffi.h: ${ODIR}ffi-types
96
 
        $I
97
 
        $H ${ODIR}ffi-types > $@
98
 
 
99
 
${ODIR}ffi-types.$(O): src/ffi-types.c
100
 
        $I
101
 
        $H ${HOSTCC} ${CFLAGS} -o $@ -c $<
102
 
 
103
 
${ODIR}ffi-types: ${ODIR}ffi-types.$(O)
104
 
        $I
105
 
        $H ${HOSTCC} -o $@ $< -lffi
106
 
 
107
 
# -- cmph hash --
108
 
 
109
 
${ODIR}%.keys: ${ODIR}%.txt
110
 
        $I
111
 
        $H sed 's/,.*$$//' < $^ > $@
112
 
 
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
116
 
        $I
117
 
        $H $(CMPH_BIN) -a $(CMPH_ALGO) -m $@ -g $^
118
 
 
119
 
${ODIR}_funclist_$(CMPH_ALGO).c: ${ODIR}hash-cmph-generate \
120
 
        ${ODIR}gtkdata.funcs.$(CMPH_ALGO).mph
121
 
        $I
122
 
        $H ${ODIR}hash-cmph-generate ${ODIR}gtkdata.funcs.$(CMPH_ALGO).mph \
123
 
                ${ODIR}gtkdata.funcs.txt "funcs" > $@
124
 
 
125
 
${ODIR}_enumlist_$(CMPH_ALGO).c: ${ODIR}hash-cmph-generate \
126
 
        ${ODIR}gtkdata.enums.$(CMPH_ALGO).mph
127
 
        $I
128
 
        $H ${ODIR}hash-cmph-generate ${ODIR}gtkdata.enums.$(CMPH_ALGO).mph \
129
 
                ${ODIR}gtkdata.enums.txt "enums" > $@
130
 
 
131
 
${ODIR}hash-fch.$(O): src/hash-fch.c
132
 
        $I
133
 
        $H ${CC} ${CFLAGS} -c -o $@ ${CMPH_CFLAGS} $<
134
 
 
135
 
${ODIR}hash-bdz.$(O): src/hash-bdz.c
136
 
        $I
137
 
        $H ${CC} ${CFLAGS} -c -o $@ ${CMPH_CFLAGS} $<
138
 
 
139
 
# -- helper programs for simple and cmph hash, to be compiled with HOSTCC --
140
 
 
141
 
${ODIR}generate.$(O): src/generate.c
142
 
        $I
143
 
        $H ${HOSTCC} ${CFLAGS} -c -o $@ $<
144
 
 
145
 
${ODIR}generate: ${ODIR}generate.$(O) ${ODIR}${HASH}-native.$(O)
146
 
        $I
147
 
        $H ${HOSTCC} -o $@ $^
148
 
 
149
 
${ODIR}file2c: src/file2c.c
150
 
        $I
151
 
        $H ${HOSTCC} -o $@ $^
152
 
 
153
 
${ODIR}hash-cmph-generate: ${ODIR}hash-cmph-generate.$(O)
154
 
        $I
155
 
        $H ${HOSTCC} -g -o $@ $^ $(CMPH_LIBS)
156
 
 
157
 
${ODIR}hash-cmph-generate.$O: src/hash-cmph-generate.c
158
 
        $I
159
 
        $H ${HOSTCC} -g -o $@ ${CMPH_CFLAGS} -I ${ODIR} -c $< 
 
148
$(ODIR)%.$O: $(IDIR)/%.c $(DEP)
 
149
        $I
 
150
        $H $(CC) $(CFLAGS) -c -o $@ $<
 
151
 
 
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)
 
155
        $I
 
156
        $H $(CC) $(CFLAGS) -c -o $@ $<
 
157
 
 
158
 
 
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
 
164
 
160
165
 
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 \
164
169
        ${ODIR}types.xml
165
170
        $I
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
 
173
 
 
174
# Generation of data from the XML file
 
175
 
 
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
 
180
        $I
 
181
        $H script/parse-xml.lua "${ODIR}" "$<" "$(ODIR)config.lua"
 
182
 
 
183
ifeq ($(COREMODULE), )
 
184
endif
 
185
 
 
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
 
190
        touch $@
 
191
 
 
192
# XXX unused
 
193
#${ODIR}_override.c: ${ODIR}override.luac ${ODIR}file2c
 
194
#       $I
 
195
#       $H ${ODIR}file2c override < $< > $@
 
196
#
 
197
 
 
198
# -- hash generation --
 
199
 
 
200
$(ODIR)%.c: $(ODIR)%.txt $(DEVMOD)
 
201
        $I
 
202
        $H lua -lgnomedev -e 'gnomedev.generate_hash("$<", "$*", "$@")'
168
203
 
169
204
# -- general rules --
170
205
 
171
 
${ODIR}%-native.$(O): src/%.c
172
 
        $I
173
 
        $H ${HOSTCC} ${CFLAGS} -c -o $@ $<
174
 
 
175
 
${ODIR}%.$(O): src/%.c
 
206
${ODIR}%.$O: $(IDIR)/%.c
176
207
        $I
177
208
        $H ${CC} ${CFLAGS} -c -o $@ $<
178
209
 
179
 
${ODIR}%.s: src/%.c
 
210
$(ODIR)%.$O: $(ODIR)%.c
 
211
        $I
 
212
        $H $(CC) $(CFLAGS) -c -o $@ $<
 
213
 
 
214
${ODIR}%.s: $(IDIR)/%.c
180
215
        $I
181
216
        $H ${CC} ${CFLAGS} -S -o $@ $<
182
217
 
183
 
${ODIR}%.c: src/%.c
 
218
${ODIR}%.c: $(IDIR)/%.c
184
219
        $I
185
220
        $H ${CC} ${CFLAGS} -E -o $@ $<
186
221
 
187
222
# could use -s to remove debugging info
188
 
${ODIR}%.luac: src/%.lua
 
223
${ODIR}%.luac: $(IDIR)/%.lua
189
224
        $I
190
225
        $H luac -o $@ $<
191
226
 
192
 
# -- special targets --
193
 
 
194
 
clean:
195
 
        $I
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
199
 
 
200
 
mrproper: clean
201
 
        $I
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}
206
 
install: all
207
 
        # you need to be root for this!
208
 
        mkdir -p $(INDIR1)
209
 
        $(LIBINSTALL) ${ODIR}${ODLL} $(INDIR1)/${ODLL}
210
 
        $(LIBFINAL) $(INDIR1)
211
 
        mkdir -p $(INDIR2)/gtk
212
 
        cp -a lib $(INDIR2)/gtk/
213
 
 
214
 
# source tar file
215
 
tar:
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})
223
 
 
224
 
wc:
225
 
        wc src/*.{c,h,lua} script/*.lua lib/*.lua
226
 
 
227
 
size: $(addprefix ${ODIR}, ${OFILES})
228
 
        size -t $^
229
 
 
230
 
tags:
231
 
        ctags src/*.[ch]
232
 
 
233
 
tests:
234
 
        tests/run-tests.sh
235
 
 
236
 
diff:
237
 
        cvs diff -u | diffstat
238
 
 
239
 
# Requires an improved version of luadoc that can read C files
240
 
doc:
241
 
        $H luadoc -d build/reference lib src/*.c
242
 
        ( cd html_in; ../script/gen-html.lua )
243
 
 
244
 
#       src/gtk2.c \
245
 
#               src/call.c src/callback.c \
246
 
#               src/channel.c src/override.c
247
 
 
248
 
help:
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."
253
 
 
254
 
funclist: all ${ODIR}gtkdata.funcs.txt
255
 
        $H script/funclist.lua ${ODIR}gtkdata.funcs.txt > $@
256
 
 
257
 
# -- dependencies --
258
 
 
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}
280
 
 
 
227
endif
281
228