~ubuntu-branches/ubuntu/quantal/mesa/quantal

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
#!/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
CXXFLAGS = -Wall -g
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
	CXXFLAGS += -O0
else
	CFLAGS += -O2
	CXXFLAGS += -O2
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
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

# keep a list of files we don't install (yet), but since it's a bit
# large, use an external file:
include debian/not-installed

# build the following configurations by default
CONFIGS = dri

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 = \
	CFLAGS="$(CFLAGS)" \
	CXXFLAGS="$(CXXFLAGS)"

DRI_DRIVERS =
GALLIUM_DRIVERS =

# hurd doesn't do direct rendering
ifeq ($(DEB_HOST_ARCH_OS), hurd)
	confflags_DIRECT_RENDERING = --disable-driglx-direct
	confflags_EGL = --disable-egl
	confflags_GALLIUM = --with-gallium-drivers=
	DRI_DRIVERS += swrast
else
	EGL_DISPLAYS = x11

  ifeq ($(DEB_HOST_ARCH_OS), linux)
# Gallium drivers require libdrm-{nouveau,radeon}, only available on Linux
	GALLIUM_DRIVERS += nouveau r600 r300 svga
#
# Although the KMS egl drivers will probably build on kfreebsd & hurd
# only linux actually has KMS drivers implemented at this point.
	EGL_DISPLAYS += drm
# Non-Linux ports also lack *_CLOEXEC and epoll, so wayland isn't ready yet:
	EGL_DISPLAYS += wayland
    ifeq (,$(filter $(DEB_HOST_ARCH), s390 s390x))
	DRI_DRIVERS += r200 radeon nouveau
    endif
    ifneq (,$(filter $(DEB_HOST_ARCH_CPU), amd64 i386))
	DRI_DRIVERS += i915 i965
	# Radeonsi needs LLVM, so only build it on the subset of archs
	# where we have LLVM enabled.
	GALLIUM_DRIVERS += radeonsi
    else
	EXTRA_SED=-e"/radeonsi_dri.so/ s/^/\#/"
    endif
  endif


# Build the llvmpipe driver only on amd64, i386 and armhf until it's tested
# elsewhere
  ifeq (,$(filter $(DEB_HOST_ARCH_CPU), amd64 i386))
	DRI_DRIVERS += swrast
  else
	GALLIUM_DRIVERS += swrast
  endif

  # LLVM is required for r300g and recommended for swrastg on x86:
  ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386 kfreebsd-amd64 kfreebsd-i386))
	confflags_GALLIUM += --enable-gallium-llvm
	confflags_GALLIUM += --with-llvm-shared-libs
  endif

	confflags_DIRECT_RENDERING = --enable-driglx-direct
	confflags_EGL = --with-egl-platforms="$(EGL_DISPLAYS)"
	confflags_GALLIUM += --with-gallium-drivers="$(GALLIUM_DRIVERS)"
	confflags_GLES = --enable-gles1 --enable-gles2
	confflags_OPENVG = --enable-openvg --enable-gallium-egl
endif

confflags-dri = \
	--enable-dri \
	--with-dri-drivers="$(DRI_DRIVERS)" \
	--with-dri-driverdir=/usr/lib/$(DEB_HOST_MULTIARCH)/dri \
	--with-dri-searchpath='/usr/lib/$(DEB_HOST_MULTIARCH)/dri:\$$$${ORIGIN}/dri:/usr/lib/dri' \
	--enable-osmesa \
	--enable-glx-tls \
	--enable-shared-dricore \
	--enable-shared-glapi \
	--enable-texture-float \
	--enable-xa \
	$(confflags_DIRECT_RENDERING) \
	$(confflags_EGL) \
	$(confflags_GALLIUM) \
	$(confflags_GLES) \
	$(confflags_OPENVG) \
	$(confflags-common)

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-stamp

build-stamp: $(BUILD_STAMPS)
	# Build pot file for pkgstriptranslations
	# We do this only once, and outside the build trees, so that
	# pkgstriptranslations doesn't get confused.
	$(MAKE) -C src/mesa/drivers/dri/common/xmlpool pot

	>$@

$(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 \
	             --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
	             --localstatedir=/var $(confflags) $(confflags-$*)
	cd $(DEB_BUILD_DIR)/$* && $(MAKE)

	# Remove extra po files.  These confuse pkgstriptranslations
	# and aren't shipped anyway.
	rm $(DEB_BUILD_DIR)/$*/src/mesa/drivers/dri/common/xmlpool/*.po ; \

	>$@

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 $(filter-out dri, $(CONFIGS)); do \
		$(MAKE) -C $(DEB_BUILD_DIR)/$$config DESTDIR=$(CURDIR)/debian/tmp install; \
	done
	$(MAKE) -C $(DEB_BUILD_DIR)/dri DESTDIR=$(CURDIR)/debian/tmp/dri install
	for file in debian/*.in; \
	do \
		sed -e"s,\$${DEB_HOST_MULTIARCH},$(DEB_HOST_MULTIARCH),g" \
		    $(EXTRA_SED) \
			$${file} > $${file%%.in}; \
	done

clean: unpatch
	dh_testdir
	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 bin/config.guess bin/config.sub config.h.in
	rm -rf $$(find -name Makefile.in)
	rm -rf aclocal.m4 bin/missing bin/depcomp install-sh bin/ltmain.sh
	rm -f bin/ar-lib bin/compile bin/ylwrap bin/install-sh
	rm -rf $(STAMP_DIR)
	for file in debian/*.in; do rm -f $${file%%.in}; done
	rm -f src/glsl/builtins/tools/texture_builtins.pyc
	rm -f src/mapi/glapi/gen/*.pyc
	rm -f src/mesa/main/*.pyc

	# And for pkgstriptranslation's benefit
	rm -f src/mesa/drivers/dri/common/xmlpool/xmlpool.pot

	dh_clean

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

allpkg = $(shell dh_listpackages -s)
dbgpkg = $(filter %-dbg, $(allpkg))
otherpkg = $(filter-out %-dbg, $(allpkg))
havedbgpkg = $(patsubst %-dbg,%,$(dbgpkg))
nodbgpkg = $(filter-out $(havedbgpkg),$(otherpkg))

# Build architecture-dependent files here.
binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs -s
	dh_installchangelogs -pmesa-common-dev
	dh_installdocs -s
	dh_installexamples -s

	# Also get rid of other files which aren't installed. Do not
	# use -f to ensure we notice disappearing files:
	set -e; for file in $(NOT_INSTALLED); do rm debian/tmp/$$file; done
	# Files only in git, not in tarballs, OK to use rm -f here:
	set -e; for file in $(NOT_INSTALLED_EITHER); do rm -f debian/tmp/$$file; done
	# No need for these .so, they're just convenience libraries:
	rm debian/tmp/dri/usr/lib/${DEB_HOST_MULTIARCH}/libglapi.so
	rm debian/tmp/dri/usr/lib/${DEB_HOST_MULTIARCH}/libdricore*.so
#	rm debian/tmp/dri/usr/lib/${DEB_HOST_MULTIARCH}/libgallium*.so
	# purge .la files
	find debian/tmp/ -name '*.la' -exec rm '{}' ';'

	dh_install -s --fail-missing

	# Create an ld.so.conf which says where to find libGL from Mesa
	echo "/usr/lib/$(DEB_HOST_MULTIARCH)/mesa" \
	> $(CURDIR)/debian/libgl1-mesa-glx/usr/lib/$(DEB_HOST_MULTIARCH)/mesa/ld.so.conf

	# Empty directory for the alternative
	mkdir -p $(CURDIR)/debian/libgl1-mesa-glx/usr/lib/$(DEB_HOST_MULTIARCH)/xorg/x11-extra-modules

	# Create an ld.so.conf which says where to find libEGL, libGLES{1,2} 
	# and libOpenVG from Mesa.
	echo "/usr/lib/$(DEB_HOST_MULTIARCH)/mesa-egl" \
	> $(CURDIR)/debian/libegl1-mesa/usr/lib/$(DEB_HOST_MULTIARCH)/mesa-egl/ld.so.conf

	dh_installman -s
	dh_lintian -s
	dh_link -s
	# Install bug control and script:
	set -e; for p in $(allpkg); do \
		install -d debian/$$p/usr/share/bug/$$p && \
		install -m 644 debian/local/control debian/$$p/usr/share/bug/$$p && \
		install -m 755 debian/local/script  debian/$$p/usr/share/bug/$$p; \
	done
	set -e; for p in $(havedbgpkg); do \
		dh_strip -p$${p} --dbg-package=$${p}-dbg; \
	done
	# dh_strip -s --remaining-packages doesn't work with resumed
	# builds (see changelog for mesa 7.10-1):
	dh_strip $(foreach p,$(nodbgpkg),-p$(p))
	dh_compress -s
	dh_fixperms -s
ifeq (,$(filter sparc sparc64,$(DEB_HOST_ARCH)))
	# Resolve EGL/GLES/OpenVG symbols in the private library path.
	# Because there's no packaging problem so onerous that accomodating
	# proprietary alternatives can't make more difficult
	set -e ; for PACKAGE in \
		libegl1-mesa libgles1-mesa libgles2-mesa libopenvg1-mesa ; do \
			dh_makeshlibs -p$$PACKAGE -- -c4 \
			-edebian/$$PACKAGE/usr/lib/$(DEB_HOST_MULTIARCH)/mesa-egl/\* \
		; done

	dh_makeshlibs -s --remaining-packages -- -c4
else
	# Temporarily work around FTBFS on sparc, ignore new symbols:
	dh_makeshlibs -s -- -c1
endif
	dh_installdeb -s
	dh_shlibdeps -s -l/usr/lib/$(DEB_HOST_MULTIARCH)/mesa:\
/usr/lib/$(DEB_HOST_MULTIARCH)/mesa-egl
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s -- -Zxz

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

# For maintainer use only, generate a tarball:
gentarball: SOURCE=mesa
gentarball: UV=$(shell dpkg-parsechangelog|awk '/^Version:/ {print $$2}'|sed 's/-.*$$//')
gentarball:
	git archive --format=tar upstream-experimental --prefix=$(SOURCE)-$(UV)/ | gzip -9 > ../$(SOURCE)_$(UV).orig.tar.gz