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

export DH_OPTIONS
export DEB_HOST_ARCH

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

STAMPDIR := debian/stamp

select_target_any = $(shell dh_listpackages -s | grep -v '^$$' | while read p ; do cut -d ' ' -f 1,3 debian/libdir.map | grep -w $$p ; done | grep -v _ | cut -d ' ' -f 1 | sort -u | grep ^$(1)- | cut -d - -f 2-)
select_target_arch = $(filter $(shell dh_listpackages -s | grep -v '^$$' | while read p ; do cut -d ' ' -f 1,3 debian/libdir.map | grep -w $$p ; done | grep _ | cut -d ' ' -f 1 | sort -u | grep ^$(1)- | cut -d - -f 2-), $(patsubst configs/%, %, $(wildcard configs/*_$(DEB_HOST_ARCH))))
select_target = $(sort $(BUILD_$(1)_TARGETS_any) $(BUILD_$(1)_TARGETS_arch))

BUILD_GL_TARGETS_any := $(call select_target_any,gl)
BUILD_GL_TARGETS_arch := $(call select_target_arch,gl)
BUILD_GL_TARGETS := $(call select_target,GL)

BUILD_GLU_TARGETS_any := $(call select_target_any,glu)
#BUILD_GLU_TARGETS_arch := $(call select_target_arch,glu)
BUILD_GLU_TARGETS := $(call select_target,GLU)

BUILD_GLW_TARGETS_any := $(call select_target_any,glw)
#BUILD_GLW_TARGETS_arch := $(call select_target_arch,glw)
BUILD_GLW_TARGETS := $(call select_target,GLW)

BUILD_TARGETS := \
	$(foreach t, $(BUILD_GL_TARGETS), $(STAMPDIR)/target-gl-$(t)) \
	$(foreach t, $(BUILD_GLU_TARGETS), $(STAMPDIR)/target-glu-$(t)) \
	$(foreach t, $(BUILD_GLW_TARGETS), $(STAMPDIR)/target-glw-$(t))

ifneq ($(strip $(shell grep-dctrl -n -s Package -PX libgl1-mesa-directfb debian/control)),)
DFB_MODULE_DIR := $(shell pkg-config --variable=moduledir directfb-internal)
endif

build: $(STAMPDIR)/build
$(STAMPDIR)/build: $(BUILD_TARGETS)
	dh_testdir
	mkdir -p $(dir $@) && touch $@

# Parameters:
#     1: library (gl, glu, glw)
#     2: target (debian, debian-i386, ...)
#     3: subdir to build (mesa, glw, glu/sgi)

driver_map = $(word $(2),$(shell grep '^$(1) ' debian/drivers.map))
libdir_map = $(word $(2),$(shell grep '^$(1) ' debian/libdir.map))

define build_target_actions
	dh_testdir
	chmod +x debian/shadowtree
	$(RM) -rf build/$(1)-$(2)
	debian/shadowtree build/$(1)-$(2)
	ln -sf $(2) build/$(1)-$(2)/configs/current
	if test $(1) != gl ; then \
		mkdir -p build/$(1)-$(2)/lib/ ; \
		ln -sf ../../gl-$(2)/lib/libGL.so build/$(1)-$(2)/lib/ ; \
	fi
	make -C build/$(1)-$(2)/src SRC_DIRS=$(3) DEBIAN_DRIVERS_DIR=$(if $(call driver_map,$(1)-$(2),1),/$(call driver_map,$(1)-$(2),3))
	if test $(1) != gl ; then \
		rm build/$(1)-$(2)/lib/libGL.so ; \
	fi
	mkdir -p $(dir $@) && touch $@
endef

$(STAMPDIR)/target-gl-%:
	$(call build_target_actions,gl,$*,mesa)

$(STAMPDIR)/target-glu-%: $(STAMPDIR)/target-gl-%
	$(call build_target_actions,glu,$*,glu/sgi)

$(STAMPDIR)/target-glw-%: $(STAMPDIR)/target-gl-%
	$(call build_target_actions,glw,$*,glw)

# Parameters:
#     1: target (gl-debian, gl-debian-i386, ...)
#     2: installation directory (usr/lib, usr/lib/dbg, ...)
#     3: library package name
#     4: development package name

define install_target_lib_actions
	dh_installdirs -p$(3) $(2)
	dh_installdirs -p$(4) $(2)
	dh_install -p$(3) build/$(1)/lib/lib*.so.* $(2)
	dh_install -p$(4) build/$(1)/lib/lib*.so $(2)
	dh_install -p$(4) build/$(1)/lib/lib*.a $(2)
endef

install_target_libs = $(call install_target_lib_actions,$(1),$(call libdir_map,$(1),2),$(call libdir_map,$(1),3),$(call libdir_map,$(1),4))

# Parameters:
#     1: target (gl-debian, gl-debian-i386, ...)
#     2: source directory (usr/lib, usr/lib/dbg, ...)
#     3: installation directory (usr/lib, usr/lib/dbg, ...)
#     4: package name

define install_target_driver_actions
	dh_installdirs -p$(4) $(3)
	dh_install -p$(4) build/$(1)/$(2) $(3)
endef

install_target_drivers = $(if $(call driver_map,$(1),1),$(call install_target_driver_actions,$(1),$(call driver_map,$(1),2),$(call driver_map,$(1),3),$(call driver_map,$(1),4)))

# Parameters:
#     1: target (gl-debian, gl-debian-i386, ...)

define install_target
	$(call install_target_libs,$(1))
	$(call install_target_drivers,$(1))
endef

install-target-%: $(STAMPDIR)/target-%
	@echo Target $@.
	$(call install_target,$*)
	@echo Target $@: done.

install-pre:
	@echo Target $@.
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	@echo Target $@: done.

install-all: install-pre \
	$(addprefix install-target-gl-,$(BUILD_GL_TARGETS)) \
	$(addprefix install-target-glu-,$(BUILD_GLU_TARGETS)) \
	$(addprefix install-target-glw-,$(BUILD_GLW_TARGETS))
	@echo Target $@.
	@echo Target $@: done.

clean:
	dh_testdir
	dh_testroot
	$(RM) -rf debian/stamp
	$(RM) -rf build
	dh_clean debian/mesa-swx11-source.install

install: build install-all
	@echo Target $@.
	@echo Target $@: done.

binary-indep: DH_OPTIONS := -i
binary-indep: debian/mesa-swx11-source.install build
	@echo Target $@
	dh_testdir
	dh_testroot
	dh_installchangelogs docs/VERSIONS
	dh_installdocs
	dh_installdirs
#	dh_installexamples
	dh_install
#	dh_installman
#	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb
	@echo Target $@: done.

# binary-arch: DH_OPTIONS := -s
binary-arch: build install
	@echo Target $@
	dh_testdir -s
	dh_testroot -s
	dh_installchangelogs -s docs/VERSIONS
	dh_installdocs -s
#	dh_installexamples -s
	dh_install -s
#	dh_installman -s
#	dh_link -s
	dh_strip -s
	dh_compress -s
	dh_fixperms -s
#	dh_makeshlibs -s -Nlibglu1-mesa -Nmesag3
ifneq ($(strip $(shell dh_listpackages -s | grep -w libgl1-mesa-glide3)),)
	dh_makeshlibs -plibgl1-mesa-glide3 -V 'libgl1-mesa-glide3'
endif
ifneq ($(strip $(shell dh_listpackages -s | grep -w libglu1-mesa)),)
	dh_makeshlibs -plibglu1-mesa -V 'libglu1-mesa | libglu1'
endif
ifneq ($(strip $(shell dh_listpackages -s | grep -w libosmesa6)),)
	dh_makeshlibs -plibosmesa6
endif
ifneq ($(strip $(shell dh_listpackages -s | grep -w libgl1-mesa-swx11)),)
	dh_makeshlibs -plibgl1-mesa-swx11
endif
ifneq ($(strip $(shell dh_listpackages -s | grep -w libgl1-mesa-glx)),)
	dh_makeshlibs -plibgl1-mesa-glx -V 'libgl1-mesa-glx | libgl1'
endif
ifneq ($(strip $(shell dh_listpackages -s | grep -w libgl1-mesa-directfb)),)
	dh_makeshlibs -plibgl1-mesa-directfb -V 'libgl1-mesa-directfb | libgl1'
endif
# Make sure nothing has been left behind.
	find debian -mindepth 2 -name shlibs | cut -d / -f 2 | sort -u > \
		debian/shlibs.actual
	find debian -mindepth 2 -name lib\*.so.\* | grep -v dbg | cut -d / -f 2 | sort -u > \
		debian/shlibs.should
	cmp debian/shlibs.actual debian/shlibs.should
	rm debian/shlibs.actual debian/shlibs.should
	dh_installdeb -s
	dh_shlibdeps -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s
	@echo Target $@: done.

list-targets:
	@for t in $(BUILD_GL_TARGETS_arch) ; do echo $$t ; done

debian/mesa-swx11-source.install:
	( find src/mesa src/glx/x11 include/GL/internal -name '*.[ch]' ; \
	  find include/GL -name 'xmesa*' ) | \
	egrep -v 'drivers/(dri/(fb|ffb|gamma|i[a-z0-9]+|mach64|mga|r[0-9]+|radeon|s3v|savage|sis|tdfx|trident|unichrome)|directfb|dos|fbdev|ggi|glide|osmesa|svga|windows)/' | \
	while read x; do echo $$x usr/share/mesa-source/`dirname $$x`; done \
	> $@

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure debian/mesa-swx11-source.install