prepare 5.6.0~rc2+dfsg-5 release
[pkg-php/php.git] / debian / rules
1 #!/usr/bin/make -f
2 # Sample debian/rules that uses debhelper. 
3 # GNU copyright 1997 by Joey Hess.
4 #
5 # This version is for a hypothetical package that builds an
6 # architecture-dependant package, as well as an architecture-independent
7 # package.
8
9 # Uncomment this to turn on verbose mode. 
10 #export DH_VERBOSE=1
11
12 # This has to be exported to make some magic below work.
13 export DH_OPTIONS
14
15 # Set this flag to 'yes' if you want to disable all modifications breaking abi 
16 # compatibility to upstream
17 PHP5_COMPAT=no
18
19 DEB_HOST_GNU_TYPE    ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
20 DEB_BUILD_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
21 DEB_HOST_ARCH   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
22
23 PHP5_SOURCE_VERSION   = $(shell dpkg-parsechangelog | grep ^Version | sed "s/Version: //")
24 PHP5_UPSTREAM_VERSION = $(shell echo $(PHP5_SOURCE_VERSION) | sed -e "s/-.*//" -e "s/.*://")
25 PHP5_DEBIAN_REVISION  = $(shell echo $(PHP5_SOURCE_VERSION) | sed "s/.*-//")
26
27 MYSQL_PORT := $(shell for i in $$(seq 1025 3600); do nc -z localhost $$i || { echo $$i; exit; } ; done)
28 MYSQL_DATA_DIR ?= $(shell readlink -f mysql_db)
29 ifeq (,$(MYSQL_PORT))
30     $(error Could not find available port for mysql server)
31 endif
32 MYSQL_SOCKET = $(MYSQL_DATA_DIR)/mysql.sock
33
34 # specify some options to our patch system
35 QUILT_DIFF_OPTS=-p
36 QUILT_NO_DIFF_TIMESTAMPS=1 
37 export QUILT_DIFF_OPTS QUILT_NO_DIFF_TIMESTAMPS
38
39 PROG_SENDMAIL = /usr/sbin/sendmail
40 ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
41   CFLAGS += -O2
42 else
43   CFLAGS += -O0
44 endif
45 CFLAGS += -Wall -fsigned-char -fno-strict-aliasing 
46 # LFS support
47 ifneq (yes,$(PHP5_COMPAT))
48   CFLAGS += $(shell getconf LFS_CFLAGS)
49 endif
50
51 # Enable IEEE-conformant floating point math on alphas (not the default)
52 ifeq (alpha-linux-gnu,$(DEB_HOST_GNU_TYPE))
53   CFLAGS += -mieee
54 endif
55
56 ifeq ($(DEB_HOST_GNU_TYPE), $(findstring $(DEB_HOST_GNU_TYPE), ia64-linux-gnu powerpc64-linux-gnu avr32-linux-gnu))
57   CFLAGS += -g
58 else
59   CFLAGS += -gstabs
60 endif
61
62 # some other helpful (for readability at least) shorthand variables
63 PHPIZE_BUILDDIR = debian/php5-dev/usr/lib/php5/build
64
65 # support new (>= 2.2) and older versions of libtool for backporting ease
66 LIBTOOL_DIRS = /usr/share/libtool/config /usr/share/libtool
67 LTMAIN = $(firstword $(wildcard $(foreach d,$(LIBTOOL_DIRS),$d/ltmain.sh)))
68 LTMAIN_DIR = $(dir $(LTMAIN))
69
70 ifeq ($(LTMAIN_DIR), /usr/share/libtool/)
71 LIBTOOL_CONFLICTS:=libtool (>= 2.2)
72 else ifeq ($(LTMAIN_DIR), /usr/share/libtool/config/)
73 LIBTOOL_CONFLICTS:=libtool (<< 2.2)
74 else
75 LIBTOOL_CONFLICTS:=$(error "could not resolve path to ltmain.sh")
76 endif
77
78 # only enable interbase support on archs where it is supported
79 ifneq (,$(filter $(DEB_HOST_ARCH),amd64 armel armhf i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mipsel powerpc s390 sparc))
80         IBFLAGS=--with-interbase=shared,/usr \
81                 --with-pdo-firebird=shared,/usr
82 endif
83
84 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
85     NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
86     MAKEFLAGS += -j$(NUMJOBS)
87 endif
88
89 # enable the hardening wrapper
90 DEB_BUILD_HARDENING = 1
91 # but disable PIE
92 DEB_BUILD_HARDENING_PIE = 0
93 export DEB_BUILD_HARDENING DEB_BUILD_HARDENING_PIE
94
95 COMMON_CONFIG=--build=$(DEB_BUILD_GNU_TYPE) \
96                 --host=$(DEB_HOST_GNU_TYPE) \
97                 --sysconfdir=/etc \
98                 --localstatedir=/var \
99                 --mandir=/usr/share/man \
100                 --disable-debug \
101                 --with-regex=php \
102                 --disable-rpath \
103                 --disable-static \
104                 --with-pic \
105                 --with-layout=GNU \
106                 --with-pear=/usr/share/php \
107                 --enable-calendar \
108                 --enable-sysvsem \
109                 --enable-sysvshm \
110                 --enable-sysvmsg \
111                 --enable-bcmath \
112                 --with-bz2 \
113                 --enable-ctype \
114                 --with-db4 \
115                 --with-qdbm=/usr \
116                 --without-gdbm \
117                 --with-iconv \
118                 --enable-exif \
119                 --enable-ftp \
120                 --with-gettext \
121                 --enable-mbstring \
122                 --with-onig=/usr \
123                 --with-pcre-regex=/usr \
124                 --enable-shmop \
125                 --enable-sockets \
126                 --enable-wddx \
127                 --with-libxml-dir=/usr \
128                 --with-zlib \
129                 --with-kerberos=/usr \
130                 --with-openssl=/usr \
131                 --enable-soap \
132                 --enable-zip \
133                 --with-mhash=yes \
134                 --with-exec-dir=/usr/lib/php5/libexec \
135                 --with-system-tzdata
136
137 BUILTIN_EXTENSION_CHECK=$$e=get_loaded_extensions(); natcasesort($$e); \
138                         $$s="The following extensions are built in:"; \
139                         foreach($$e as $$i) { $$s .= " $$i"; } \
140                         echo("php:Extensions=" . wordwrap($$s . ".\n", 75, "\$${Newline} "));
141
142 # include the patch/unpatch rules from quilt
143 include /usr/share/quilt/quilt.make
144
145 prepared: prepared-stamp
146 prepared-stamp: $(QUILT_STAMPFN)
147         dh_testdir
148         sed -i -e 's/EXTRA_VERSION=""/EXTRA_VERSION="-$(PHP5_DEBIAN_REVISION)"/' configure.in
149         ./buildconf --force
150         touch prepared-stamp
151
152 unprepared:
153         dh_testdir
154         sed -i -e 's/EXTRA_VERSION="-$(PHP5_DEBIAN_REVISION)"/EXTRA_VERSION=""/' configure.in
155         rm -f prepared-stamp
156
157 test-results.txt: build-apache2-stamp build-cli-stamp build-cgi-stamp
158 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
159         mkdir -p temp_session_store
160         # start our own mysql server for the tests
161         $(SHELL) debian/setup-mysql.sh $(MYSQL_PORT) $(MYSQL_DATA_DIR)
162         extensions=""; \
163         for f in $(CURDIR)/apache2-build/modules/*.so; do \
164             ext=`basename "$$f"`; \
165             test -d "$(CURDIR)/ext/$${ext%.so}/tests" || continue; \
166             test "$$ext" != "imap.so" || continue; \
167             test "$$ext" != "interbase.so" || continue; \
168             test "$$ext" != "ldap.so" || continue; \
169             test "$$ext" != "odbc.so" || continue; \
170             test "$$ext" != "pgsql.so" || continue; \
171             test "$$ext" != "pdo_dblib.so" || continue; \
172             test "$$ext" != "pdo_firebird.so" || continue; \
173             test "$$ext" != "pdo_odbc.so" || continue; \
174             test "$$ext" != "pdo_pgsql.so" || continue; \
175             test "$$ext" != "snmp.so" || continue; \
176             extensions="$$extensions -d extension=$$ext"; \
177         done; \
178         [ "$$extensions" ] || { echo "extensions list is empty"; exit 1; }; \
179         env MYSQL_TEST_PORT=$(MYSQL_PORT) MYSQL_TEST_SOCKET=$(MYSQL_SOCKET) PDO_MYSQL_TEST_PORT=$(MYSQL_PORT) PDO_MYSQL_TEST_SOCKET=$(MYSQL_SOCKET) NO_INTERACTION=1 TEST_PHP_CGI_EXECUTABLE=$(CURDIR)/cgi-build/sapi/cgi/cgi-bin.php5 TEST_PHP_EXECUTABLE=$(CURDIR)/cli-build/sapi/cli/php \
180         $(CURDIR)/cli-build/sapi/cli/php run-tests.php -d mysql.default_socket=$(MYSQL_SOCKET) -d mysqli.default_socket=$(MYSQL_SOCKET) -d extension_dir=$(CURDIR)/apache2-build/modules/ $$extensions| tee test-results.txt
181         rm -rf temp_session_store
182         @for test in `find . -name '*.log' -a '!' -name 'config.log' -a '!' -name 'bootstrap.log' -a '!' -name 'run.log'`; do \
183             echo; \
184             echo -n "$${test#./}:"; \
185             cat $$test; \
186             echo; \
187         done | tee -a test-results.txt
188         $(SHELL) debian/setup-mysql.sh $(MYSQL_PORT) $(MYSQL_DATA_DIR) stop
189 else
190         echo 'nocheck found in DEB_BUILD_OPTIONS' | tee test-results.txt
191 endif
192
193 build: build-apache2-stamp build-apache2filter-stamp build-cgi-stamp build-cli-stamp build-fpm-stamp build-pear-stamp test-results.txt
194
195 build-apache2-stamp: configure-apache2-stamp
196         dh_testdir
197         cd apache2-build && $(MAKE)
198
199         touch build-apache2-stamp
200
201 build-apache2filter-stamp: configure-apache2filter-stamp
202         dh_testdir
203         cd apache2filter-build && $(MAKE)
204
205         touch build-apache2filter-stamp
206
207 build-cli-stamp: configure-cli-stamp
208         dh_testdir
209         cd cli-build && $(MAKE)
210
211         touch build-cli-stamp
212
213 build-fpm-stamp: configure-fpm-stamp
214         dh_testdir
215         cd fpm-build && $(MAKE)
216
217         touch build-fpm-stamp
218
219
220 build-cgi-stamp: configure-cgi-stamp
221         dh_testdir
222         cd cgi-build && $(MAKE) && mv sapi/cgi/php-cgi sapi/cgi/cgi-bin.php5
223
224         # Dirty hack to not rebuild everything twice
225         cd cgi-build/main && \
226                 sed -i -e 's/FORCE_CGI_REDIRECT 1/FORCE_CGI_REDIRECT 0/' \
227                        -e 's/DISCARD_PATH 0/DISCARD_PATH 1/' php_config.h && \
228                 sed -i -e 's/--enable-force-cgi-redirect/--enable-discard-path/' build-defs.h && \
229                 touch ../../ext/standard/info.c && \
230                 touch ../../sapi/cgi/cgi_main.c
231
232         cd cgi-build && $(MAKE) && mv sapi/cgi/php-cgi sapi/cgi/usr.bin.php5-cgi
233
234         touch build-cgi-stamp
235
236 build-pear-stamp: build-cgi-stamp
237         dh_testdir
238         -mkdir pear-build
239         -mkdir pear-build-download
240         cd cgi-build && PHP_PEAR_DOWNLOAD_DIR=$(CURDIR)/pear-build-download $(MAKE) install-pear PHP_PEAR_PHP_BIN=/usr/bin/php PHP_PEAR_INSTALL_DIR=/usr/share/php PHP_PEAR_SYSCONF_DIR=/etc/pear PHP_PEAR_SIG_BIN=/usr/bin/gpg INSTALL_ROOT=$(CURDIR)/pear-build
241         sed -i -e 's/-d output_buffering=1 -d open_basedir="" -d safe_mode=0/-d output_buffering=1 -d open_basedir="" -d safe_mode=0 -d memory_limit="-1"/' \
242                $(CURDIR)/pear-build/usr/bin/pear && \
243         sed -i -e 's/-d output_buffering=1 -d safe_mode=0/-d output_buffering=1 -d open_basedir="" -d safe_mode=0 -d memory_limit="-1"/' \
244                $(CURDIR)/pear-build/usr/bin/pecl && \
245         sed -i -e 's/-d memory_limit="-1"//' \
246                -e 's/-d output_buffering=1 -d open_basedir="" -d safe_mode=0/-d output_buffering=1 -d open_basedir="" -d safe_mode=0 -d memory_limit="-1"/' \
247                $(CURDIR)/pear-build/usr/bin/peardev
248         sed -i -re "s#('PEAR_CONFIG_SYSCONFDIR', PHP_SYSCONFDIR)#\1 . '/pear'#" $(CURDIR)/pear-build/usr/share/php/PEAR/Config.php
249         touch build-pear-stamp
250
251 configure: configure-apache2-stamp configure-apache2filter-stamp configure-cli-stamp configure-fpm-stamp configure-cgi-stamp
252
253 configure-apache2-stamp: prepared-stamp
254         dh_testdir
255         if [ -d apache2-build ]; then rm -rf apache2-build; fi
256         -mkdir apache2-build
257         cd apache2-build && \
258         CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
259                 --prefix=/usr --with-apxs2=/usr/bin/apxs2 \
260                 --with-config-file-path=/etc/php5/apache2 \
261                 --with-config-file-scan-dir=/etc/php5/apache2/conf.d \
262                 $(COMMON_CONFIG) \
263                 --without-mm \
264                 --with-curl=shared,/usr \
265                 --with-enchant=shared,/usr \
266                 --with-zlib-dir=/usr \
267                 --with-gd=shared,/usr --enable-gd-native-ttf \
268                 --with-gmp=shared,/usr \
269                 --with-jpeg-dir=shared,/usr \
270                 --with-xpm-dir=shared,/usr/X11R6 \
271                 --with-png-dir=shared,/usr \
272                 --with-freetype-dir=shared,/usr \
273                 --with-imap=shared,/usr \
274                 --with-imap-ssl \
275                 $(IBFLAGS) \
276                 --enable-intl=shared \
277                 --with-ttf=shared,/usr \
278                 --with-t1lib=shared,/usr \
279                 --with-ldap=shared,/usr \
280                 --with-ldap-sasl=/usr \
281                 --with-mcrypt=shared,/usr \
282                 --with-mysql=shared,/usr \
283                 --with-mysqli=shared,/usr/bin/mysql_config \
284                 --with-pspell=shared,/usr \
285                 --with-unixODBC=shared,/usr \
286                 --with-recode=shared,/usr \
287                 --with-xsl=shared,/usr \
288                 --with-snmp=shared,/usr \
289                 --with-sqlite=shared,/usr \
290                 --with-sqlite3=shared,/usr \
291                 --with-mssql=shared,/usr \
292                 --with-tidy=shared,/usr \
293                 --with-xmlrpc=shared \
294                 --with-pgsql=shared,/usr PGSQL_INCLUDE=`pg_config --includedir` \
295                 --enable-pdo=shared \
296                 --without-pdo-dblib \
297                 --with-pdo-mysql=shared,/usr \
298                 --with-pdo-odbc=shared,unixODBC,/usr \
299                 --with-pdo-pgsql=shared,/usr/bin/pg_config \
300                 --with-pdo-sqlite=shared,/usr \
301                 --with-pdo-dblib=shared,/usr
302         cd apache2-build && \
303         cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
304            ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
305            ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
306            Zend/
307         touch configure-apache2-stamp
308
309 configure-apache2filter-stamp: prepared-stamp
310         dh_testdir
311         if [ -d apache2filter-build ]; then rm -rf apache2filter-build; fi
312         -mkdir apache2filter-build
313         cd apache2filter-build && \
314         CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
315                 --prefix=/usr --with-apxs2filter=/usr/bin/apxs2 \
316                 --with-config-file-path=/etc/php5/apache2filter \
317                 --with-config-file-scan-dir=/etc/php5/apache2filter/conf.d \
318                 $(COMMON_CONFIG) \
319                 --without-mm \
320                 --disable-pdo \
321                 --without-mysql --without-sybase-ct --without-mssql \
322                 --without-sqlite --without-sqlite3
323         cd apache2filter-build && \
324         cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
325            ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
326            ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
327            Zend/
328         touch configure-apache2filter-stamp
329
330 configure-cgi-stamp: prepared-stamp
331         dh_testdir
332         if [ -d cgi-build ]; then rm -rf cgi-build; fi
333         -mkdir cgi-build
334         cd cgi-build && \
335         CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
336                 --prefix=/usr --enable-force-cgi-redirect --enable-fastcgi \
337                 --with-config-file-path=/etc/php5/cgi \
338                 --with-config-file-scan-dir=/etc/php5/cgi/conf.d \
339                 $(COMMON_CONFIG) \
340                 --without-mm \
341                 --disable-pdo \
342                 --without-mysql --without-sybase-ct --without-mssql \
343                 --without-sqlite --without-sqlite3
344         cd cgi-build && \
345         cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
346            ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
347            ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
348            Zend/
349         touch configure-cgi-stamp
350
351 configure-cli-stamp: prepared-stamp
352         dh_testdir
353         if [ -d cli-build ]; then rm -rf cli-build; fi
354         -mkdir cli-build
355         cd cli-build && \
356         CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
357                 --prefix=/usr --disable-cgi \
358                 --with-config-file-path=/etc/php5/cli \
359                 --with-config-file-scan-dir=/etc/php5/cli/conf.d \
360                 $(COMMON_CONFIG) \
361                 --without-mm \
362                 --disable-pdo \
363                 --without-mysql --without-sybase-ct --without-sqlite \
364                 --without-mssql --without-sqlite3 --enable-pcntl
365         cd cli-build && \
366         cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
367            ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
368            ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
369            Zend/
370         touch configure-cli-stamp
371
372 configure-fpm-stamp: prepared-stamp
373         dh_testdir
374         if [ -d fpm-build ]; then rm -rf fpm-build; fi
375         -mkdir fpm-build
376         cd fpm-build && \
377         CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
378                 --prefix=/usr --enable-fpm --disable-cgi \
379                 --with-fpm-user=www-data --with-fpm-group=www-data \
380                 --with-config-file-path=/etc/php5/fpm \
381                 --with-config-file-scan-dir=/etc/php5/fpm/conf.d \
382                 $(COMMON_CONFIG) \
383                 --with-libevent-dir=/usr \
384                 --without-mm \
385                 --disable-pdo \
386                 --without-mysql --without-sybase-ct --without-sqlite \
387                 --without-mssql --without-sqlite3
388         cd fpm-build && \
389         cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
390            ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
391            ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
392            Zend/
393         touch configure-fpm-stamp
394
395 clean: unprepared unpatch
396         dh_testdir
397         dh_testroot
398
399
400         rm -f configure-apache2-stamp build-apache2-stamp
401         rm -f configure-apache2filter-stamp build-apache2filter-stamp
402         rm -f configure-cgi-stamp build-cgi-stamp
403         rm -f configure-cli-stamp build-cli-stamp
404         rm -f configure-fpm-stamp build-fpm-stamp
405         rm -f build-pear-stamp
406         rm -f install-stamp
407         rm -rf apache2-build
408         rm -rf apache2filter-build
409         rm -rf cgi-build
410         rm -rf cli-build
411         rm -rf fpm-build
412         rm -rf pear-build pear-build-download
413         rm -f debian/copyright
414         rm -rf test-results.txt $(MYSQL_DATA_DIR)
415         dh_clean -Xorig
416
417         # clean up autogenerated cruft
418         cat debian/modulelist | while read package extname dsoname; do \
419                 rm -f debian/php5-$$package.postinst; \
420         done
421         for sapi in libapache2-mod-php5 libapache2-mod-php5filter php5-cgi php5-cli php5-fpm; do \
422                 for cruft in postrm links; do \
423                         rm -f debian/$${sapi}.$${cruft}; \
424                 done; \
425         done
426
427 install: DH_OPTIONS=
428 install: build
429         dh_testdir
430         dh_testroot
431         dh_clean -k
432         dh_installdirs
433
434         chmod 01733 debian/php5-common/var/lib/php5
435
436         # Add here commands to install the package into debian/php5.
437         # install apache2 DSO module
438         cp apache2-build/.libs/libphp5.so \
439                 debian/libapache2-mod-php5/`apxs2 -q LIBEXECDIR`/
440         cp debian/libapache2-mod-php5.load \
441                 debian/libapache2-mod-php5/etc/apache2/mods-available/php5.load
442         cp debian/libapache2-mod-php5.conf \
443                 debian/libapache2-mod-php5/etc/apache2/mods-available/php5.conf
444
445         # Add here commands to install the package into debian/php5.
446         # install apache2 DSO filter module
447         cp apache2filter-build/.libs/libphp5.so \
448                 debian/libapache2-mod-php5filter/`apxs2 -q LIBEXECDIR`/libphp5filter.so
449         cp debian/libapache2-mod-php5filter.load \
450                 debian/libapache2-mod-php5filter/etc/apache2/mods-available/php5filter.load
451         cp debian/libapache2-mod-php5filter.conf \
452                 debian/libapache2-mod-php5filter/etc/apache2/mods-available/php5filter.conf
453
454         # sanitize php.ini file
455         cat php.ini-production | tr "\t" " " | sed -e'/short_open_tag =/ s/Off/On/g;/session.gc_probability =/ s/1/0/g' > debian/php5-common/usr/share/php5/php.ini-production
456         cat php.ini-production | tr "\t" " " | sed -e'/memory_limit =/ s/128M/-1/g;/short_open_tag =/ s/Off/On/g;/session.gc_probability =/ s/1/0/g' > debian/php5-common/usr/share/php5/php.ini-production.cli
457         cat php.ini-development | tr "\t" " " > debian/php5-common/usr/share/doc/php5-common/examples/php.ini-development
458         cp test-results.txt debian/php5-common/usr/share/doc/php5-common/
459
460         # install the apache modules' files
461         cd apache2-build && $(MAKE) install-headers install-build install-modules install-programs INSTALL_ROOT=$(CURDIR)/debian/libapache2-mod-php5
462         # remove netware and win32 headers that we don't want
463         cd debian/libapache2-mod-php5/usr/include/php5/ && \
464                   $(RM) TSRM/readdir.h \
465                         TSRM/tsrm_config.nw.h TSRM/tsrm_config.w32.h\
466                         TSRM/tsrm_nw.h TSRM/tsrm_win32.h\
467                         Zend/zend_config.nw.h Zend/zend_config.w32.h\
468                         main/config.nw.h main/config.w32.h\
469                         main/win95nt.h
470
471         # install PEAR
472         cp -a pear-build/* debian/php-pear/
473
474         # everything under usr/share/php/data except 'PEAR' is b0rken
475         # and actually needs to be fixed
476         [ ! -f debian/php-pear/usr/share/php/data/Structures_Graph/LICENSE ] || \
477                 $(RM) debian/php-pear/usr/share/php/data/Structures_Graph/LICENSE
478         [ ! -f debian/php-pear/usr/share/php/doc/PEAR/INSTALL ] || \
479                 $(RM) debian/php-pear/usr/share/php/doc/PEAR/INSTALL
480         [ ! -f debian/php-pear/usr/share/php/doc/Structures_Graph/docs/generate.sh ] || \
481                 $(RM) debian/php-pear/usr/share/php/doc/Structures_Graph/docs/generate.sh
482         for f in Structures_Graph/publish.sh Structures_Graph/package.sh \
483                 Structures_Graph/genpackage.xml.pl; do \
484                 $(RM) debian/php-pear/usr/share/php/data/$$f; \
485         done
486         # we don't want test suites
487         $(RM) -r debian/php-pear/usr/share/php/test/
488         [ -d debian/php-pear/usr/share/php/doc ] && { \
489                 mkdir -p debian/php-pear/usr/share/doc/php5-common/PEAR; \
490                 mv debian/php-pear/usr/share/php/doc/* \
491                         debian/php-pear/usr/share/doc/php5-common/PEAR/; \
492                 $(RM) -r debian/php-pear/usr/share/php/doc; \
493                 ln -s ../doc/php-pear/PEAR debian/php-pear/usr/share/php/doc; \
494                 echo "Dummy placeholder to prevent the directory's deletion" > \
495                         debian/php-pear/usr/share/doc/php5-common/PEAR/.placeholder; \
496         }
497
498         # install extensions
499         ext=`./debian/libapache2-mod-php5/usr/bin/php-config --extension-dir`;\
500         for i in libapache2-mod-php5 libapache2-mod-php5filter php5-cgi php5-fpm php5-cli; do \
501                 mkdir -p debian/$$i/$${ext}; \
502         done; \
503         cat debian/modulelist debian/extramodulelist | while read package extname dsoname; do \
504                 if [ -z "$$dsoname" ]; then dsoname=$$package; fi; \
505                 mkdir -p debian/php5-$$package$${ext}; \
506                 chrpath debian/libapache2-mod-php5/$${ext}/$$dsoname.so; \
507                 chrpath -d debian/libapache2-mod-php5/$${ext}/$$dsoname.so; \
508                 install -m 644 -o root -g root \
509                         debian/libapache2-mod-php5/$${ext}/$$dsoname.so \
510                         debian/php5-$$package$${ext}/$$dsoname.so; \
511                 rm debian/libapache2-mod-php5/$${ext}/$$dsoname.so; \
512         done
513
514         # install CGI
515         cp cgi-build/sapi/cgi/cgi-bin.php5 debian/php5-cgi/usr/lib/cgi-bin/php5
516         cp cgi-build/sapi/cgi/usr.bin.php5-cgi debian/php5-cgi/usr/bin/php5-cgi
517         cp cli-build/sapi/cli/php.1 debian/php5-cgi/usr/share/man/man1/php5-cgi.1
518
519         # install CLI
520         cp cli-build/sapi/cli/php debian/php5-cli/usr/bin/php5
521         cp cli-build/sapi/cli/php.1 debian/php5-cli/usr/share/man/man1/php5.1
522
523         # install FPM
524         mkdir -p debian/php5-fpm/usr/sbin debian/php5-fpm/usr/share/man/man8/ debian/php5-fpm/etc/php5/fpm/pool.d
525         cp fpm-build/sapi/fpm/php-fpm debian/php5-fpm/usr/sbin/php5-fpm
526         cp fpm-build/sapi/fpm/php-fpm.8 debian/php5-fpm/usr/share/man/man8/php5-fpm.8
527         # we don't want the pool definitions on the main file itself:
528         sed -r '/('"'"'|\[)www('"'"'|\])/Q' < fpm-build/sapi/fpm/php-fpm.conf > \
529             debian/php5-fpm/etc/php5/fpm/main.conf
530         # extract the first pool, called "www," from the config file:
531         sed -nr '/('"'"'|\[)www('"'"'|\])/{h;p;d};x;/www/{x;p}' < fpm-build/sapi/fpm/php-fpm.conf \
532             > debian/php5-fpm/etc/php5/fpm/pool.d/www.conf
533
534         # move and install -dev files
535         dh_movefiles --sourcedir=debian/libapache2-mod-php5
536         rm -rf debian/libapache2-mod-php5/usr/lib/php5/build/ \
537                debian/libapache2-mod-php5/usr/include/ \
538                debian/libapache2-mod-php5/usr/bin/
539         rm -rf debian/libapache2-mod-php5filter/usr/lib/php5/build/ \
540                debian/libapache2-mod-php5filter/usr/include/ \
541                debian/libapache2-mod-php5filter/usr/bin/
542         for i in Makefile.global acinclude.m4 mkdep.awk phpize.m4 scan_makefile_in.awk; do \
543                 chmod 644 debian/php5-dev/usr/lib/php5/build/$$i; \
544         done
545         mkdir -p debian/php5-dev/usr/share/php5
546         cp -a ext/skeleton ext/ext_skel debian/php5-dev/usr/share/php5
547         sed -i 's/skel_dir="skeleton"/skel_dir="\/usr\/share\/php5\/skeleton"/' \
548             debian/php5-dev/usr/share/php5/ext_skel
549         # shipping duplicate files from other packages is hell for security audits
550         ln -sf /usr/share/misc/config.guess $(PHPIZE_BUILDDIR)/config.guess
551         ln -sf /usr/share/misc/config.sub $(PHPIZE_BUILDDIR)/config.sub
552         ln -sf /usr/share/aclocal/libtool.m4 $(PHPIZE_BUILDDIR)/libtool.m4
553         ln -sf $(LTMAIN_DIR)ltmain.sh $(PHPIZE_BUILDDIR)/ltmain.sh
554         ln -sf /usr/bin/shtool $(PHPIZE_BUILDDIR)/shtool
555         # make php-dev stuff versioned
556         for i in php-config phpize; do \
557                 mv debian/php5-dev/usr/bin/$$i debian/php5-dev/usr/bin/"$$i"5; \
558                 mv debian/php5-dev/usr/share/man/man1/"$$i".1 debian/php5-dev/usr/share/man/man1/"$$i"5.1; \
559         done
560
561         # install common files
562         install -m755 debian/maxlifetime debian/php5-common/usr/lib/php5
563
564         # install lintian overrides
565         cp debian/php5.lintian-overrides $(CURDIR)/debian/php5-common/usr/share/lintian/overrides/php5-common
566         cp debian/php5-dev.lintian-overrides $(CURDIR)/debian/php5-dev/usr/share/lintian/overrides/php5-dev
567
568         # install some generic lintian overrides
569         ext=`debian/php5-dev/usr/bin/php-config5 --extension-dir | cut -b2- `; \
570         for sapi in php5-cli php5-fpm php5-cgi libapache2-mod-php5 libapache2-mod-php5filter; do \
571                 mkdir -p $(CURDIR)/debian/"$$sapi"/usr/share/lintian/overrides/; \
572                 sed "s/@sapi@/$$sapi/g;s,@extdir@,$$ext,g" \
573                     < $(CURDIR)/debian/php5-sapi.lintian-overrides \
574                     >> $(CURDIR)/debian/"$$sapi"/usr/share/lintian/overrides/"$$sapi"; \
575         done
576
577         # directories cleanup:
578         -rmdir -p debian/libapache2-mod-php5/usr/share/man/man1
579         -find debian/php-pear -type d -exec rmdir --ignore-fail-on-non-empty -p '{}' \; >/dev/null 2>&1
580
581         touch install-stamp
582
583 # Build architecture-independent files here.
584 # Pass -i to all debhelper commands in this target to reduce clutter.
585 binary-indep: DH_OPTIONS=-i
586 binary-indep: build install
587         # Need this version of debhelper for DH_OPTIONS to work.
588         dh_testdir
589         dh_testroot
590         cat debian/copyright.header LICENSE Zend/LICENSE > debian/copyright
591
592         dh_installdocs
593
594         for package in php5 php-pear; do \
595                 rm -rf debian/$$package/usr/share/doc/$$package; \
596                 ln -s php5-common debian/$$package/usr/share/doc/$$package; \
597         done
598
599         dh_link
600         dh_compress -Xphp.ini
601         dh_fixperms
602         dh_installdeb
603         dh_gencontrol
604         dh_md5sums
605         dh_builddeb
606
607 # Build architecture-dependent files here.
608 binary-arch: build install
609         # Need this version of debhelper for DH_OPTIONS to work.
610         dh_testdir
611         dh_testroot
612         # Do this first so we don't overwrite any debhelper-generated files
613         #
614         # generate the maintscripts for various php
615         # modules from the templates.
616         cat debian/modulelist | while read package extname dsoname; do \
617                 if [ -z "$$dsoname" ]; then dsoname=$$package; fi; \
618                 sed -e"s/@extname@/$$extname/g; s/@dsoname@/$$dsoname/g; \
619                        /#EXTRA#/ r debian/php5-$${package}.postinst.extra" \
620                   < debian/php5-module.postinst \
621                 | sed -e'/#EXTRA#/ d' \
622                   > debian/php5-$${package}.postinst; \
623                 c=`grep -vE '^(#|set|$$)' < debian/php5-$${package}.postinst | wc -l`; \
624                 [ "$$c" != "0" ] || $(RM) debian/php5-$${package}.postinst; \
625         done
626
627         # generate the config snippets for various php
628         # modules from the templates.
629         cat debian/modulelist debian/extramodulelist | while read package extname dsoname; do \
630                 if [ -z "$$dsoname" ]; then dsoname=$$package; fi; \
631                 mkdir -p debian/php5-$$package/etc/php5/conf.d; \
632                 sed -e"s/@extname@/$$extname/g; s/@dsoname@/$$dsoname/g" \
633                   < debian/php5-module.ini \
634                   > debian/php5-$${package}/etc/php5/conf.d/$${dsoname}.ini; \
635         done
636
637         # likewise, for the different sapi implementations
638         for tmpl in postrm links; do \
639                 for sapi in apache2 apache2filter cgi cli fpm; do \
640                         sed -e "s/@sapi@/$$sapi/g" \
641                         < debian/php5-sapi.$$tmpl \
642                         > debian/php5-$${sapi}.$$tmpl; \
643                 done; \
644                 mv debian/php5-apache2.$$tmpl debian/libapache2-mod-php5.$$tmpl; \
645                 mv debian/php5-apache2filter.$$tmpl debian/libapache2-mod-php5filter.$$tmpl; \
646         done
647
648         cat debian/copyright.header LICENSE Zend/LICENSE > debian/copyright
649         dh_installdocs -s
650
651         cat debian/modulelist | while read package extname dsoname; do \
652                 rm -rf debian/php5-$$package/usr/share/doc/php5-$$package; \
653                 ln -s php5-common debian/php5-$$package/usr/share/doc/php5-$$package; \
654         done
655
656         for package in php5-dbg php5-dev php5-cgi php5-cli php5-fpm libapache2-mod-php5 libapache2-mod-php5filter; do \
657                 rm -rf debian/$$package/usr/share/doc/$$package; \
658                 ln -s php5-common debian/$$package/usr/share/doc/$$package; \
659         done
660         dh_installcron -pphp5-common --name=php5
661         dh_installchangelogs -pphp5-common NEWS
662         dh_installinit
663         dh_strip -s --dbg-package=php5-dbg
664         dh_link -s
665         dh_compress -s -Xphp.ini
666         dh_fixperms -s -X /var/lib/php5
667         dh_installdeb -s
668         dh_shlibdeps -s
669
670         phpapi=`./debian/php5-dev/usr/bin/php-config5 --phpapi`; \
671         for i in libapache2-mod-php5 libapache2-mod-php5filter php5-cgi php5-cli php5-fpm; do \
672                 echo "php:Provides=phpapi-$${phpapi}" >> debian/$$i.substvars; \
673         done; \
674         cat debian/modulelist | while read package extname dsoname; do \
675                 echo "php:Depends=phpapi-$${phpapi}" >> debian/php5-$$package.substvars; \
676         done
677
678         for i in cgi cli fpm; do \
679                 "$$i"-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
680                         >> debian/php5-"$$i".substvars; \
681         done
682         for i in apache2; do \
683                 "$$i"-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
684                         >> debian/lib"$$i"-mod-php5.substvars; \
685                 "$$i"filter-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
686                         >> debian/lib"$$i"-mod-php5filter.substvars; \
687         done
688
689         echo "apache2:Depends=apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk, apache2.2-common" >>debian/libapache2-mod-php5.substvars
690         echo "apache2:Depends=apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk, apache2.2-common" >>debian/libapache2-mod-php5filter.substvars
691
692         echo "libtool:Conflicts=$(LIBTOOL_CONFLICTS)" >>debian/php5-dev.substvars
693         dh_gencontrol -s
694         dh_md5sums -s
695         dh_builddeb -s
696
697 binary: binary-arch binary-indep
698 .PHONY: build clean binary-indep binary-arch binary install configure