summaryrefslogtreecommitdiff
path: root/debian/rules
blob: df8d0ab4db8321335dcc7cd7bec55a1b63fd6d92 (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
#!/usr/bin/make -f

# list of flavors we build; each gets a builddir, a configure pass (configure
# args are defined below), a build pass, and an install pass
FLAVORS := main udeb

# current flavor we're building; this is only expanded in flavor specific
# targets
current_flavor = $*

# macro to get a value for the current flavor we're building; for example
# when building the main flavor, $(call flavor_get,CFLAGS) will expand to
# main_CFLAGS if it's set or to CFLAGS otherwise; pay attention to not adding
# superflous spaces when for the arguments of $(call ); only some vars can
# be expanded in this way though
flavor_get = $(or $($(current_flavor)_$(1)),$($(1)))

# Supported backends (as of Cairo 1.7.4):
#  (internal) Image
#  xlib       Xlib
#  pdf        PDF
#  ps         PostScript
#  svg        SVG
#
# Experimental and unsupported backends:
#  directfb  DirectFB (requires Build-Depend on libdirectfb-dev (>=0.9.25) )
#  glitz     OpenGL (glitz)
#  xcb       XCB  (requires Build-Depend on at least libxcb1-dev)
#
# Other platform backends are auto disabled: quartz/OSX, win32/Win32
#
# Features:
# --enable-png  PNG (default enabled)

DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

configure_flags += \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--enable-pdf --enable-ps \
--enable-xlib \
--enable-png \
--enable-tee \
--disable-silent-rules \
--disable-maintainer-mode \
--build=$(DEB_BUILD_GNU_TYPE)

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
configure_flags += --host=$(DEB_HOST_GNU_TYPE)
endif

main_configure_flags += \
$(configure_flags) \
--enable-xlib --enable-svg \
--enable-xcb --enable-perf-utils # --enable-gl

udeb_configure_flags += \
$(configure_flags) \
--disable-svg \
--disable-xcb

builddir = $(buildbasedir)/$(current_flavor)
buildbasedir = $(CURDIR)/debian/build

installdir = $(installbasedir)/$(current_flavor)
installbasedir = $(CURDIR)/debian/install

# default CFLAGS; these can be expanded with $(call flavor_get, )
CFLAGS += -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS_main += $(CFLAGS) -O0
CFLAGS_udeb += $(CFLAGS) -O0
else
CFLAGS_main += $(CFLAGS) -O2
CFLAGS_udeb += $(CFLAGS) -Os
endif

LDFLAGS += -Wl,-z,defs -Wl,-O1 -Wl,--as-needed

configure-common-stamp:
	dh_testdir
	# Generated by configure and breaks the build if already existing
	-test -r src/cairo-features.h && \
	  mv src/cairo-features.h src/cairo-features.h.orig
	dh_autoreconf
	patch -Np1 < debian/ltmain_as-needed.patch
	touch $@

configure-stamp-%: configure-common-stamp
	dh_testdir
	mkdir -p $(builddir); \
	cd $(builddir); \
	$(CURDIR)/configure \
		CFLAGS="$(call flavor_get,CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		$(call flavor_get,configure_flags)
	touch $@

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

build-stamp-%: configure-stamp-%
	dh_testdir
	$(MAKE) -C $(builddir)
	touch $@

clean:
	dh_testdir
	dh_testroot
	[ ! -r src/cairo-features.h.orig ] || mv -f src/cairo-features.h.orig src/cairo-features.h
	[ ! -r configure-common-stamp ] || patch -NRp1 < debian/ltmain_as-needed.patch
	rm -f *-stamp
	rm -rf $(buildbasedir) $(installbasedir)
	dh_autoreconf_clean
	dh_clean

install-%: build-stamp-%
	$(MAKE) -C $(builddir) install DESTDIR=$(installdir)
	sed -i "/dependency_libs/ s/'.*'/''/" $(installdir)/usr/lib/*.la

install:
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	for f in $(FLAVORS); do \
	    debian/rules install-$$f; \
	done

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_install -i
	dh_installchangelogs -i ChangeLog
	dh_installdocs -i -A NEWS README AUTHORS
	dh_link -i
	dh_lintian -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_install -s
	dh_installdocs -s -A README NEWS AUTHORS
	dh_installchangelogs -s ChangeLog
	dh_installman -s
	dh_installexamples -s
	dh_link -s
	dh_strip -s --dbg-package=libcairo2-dbg -Nlibcairo2-udeb
	dh_strip -plibcairo2-udeb
	dh_lintian -s
	dh_compress -s
	dh_fixperms -s
	dh_makeshlibs -plibcairo2 --add-udeb=libcairo2-udeb -V 'libcairo2 (>= 1.10.2-2~)' -- -c4
	dh_makeshlibs -plibcairo-gobject2 -V 'libcairo-gobject2 (>= 1.10.0)' -- -c4
	dh_makeshlibs -plibcairo-script-interpreter2 -V 'libcairo-script-interpreter2 (>= 1.10.0)' -- -c4
	dh_installdeb -s
	dh_shlibdeps -s
	dh_perl -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

binary: binary-indep binary-arch

.PHONY: build clean binary-indep binary-arch binary install clean