summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 6462580616b7071ca8f22ce3b030b37638852974 (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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
#!/usr/bin/make -f

export SHELL = /bin/bash

export DH_VERBOSE=1

export VER=5.0
export OLDVER=4.1

include debian/defs.mk

changelog_values := $(shell dpkg-parsechangelog \
                        | awk '/^(Version|Source|Distribution):/ {print $$2}')
PKGSOURCE := $(word 1, $(changelog_values))
PKGVERSION := $(word 2, $(changelog_values))
PKGDISTRO := $(word 3, $(changelog_values))
PKGFLAVOR := $(shell echo $(PKGSOURCE) | perl -nle 's/mysql-(.*?)-$(PKGDISTRO).*/$$1/ && print ')

soversions := $(shell  awk -F= '/SHARED_LIB_MAJOR_VERSION=/ {print $$2}' configure.in)

export MYSOVER=$(word 1, $(soversions))
export NDBSOVER=$(word 2, $(soversions))

ifeq ("x$(MYSQL_FLAVOR)","x")
  export MYSQL_FLAVOR=$(PKGFLAVOR)
endif

ifeq ("x$(MYSQL_FLAVOR)","x")
  export MYVER=$(VER)
  export MYOLDVER=$(OLDVER)
  export MYSRCVER=$(MYVER)
else
  export MYVER=$(MYSQL_FLAVOR)-$(VER)
  export MYOLDVER=$(MYSQL_FLAVOR)-$(OLDVER)
  export MYSRCVER=$(MYSQL_FLAVOR)-$(PKGDISTRO)-$(VER)
endif

PACKAGE=mysql-$(MYVER)

PWD=$(shell pwd)
TMP=$(PWD)/debian/tmp/


ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)

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

MAKE_J = $(shell if grep -q processor.*3 /proc/cpuinfo; then echo "-j 4"; else echo ""; fi )

ifeq ($(findstring $(ARCH),i386 sparc),$(ARCH))
    USE_ASSEMBLER=--enable-assembler 
endif

ifeq ($(findstring $(ARCH), arm),$(ARCH))
    FOMIT_FRAME_POINTER=
else
    FOMIT_FRAME_POINTER=-fomit-frame-pointer
endif

# trying to raise stability on i386. See #116631
# don't use it on ia64
ifeq ($(findstring $(ARCH),i386),$(ARCH))
  FNO_EXCEPTIONS=-fno-exceptions
endif

# This causes seg11 crashes if LDAP is used for groups in /etc/nsswitch.conf
# so it is disabled by default although, according to MySQL, it brings >10%
# performance gain if enabled. See #299382.
ifeq ($(STATIC_MYSQLD), 1)
    USE_STATIC_MYSQLD=--with-mysqld-ldflags=-all-static
endif



control-file:
	@echo "## This file is autogenerated you want to edit control.in instead" > debian/control.tmp
	sed -e "s/@MYVER@/$(MYVER)/g" \
	    -e "s/@VER@/$(VER)/g" \
	    -e "s/@VERSIONSTRING@/$(VERSIONSTRING)/g" \
	    -e "s/@MYOLDVER@/$(MYOLDVER)/g" \
	    -e "s/@MYSRCVER@/$(MYSRCVER)/g" \
	    -e "s/@MYSOVER@/$(MYSOVER)/g" \
	    -e "s/@NDBSOVER@/$(NDBSOVER)/g" \
		debian/control.in >> debian/control.tmp
	[ -e debian/control ] \
	  && cmp -s debian/control debian/control.tmp \
	  && rm -f debian/control.tmp && exit 0; \
	  mv debian/control.tmp debian/control


missing:
	./BUILD/autorun.sh 

configure: configure-stamp
configure-stamp:
	@echo "RULES.configure-stamp"
	dh_testdir

ifneq ($(ARCH_OS),hurd)
	@if [ ! -d /proc/self ]; then echo "/proc IS NEEDED" 1>&2; exit 1; fi 
endif

	( \
	CC="$(MYSQL_BUILD_CC)"  \
	CXX="$(MYSQL_BUILD_CXX)" \
	BUILD_OPTS="${MYSQL_BUILD_OPTS:-''}"  \
	CFLAGS="${MYSQL_BUILD_CFLAGS:-'-DBIG_JOINS=1 -O2'}" \
	CXXFLAGS="${MYSQL_BUILD_CXXFLAGS:-'-DBIG_JOINS=1 -felide-constructors -fno-rtti -O2'}" \
	./configure \
		--build=${DEB_BUILD_GNU_TYPE} \
		--host=${DEB_HOST_GNU_TYPE} \
		\
		--prefix=/usr \
	        --exec-prefix=/usr \
	        --libexecdir=/usr/sbin \
	        --datadir=/usr/share \
	        --localstatedir=/var/lib/mysql \
	        --includedir=/usr/include \
	        --infodir=/usr/share/info \
	        --mandir=/usr/share/man \
		\
		--with-comment="MySQL Server (custom build)" \
		--with-server-suffix="-custom" \
		\
		--enable-shared \
		--enable-thread-safe-client \
	        $(USE_ASSEMBLER) \
		--enable-local-infile \
		\
                --with-big-tables \
		--with-unix-socket-path=/var/run/mysqld/mysqld.sock \
	       	--with-mysqld-user=mysql \
		$(USE_STATIC_MYSQLD) \
		--without-bench \
		--with-zlib-dir=bundled \
		--with-yassl \
		--with-readline \
		--with-extra-charsets=all \
		--with-innodb \
                --with-blackhole-storage-engine \
                --with-example-storage-engine \
		\
		--with-isam \
		--with-archive-storage-engine \
		--with-csv-storage-engine \
		--with-federated-storage-engine \
		--without-embedded-server \
		--with-ndbcluster \
		--with-ndb-shm \
		--without-ndb-sci \
		--without-ndb-test \
		--with-ndb-docs \
		$(MYSQL_BUILD_OPTS) \
	)

	touch configure-stamp


build: build-stamp
build-stamp: configure
	dh_testdir

	$(MAKE) $(MAKE_J)

	if [ -f sql/.libs/mysqld ] ; then \
		nm --numeric-sort sql/.libs/mysqld > sql/mysqld.sym ; \
	else \
		nm --numeric-sort sql/mysqld > sql/mysqld.sym ; \
	fi


	if [ "${MYSQL_BUILD_TEST}" != "no" ] ; then \
	  ( cd mysql-test ;\
	    MTR_BUILD_THREAD=auto ; \
	    export MTR_BUILD_THREAD ; \
            perl ./mysql-test-run.pl --force --report-features ; \
            perl ./mysql-test-run.pl --force --ps-protocol ; \
            true ) \
	fi


	touch build-stamp

stamp-control:
	# We have to prepare the various control files

	# We have some naming inconsistencies here... 
	for f in debian/*.in debian/po/POTFILES.in.in ; do \
            f2=`echo $$f | sed "s,MYVER,$(MYVER),g;\
                                s,MYSRCVER,$(MYSRCVER),g;\
                                s,MYOLDVER,$(MYOLDVER),g;\
                                s,NDBSOVER,$(NDBSOVER),g;\
                                s,MYSOVER,$(MYSOVER),g;s,\.in$$,,"`; \
            if [ $$f2 != debian/control ]; then \
                sed -e "s/@MYVER@/$(MYVER)/g" \
		    -e "s/@VERSIONSTRING@/$(VERSIONSTRING)/g" \
		    -e "s/@VER@/$(VER)/g" \
                    -e "s/@PRIORITY@/$(PRIORITY)/g" \
		    -e "s/@MYOLDVER@/$(MYOLDVER)/g" \
		    -e "s/@MYSRCVER@/$(MYSRCVER)/g" \
		    -e "s/@MYSOVER@/$(MYSOVER)/g" \
		    -e "s/@NDBSOVER@/$(NDBSOVER)/g" \
                    -e "s,@SCRIPTDIR@,/$(scriptdir),g" \
                    -e "s,@INFO@,$(findstring info, $(doc_dependencies)),g" \
                  <$$f >$$f2; \
            fi; \
        done

# depending on two files we expect to be in the root
# to protect from accidentally deleting a whole bunch of 
# files somewhere else.
clean: configure.in Makefile.am control-file

	rm -f debian/mysql-server-$(MYVER).mysql.init

	# We depend on this later, and delete the results in the mean time
	$(MAKE) -f debian/rules stamp-control
	dh_testdir 
	dh_testroot
	rm -f configure-stamp
	rm -f build-stamp

	-make distclean

	debconf-updatepo

	for f in debian/*.in; do \
            f2=`echo $$f | sed "s,MYVER,$(MYVER),g;\
                                s,MYOLDVER,$(MYOLDVER),g;\
                                s,MYSRCVER,$(MYSRCVER),g;\
                                s,NDBSOVER,$(NDBSOVER),g;\
                                s,MYSOVER,$(MYSOVER),g;s,\.in$$,,"`; \
            if [ $$f2 != debian/control ]; then \
		rm -f $$f2; \
            fi; \
        done
	rm -f po/POTFILES.in

	dh_clean -v


install:
install: build stamp-control
	@echo "RULES.install"
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Sort of hackish way to make sure we have a init script 
	# for dh_installinit
	cp support-files/mysql.server debian/mysql-server-$(MYVER).mysql.init

	# some self written manpages which hopefully
	# gets overwritten sooner or later with upstreams
	mkdir -p $(TMP)/usr/share/man/man1/
	mkdir -p $(TMP)/usr/share/man/man8/
	mkdir -p $(TMP)/usr/lib/mysql/mysqld.sym
	cp debian/additions/*.1 $(TMP)/usr/share/man/man1/
	ln -s mysqlmanager.1 $(TMP)/usr/share/man/man1/mysqlmanager-pwgen.1
	ln -s mysqlmanager.1 $(TMP)/usr/share/man/man1/mysqlmanagerc.1
	cp sql/mysqld.sym $(TMP)/usr/lib/mysql/mysqld.sym

	# TODO: need real man pages!
	for f in mysql mysqldump mysqlaccess mysqladmin mysqlshow myisam_ftdump myisamlog myisampack mysql_explain_log mysqld_multi mysqld_safe mysql_fix_privilege_tables mysql_upgrade mysql_tzinfo_to_sql mysql_zap perror replace safe_mysqld ; do touch $(TMP)/usr/share/man/man1/$$f.1 ; done
	for f in mysqld mysqlmanager ; do touch $(TMP)/usr/share/man/man8/$$f.8 ; done
	# make install (trailing slash needed for innobase)
	$(MAKE) install DESTDIR=$(TMP)/

	# After installing, remove rpath to make lintian happy.
	set +e; \
	find ./debian/tmp/ -type f -print0 \
		| xargs -0 --no-run-if-empty chrpath -k 2>/dev/null \
		| fgrep RPATH= \
		| cut -d: -f 1 \
		| xargs --no-run-if-empty chrpath -d; \
	set -e

	# libmysqlclient: move shared libraries (but not the rest like libheap.a & co)
	mv $(TMP)/usr/lib/mysql/libmysqlclient* $(TMP)/usr/lib
	mv $(TMP)/usr/lib/mysql/libndbclient* $(TMP)/usr/lib
	perl -pi -e 's#/usr/lib/mysql#/usr/lib#' $(TMP)/usr/lib/libmysqlclient.la
	perl -pi -e 's#/usr/lib/mysql#/usr/lib#' $(TMP)/usr/lib/libmysqlclient_r.la
	perl -pi -e 's#/usr/lib/mysql#/usr/lib#' $(TMP)/usr/lib/libndbclient.la

	# Check if our beloved versioned symbols are really there
	if [ "`objdump -T $(TMP)/usr/lib/libmysqlclient.so.15.0.0 | grep -c libmysqlclient_15`" -lt 500 ]; then \
	  echo "ERROR: versioned symbols are absent"; \
	  exit 1; \
	fi     
	if [ "`objdump -T $(TMP)/usr/lib/libndbclient.so.2.0.0 | grep -c libndbclient_2`" -lt 500 ]; then \
          echo "ERROR: versioned symbols are absent from libndbclient"; \
          exit 1; \
        fi

	# libmysqlclient-dev: forgotten header file since 3.23.25?
	cp include/my_config.h $(TMP)/usr/include/mysql/
	cp include/my_dir.h $(TMP)/usr/include/mysql/

	# mysql-common: We now provide our own config file.
	install -d $(TMP)/etc/mysql
	install -m 0644 debian/additions/my.cnf $(TMP)/etc/mysql/my.cnf

	pod2man scripts/mysqlhotcopy $(TMP)/usr/share/man/man1/mysqlhotcopy.1

	# mysql-server
	install -m 0755 scripts/mysqld_safe $(TMP)/usr/bin/mysqld_safe
	mkdir -p $(TMP)/usr/share/doc/mysql-server-$(MYVER)/examples
	mv $(TMP)/usr/share/mysql/*cnf 	    $(TMP)/usr/share/doc/mysql-server-$(MYVER)/examples/
	rm -vf $(TMP)/usr/share/mysql/mi_test_all* \
	       $(TMP)/usr/share/mysql/mysql-log-rotate \
	       $(TMP)/usr/share/mysql/mysql.server \
	       $(TMP)/usr/share/mysql/binary-configure

	# we can't install *.pl into /usr/bin - so we have to rename it.
	sed "s#filename => 'ndb_size.tmpl#filename => '/usr/share/mysql/ndb_size.tmpl#" < $(TMP)/usr/bin/ndb_size.pl > $(TMP)/usr/bin/ndb_size
	cp -a mysql-test $(TMP)/usr/share/mysql/
	cp -a sql-bench $(TMP)/usr/share/mysql/
	# lintian overrides
	mkdir -p $(TMP)/usr/share/lintian/overrides/
	cp debian/mysql-server-$(MYVER).lintian-overrides $(TMP)/usr/share/lintian/overrides/mysql-server-$(MYVER)
	cp debian/mysql-client-$(MYVER).lintian-overrides $(TMP)/usr/share/lintian/overrides/mysql-client-$(MYVER)

	# For 4.1 -> 5.0 transition
	d=$(TMP)/usr/share/mysql-common/internal-use-only/; \
	mkdir -p $$d; \
	cp debian/mysql-server-$(MYVER).mysql.init $$d/_etc_init.d_mysql; \
	cp debian/mysql-server-$(MYVER).mysql-server.logrotate $$d/_etc_logrotate.d_mysql-server; \

	dh_movefiles

# Build architecture-independent files here.
binary-indep: build install
	@echo "RULES.binary-indep"
	dh_testdir -i
	dh_testroot -i
	dh_installdebconf -i
	dh_installdocs -i
	dh_installexamples -i
	dh_installmenu -i
	dh_installlogrotate -i
	dh_installinit -i
	dh_installcron -i 
	dh_installman -i
	dh_installinfo -i
	dh_installlogcheck -i
	dh_installchangelogs -i
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_perl -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	@echo "RULES.binary-arch"
	dh_testdir 
	dh_testroot

	dh_installdebconf -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
	dh_installlogrotate -a --name mysql-server
	# Start mysql in runlevel 19 before 20 where apache, proftpd etc gets
	# started which might depend on a running database server.
	dh_installinit -a --name=mysql-storage 	-- defaults 19 21
	dh_installinit -a --name=mysql		-- defaults 19 21
	dh_installinit -a --name=mysql-management 	-- defaults 20
	dh_installcron -a --name mysql-server
	dh_installman -a
	dh_installinfo -a
	dh_installlogcheck -a
	dh_installchangelogs -a
	dh_strip -a
	dh_link -a	# .so muss nach .so.1.2.3 installier werden!
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_makeshlibs -plibmysqlclient$(MYSOVER) -V"libmysqlclient$(MYSOVER) (>= $(PKGVERSION))"
	dh_makeshlibs -plibndbclient$(NDBSOVER) -V"libndbclient2 (>= $(PKGVERSION))"
	dh_installdeb -a
	dh_perl -a
	dh_shlibdeps -a -l debian/libmysqlclient$(MYSOVER)/usr/lib -L libmysqlclient$(MYSOVER)
	dh_shlibdeps -a -l debian/libndbclient$(NDBSOVER)/usr/lib -L libndbclient$(NDBSOVER)
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary:	binary-indep binary-arch
.PHONY: clean stamp-control control-file configure build binary binary-indep binary-arch install 

# vim: ts=8