summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 35ed85bc117fc5dd6c1e12df7318d6c262fa5fc9 (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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/usr/bin/make -f
# debian/rules for the Debian mesa package
# Copyright © 2006 Thierry Reding <thierry@gilfi.de>

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

CFLAGS = -Wall -g
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

DEB_BUILD_ARCH     ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_HOST_ARCH     ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS     ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
DEB_BUILD_DIR      ?= $(CURDIR)/build
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
        confflags += --build=$(DEB_HOST_GNU_TYPE)
else
        confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
endif

# choose which configurations to build
include debian/scripts/choose-configs

# build the following configurations by default
CONFIGS = $(SWX11_GLU_CONFIGS) \
	  dri \
	  osmesa \
	  osmesa-static \
	  osmesa16 \
	  osmesa16-static \
	  osmesa32 \
	  osmesa32-static

STAMP_DIR = debian/stamp
STAMP = $(STAMP_DIR)/$(DEB_BUILD_GNU_TYPE)
BUILD_STAMPS = $(addprefix $(STAMP)-build-, $(CONFIGS))

QUILT_STAMPFN = $(STAMP_DIR)/patch
include /usr/share/quilt/quilt.make

confflags-common = \
	--disable-glu \
	--disable-glut \
	--disable-glw \
	CFLAGS="$(CFLAGS)"

DRI_DRIVERS = swrast
GALLIUM_DRIVERS = --enable-gallium-swrast
# Mesa 7.8 doesn't build a gallium swrast DRI driver
# This is built in git, and will be built in 7.9
HAVE_GALLIUM_DRI_DRIVERS = no
HAVE_KMS = no
EGL_DISPLAYS = x11

# hurd doesn't do direct rendering
ifeq ($(DEB_HOST_ARCH_OS), hurd)
	DIRECT_RENDERING = --disable-driglx-direct
else
	DIRECT_RENDERING = --enable-driglx-direct

  ifeq ($(DEB_HOST_ARCH_OS), linux)
# Gallium drivers require libdrm-{nouveau,radeon}, only available on Linux
	GALLIUM_DRIVERS += --enable-gallium-nouveau --enable-gallium-radeon
	HAVE_GALLIUM_DRI_DRIVERS = yes
# Although the KMS egl drivers will probably build on kfreebsd & hurd
# only linux actually has KMS drivers implemented at this point.
	HAVE_KMS = yes
  endif

  ifeq ($(DEB_HOST_ARCH), lpia)
	DRI_DRIVERS += i915 i965
	GALLIUM_DRIVERS += --enable-gallium-intel
  else ifneq ($(DEB_HOST_ARCH), s390)
	DRI_DRIVERS += mach64 mga r128 r200 r300 r600 radeon savage tdfx
    ifeq ($(DEB_HOST_ARCH_CPU), i386)
	DRI_DRIVERS += i810 i915 i965 sis unichrome
	GALLIUM_DRIVERS += --enable-gallium-intel
    else ifeq ($(DEB_HOST_ARCH_CPU), amd64)
	DRI_DRIVERS += i915 i965 sis unichrome
	GALLIUM_DRIVERS += --enable-gallium-intel
    endif
  endif
endif

ifeq ($(HAVE_KMS), yes)
	EGL_DISPLAYS += kms
endif

confflags-dri = \
	--with-driver=dri \
	--with-dri-drivers="$(DRI_DRIVERS)" \
	--with-demos=xdemos \
	--libdir=/usr/lib/glx \
	--with-dri-driverdir=/usr/lib/dri \
	--with-egl-displays="$(EGL_DISPLAYS)" \
	--enable-glx-tls \
	$(GALLIUM_DRIVERS) \
	--with-state-trackers=egl,es,glx,dri,vega \
	$(DIRECT_RENDERING) \
	$(confflags-common)

confflags-osmesa = \
	--disable-egl \
	--disable-gallium \
	--with-driver=osmesa \
	--with-demos= \
	$(confflags-common)

confflags-osmesa-static = \
	--disable-egl \
	--disable-gallium \
	--with-driver=osmesa \
	--enable-static \
	--with-demos= \
	$(confflags-common)

confflags-osmesa16 = \
	--disable-egl \
	--disable-gallium \
	--with-driver=osmesa \
	--with-osmesa-bits=16 \
	--with-demos= \
	$(confflags-common)

confflags-osmesa16-static = \
	--disable-egl \
	--disable-gallium \
	--with-driver=osmesa \
	--with-osmesa-bits=16 \
	--enable-static \
	--with-demos= \
	$(confflags-common)

confflags-osmesa32 = \
	--disable-egl \
	--disable-gallium \
	--with-driver=osmesa \
	--with-osmesa-bits=32 \
	--with-demos= \
	$(confflags-common)

confflags-osmesa32-static = \
	--disable-egl \
	--disable-gallium \
	--with-driver=osmesa \
	--with-osmesa-bits=32 \
	--enable-static \
	--with-demos= \
	$(confflags-common)

confflags-swx11+glu = \
	--disable-egl \
	--disable-gallium \
	--with-driver=xlib \
	--disable-gl-osmesa \
	--with-demos= \
	--disable-egl \
	--disable-glut \
	--enable-motif \
	CFLAGS="$(CFLAGS)"

confflags-swx11+glu-static = \
	--disable-egl \
	--disable-gallium \
	--with-driver=xlib \
	--disable-gl-osmesa \
	--enable-static \
	--with-demos= \
	--disable-egl \
	--disable-glut \
	--enable-motif \
	CFLAGS="$(CFLAGS)"

confflags-swx11+glu-i386-i686 = \
	--disable-egl \
	--disable-gallium \
	--with-driver=xlib \
	--disable-gl-osmesa \
	--with-demos= \
	--disable-glut \
	--disable-egl \
	--enable-motif \
	--libdir=/usr/lib/i686/cmov \
	CFLAGS="$(CFLAGS) -march=i686"

configure: $(QUILT_STAMPFN) configure.ac
	autoreconf -vfi

# list the configurations that will built
configs:
	@echo Building the following configurations: $(CONFIGS)

$(STAMP_DIR)/stamp:
	dh_testdir
	mkdir -p $(STAMP_DIR)
	>$@

$(QUILT_STAMPFN): $(STAMP_DIR)/stamp

build: $(BUILD_STAMPS)

$(STAMP)-build-%: configure
	dh_testdir

	mkdir -p $(DEB_BUILD_DIR)/$*
	find $(CURDIR)/* -maxdepth 0 -not -path '$(DEB_BUILD_DIR)*' | \
		xargs cp -rlf -t $(DEB_BUILD_DIR)/$*
	cd $(DEB_BUILD_DIR)/$* && \
	../../configure --prefix=/usr --mandir=\$${prefix}/share/man \
	             --infodir=\$${prefix}/share/info --sysconfdir=/etc \
	             --localstatedir=/var $(confflags) $(confflags-$*)
	cd $(DEB_BUILD_DIR)/$* && $(MAKE)

	touch $@

install: build
	# Add here commands to install the package into debian/tmp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	set -e; for config in $(CONFIGS); do \
		$(MAKE) -C $(DEB_BUILD_DIR)/$$config DESTDIR=$(CURDIR)/debian/tmp install; \
	done

clean: unpatch
	dh_testdir
	dh_testroot
	rm -rf .pc
	
	rm -f config.cache config.log config.status
	rm -f */config.cache */config.log */config.status
	rm -f conftest* */conftest*
	rm -rf autom4te.cache */autom4te.cache
	rm -rf build
	rm -rf configure config.guess config.sub config.h.in
	rm -rf $$(find -name Makefile.in)
	rm -rf aclocal.m4 missing depcomp install-sh ltmain.sh
	rm -rf $(STAMP_DIR)
	
	dh_clean

# Build architecture-independent files here.
binary-indep: install

# Build architecture-dependent files here.
binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs -s -XChangeLog
	dh_installchangelogs -pmesa-common-dev ChangeLog
	dh_installdocs -s
	dh_installexamples -s
	# Classic DRI and Gallium DRI are mixed up together here
	# Remove the whole tree to avoid false-positives in --list-missing, and
	# install the right files manually.
	rm -r debian/tmp/usr/lib/dri
	# Radeon searches for r{200,300,600}_dri only, but the gallium driver
	# is (at the moment) radeong_dri.  Rename it to r300_dri, as it
	# fails to support r600.
	mv build/dri/glx/gallium/radeong_dri.so \
		build/dri/glx/gallium/r300_dri.so
	# Intel i965 Gallium appears to do nothing more than generate GPU 
	# lockups.  Kill it with fire.  i915 is apparently useful.
	-rm build/dri/glx/gallium/i965_dri.so
	-rm debian/tmp/usr/lib/glx/egl/egl_*_i965.so

	dh_install -s --list-missing
	dh_installman -s
	dh_lintian -s
	dh_link -s
	dh_strip -plibgl1-mesa-swx11 --dbg-package=libgl1-mesa-swx11-dbg
	dh_strip -plibgl1-mesa-glx --dbg-package=libgl1-mesa-glx-dbg
	dh_strip -plibgl1-mesa-dri --dbg-package=libgl1-mesa-dri-dbg
ifeq ($(HAVE_GALLIUM_DRI_DRIVERS), yes)
	dh_strip -plibgl1-mesa-dri-gallium --dbg-package=libgl1-mesa-dri-gallium-dbg
endif
	dh_strip -plibopenvg1-mesa --dbg-package=libopenvg1-mesa-dbg
	dh_strip -plibegl1-mesa --dbg-package=libegl1-mesa-dbg
	dh_strip -plibgles1-mesa --dbg-package=libgles1-mesa-dbg
	dh_strip -plibgles2-mesa --dbg-package=libgles2-mesa-dbg	
	dh_strip -plibegl1-mesa-drivers-x11 --dbg-package=libegl1-mesa-drivers-x11-dbg
ifeq ($(HAVE_KMS), yes)
	dh_strip -plibegl1-mesa-drivers-kms --dbg-package=libegl1-mesa-drivers-kms-dbg
endif
	dh_strip -s --remaining-packages
	dh_compress -s
	dh_fixperms -s
	dh_makeshlibs -s
	dh_installdeb -s
	dh_shlibdeps -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

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