summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 78cf080ef9cf9daddd15d4ccb06e65deda0e05db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/usr/bin/make -f

DISABLE_UPDATE_UPLOADERS := 1
include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
-include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

GNOME_MODULE := glib

STAMP_DIR := debian/stampdir

PATCH_DIR := debian/patches

# rules in this debian/rules Makefile can be built concurrently as well as
# upstream rules in Makefile; all $(MAKE) invocations will inherit this flag,
# if you recurse into debian/rules ($(MAKE)
# -f debian/rules in rules), you need to pass a flag to avoid adding "-jX" when
# the childs encounters this line
DEB_BUILD_OPTIONS_PARALLEL ?= $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += $(if $(DEB_BUILD_OPTIONS_PARALLEL),-j$(DEB_BUILD_OPTIONS_PARALLEL))

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

# Debian architectures
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_HOST_ARCH  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

CFLAGS += -Wall -DMAEMO_CHANGES -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2)

# Ensure the build aborts when there are still references to undefined
# symbols
LDFLAGS += -Wl,-z,defs

# Make the linker work a bit harder so dynamic loading can be done faster
LDFLAGS += -Wl,-O1

APIVER := 2.0
SONAME := 0
SHVER := 2.23.1

# package names
SHARED_PKG := libglib$(APIVER)-$(SONAME)
DATA_PKG := libglib$(APIVER)-data
DEV_PKG := libglib$(APIVER)-dev
DOC_PKG := libglib$(APIVER)-doc
DEBUG_PKG := $(SHARED_PKG)-dbg

# list of flavors we build; each gets a builddir, a configure pass (configure
# args are defined below), a build pass, and an install pass (in two steps)
# Note: the "deb" flavor is required
FLAVORS := deb

# list of flavors to run the test suite on
CHECK_FLAVORS := $(filter deb, $(FLAVORS))

# list of arches on which testsuite failures are fatal
# XXX testsuite failures currently disabled as testsuite fails everywhere when
# $HOME isn't writable
CHECK_SUPPORTED_ARCHES :=
# CHECK_SUPPORTED_ARCHES := alpha amd64 i386 ia64 lpia m68k s390
# testsuite is known to fail on hppa, hurd, kfreebsd-amd64, kfreebsd-i386; see
# Debian #428674
# testsuite is known to fail on arm, mips, mipsel, powerpc, sparc; see GNOME #481573

# build dir for the current flavor; this is only expanded in flavor specific
# targets
# Note: dh_clean will rm -rf debian/tmp, hence all builds
builddir = $(buildbasedir)/$*
buildbasedir = $(CURDIR)/debian/build

# install dir for the current flavor; this is only expanded in flavor specific
# targets
installdir = $(installbasedir)/$*
installbasedir = $(CURDIR)/debian/install

# configure flags
common_configure_flags := \
			--prefix=/usr \
			--mandir=\$${prefix}/share/man \
			--infodir=\$${prefix}/share/info \
			--with-html-dir=\$${prefix}/share/doc/$(DOC_PKG) \
			--with-pcre=internal \
			--disable-fam

ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	common_configure_flags += --build=$(DEB_BUILD_GNU_TYPE)
else
	common_configure_flags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
endif
deb_configure_flags := $(common_configure_flags) 

$(STAMP_DIR)/patch-stamp:
	dh_testdir
	# backup the original files to restore them in the clean target
	-test -r config.sub && cp config.sub config.sub.orig
	-test -r config.guess && cp config.guess config.guess.orig
	# apply patches
	QUILT_PATCHES=$(PATCH_DIR) \
		quilt --quiltrc /dev/null push -a || test $$? = 2
	-test -r /usr/share/misc/config.sub && \
		cp -f /usr/share/misc/config.sub config.sub
	-test -r /usr/share/misc/config.guess && \
		cp -f /usr/share/misc/config.guess config.guess
	-mkdir -p $(STAMP_DIR)
	autoreconf -f -i
	touch $@

patch: $(STAMP_DIR)/patch-stamp

$(STAMP_DIR)/configure-stamp-%: $(STAMP_DIR)/patch-stamp
	dh_testdir
	mkdir -p $(builddir)
	cd $(builddir) && \
		CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
			$(CURDIR)/configure $($*_configure_flags)
	touch $@

configure: $(addprefix $(STAMP_DIR)/configure-stamp-, $(FLAVORS))

$(STAMP_DIR)/build-stamp-%: $(STAMP_DIR)/configure-stamp-%
	dh_testdir
	LD_LIBRARY_PATH=$(builddir)/glib/.libs:$(builddir)/gmodule/.libs:$(builddir)/gobject/.libs:$(builddir)/gthread/.libs:$(LD_LIBRARY_PATH) \
		$(MAKE) -C $(builddir)
	touch $@

build: $(addprefix $(STAMP_DIR)/build-stamp-, $(FLAVORS))

maybe_ignore_check_failure = $(if $(filter ,$(CHECK_SUPPORTED_ARCHES)),-)

$(STAMP_DIR)/check-stamp-%: $(STAMP_DIR)/build-stamp-%
	dh_testdir
ifeq ($(filter $(DEB_BUILD_ARCH),$(CHECK_SUPPORTED_ARCHES)),$(DEB_BUILD_ARCH))
	# testsuite failures are fatal
	LD_LIBRARY_PATH=$(builddir)/glib/.libs:$(builddir)/gmodule/.libs:$(builddir)/gobject/.libs:$(builddir)/gthread/.libs:$(LD_LIBRARY_PATH) \
		$(MAKE) -k -C $(builddir) check
else
	# testsuite failures are ignored
	-LD_LIBRARY_PATH=$(builddir)/glib/.libs:$(builddir)/gmodule/.libs:$(builddir)/gobject/.libs:$(builddir)/gthread/.libs:$(LD_LIBRARY_PATH) \
		$(MAKE) -k -C $(builddir) check
endif
	touch $@

check: $(addprefix $(STAMP_DIR)/check-stamp-, $(CHECK_FLAVORS))

$(STAMP_DIR)/install-stamp-%: $(STAMP_DIR)/build-stamp-%
	mkdir -p $(installdir)
	$(MAKE) -C $(builddir) install DESTDIR=$(installdir)
	touch $@

install: $(addprefix $(STAMP_DIR)/install-stamp-, $(FLAVORS))

debian/control:
	dh_testdir
	sed \
		-e "s#@SONAME@#$(SONAME)#g" \
		-e "s#@APIVER@#$(APIVER)#g" \
		-e "s#@VERSION@#$(VERSION)#g" \
		-e "s#@SHARED_PKG@#$(SHARED_PKG)#g" \
		-e "s#@DATA_PKG@#$(DATA_PKG)#g" \
		-e "s#@DEV_PKG@#$(DEV_PKG)#g" \
		-e "s#@DOC_PKG@#$(DOC_PKG)#g" \
		-e "s#@DEBUG_PKG@#$(DEBUG_PKG)#g" \
		-e "s#@GNOME_TEAM@#$(UPLOADERS)#g" \
		$@.in >$@

clean:: debian/control
	dh_testdir
	dh_testroot
	# remove install and build dirs
	rm -rf $(installbasedir)
	rm -rf $(buildbasedir)
	# restore files from backup (before unpatching)
	-test -r config.sub.orig && mv -f config.sub.orig config.sub
	-test -r config.guess.orig && mv -f config.guess.orig config.guess
	# unapply patches, if any
	QUILT_PATCHES=$(PATCH_DIR) \
		quilt --quiltrc /dev/null pop -a -R || test $$? = 2
	-rm -rf .pc
	-rm -rf $(STAMP_DIR)
	dh_clean

ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
# maemo: testsuite hangs sb; investigate
maybe_check = 
# maybe_check = $(if $(findstring nocheck,$(DEB_BUILD_OPTIONS)),,check)
else
# can't run the testsuite when cross-compiling
maybe_check =
endif

binary-indep: build $(maybe_check) install
	dh_testdir
	dh_testroot
	dh_install -i
	dh_installchangelogs -i -N$(DATA_PKG) ChangeLog
	dh_installdocs -N$(DATA_PKG) -i NEWS README
	dh_link -i
	dh_compress -i -X.sgml -X.devhelp
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build $(maybe_check) install
	dh_testdir
	dh_testroot
	dh_install -s
	# empty the dependency_libs in the *.la files
	sed -i -e "/dependency_libs/ s/'.*'/''/" debian/$(DEV_PKG)/usr/lib/*.la
	dh_installchangelogs -s -N$(DEV_PKG) -N$(DEBUG_PKG) \
		ChangeLog
	dh_installdocs -s -N$(DEV_PKG) -N$(DEBUG_PKG) NEWS README
	dh_link -s
	dh_strip -s --dbg-package=$(DEBUG_PKG)
	dh_compress -s -X.sgml -X.devhelp
	dh_fixperms -s
	dh_makeshlibs	-p$(SHARED_PKG) \
			-V "$(SHARED_PKG) (>= $(SHVER))" \
			 -- -c4
	dh_installdeb -s
	# override shlibs for libraries from this source before computing
	# dependencies of packages generated from this source; we already have
	# inter-dependencies expressed manually in the control file, we do not
	# need the shlibs to add duplicates
	sed -nr -e 's/(([^ ]+: )?([^ ]+) ([^ ]+)) .*/\1/p' \
		debian/*/DEBIAN/shlibs \
		>debian/shlibs.local
	dh_shlibdeps -s -ldebian/$(SHARED_PKG)/usr/lib
	-rm -f debian/shlibs.local
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

binary: binary-indep binary-arch
.PHONY: patch configure build check install clean binary-indep binary-arch binary debian/control