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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
|
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 by Joey Hess.
#
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independent
# package.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This has to be exported to make some magic below work.
export DH_OPTIONS
# Set this flag to 'yes' if you want to disable all modifications breaking abi
# compatibility to upstream
PHP5_COMPAT=no
# Set this flag to 'yes' if you want to compile PHP5 with suhosin patch
PHP5_SUHOSIN=no
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 ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
PHP5_SOURCE_VERSION = $(shell dpkg-parsechangelog | grep ^Version | sed "s/Version: //")
PHP5_UPSTREAM_VERSION = $(shell echo $(PHP5_SOURCE_VERSION) | sed -e "s/-.*//" -e "s/.*://")
PHP5_DEBIAN_REVISION = $(shell echo $(PHP5_SOURCE_VERSION) | sed "s/.*-//")
RUN_TESTS = yes
ifeq (nocheck,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
$(warning Disabling checks due DEB_BUILD_OPTIONS)
RUN_TESTS = no
endif
ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),hurd-i386))
$(warning Disabling checks on hurd-i386)
RUN_TESTS = no
endif
ifneq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),hurd-i386 m68k hppa ppc64))
CONFIGURE_APACHE_ARGS = --with-interbase=shared,/usr --with-pdo-firebird=shared,/usr
else
CONFIGURE_APACHE_ARGS = --without-interbase --without-pdo-firebird
endif
ifeq (yes,$(RUN_TESTS))
MYSQL_PORT := $(shell for i in $$(seq 1025 3600 | sort -R); do nc -z localhost $$i || { echo $$i; exit; } ; done)
MYSQL_DATA_DIR ?= $(shell readlink -f mysql_db)
ifeq (,$(MYSQL_PORT))
$(error Could not find available port for mysql server)
endif
MYSQL_SOCKET = $(MYSQL_DATA_DIR)/mysql.sock
endif
# specify some options to our patch system
QUILT_DIFF_OPTS=-p
QUILT_NO_DIFF_TIMESTAMPS=1
export QUILT_DIFF_OPTS QUILT_NO_DIFF_TIMESTAMPS
PROG_SENDMAIL = /usr/sbin/sendmail
ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O2
else
CFLAGS += -O0
endif
CFLAGS += -Wall -fsigned-char -fno-strict-aliasing
# LFS support
ifneq (yes,$(PHP5_COMPAT))
CFLAGS += $(shell getconf LFS_CFLAGS)
endif
# Enable IEEE-conformant floating point math on alphas (not the default)
ifeq (alpha-linux-gnu,$(DEB_HOST_GNU_TYPE))
CFLAGS += -mieee
endif
ifeq ($(DEB_HOST_GNU_TYPE),$(filter $(DEB_HOST_GNU_TYPE),ia64-linux-gnu powerpc64-linux-gnu avr32-linux-gnu))
CFLAGS += -g
else
CFLAGS += -gstabs
endif
# some other helpful (for readability at least) shorthand variables
PHPIZE_BUILDDIR = debian/php5-dev/usr/lib/php5/build
# support new (>= 2.2) and older versions of libtool for backporting ease
LIBTOOL_DIRS = /usr/share/libtool/config /usr/share/libtool
LTMAIN = $(firstword $(wildcard $(foreach d,$(LIBTOOL_DIRS),$d/ltmain.sh)))
LTMAIN_DIR = $(dir $(LTMAIN))
ifeq ($(LTMAIN_DIR), /usr/share/libtool/)
LIBTOOL_CONFLICTS:=libtool (>= 2.2)
else ifeq ($(LTMAIN_DIR), /usr/share/libtool/config/)
LIBTOOL_CONFLICTS:=libtool (<< 2.2)
else
LIBTOOL_CONFLICTS:=$(error "could not resolve path to ltmain.sh")
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
endif
# enable the hardening wrapper
DEB_BUILD_HARDENING = 1
# but disable PIE
DEB_BUILD_HARDENING_PIE = 0
export DEB_BUILD_HARDENING DEB_BUILD_HARDENING_PIE
COMMON_CONFIG=--build=$(DEB_BUILD_GNU_TYPE) \
--host=$(DEB_HOST_GNU_TYPE) \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/share/man \
--disable-debug \
--with-regex=php \
--disable-rpath \
--disable-static \
--with-pic \
--with-layout=GNU \
--with-pear=/usr/share/php \
--enable-calendar \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-bcmath \
--with-bz2 \
--enable-ctype \
--with-db4 \
--with-qdbm=/usr \
--without-gdbm \
--with-iconv \
--enable-exif \
--enable-ftp \
--with-gettext \
--enable-mbstring \
--with-onig=/usr \
--with-pcre-regex=/usr \
--enable-shmop \
--enable-sockets \
--enable-wddx \
--with-libxml-dir=/usr \
--with-zlib \
--with-kerberos=/usr \
--with-openssl=/usr \
--enable-soap \
--enable-zip \
--with-mhash=yes \
--with-system-tzdata \
--with-mysql-sock=/var/run/mysqld/mysqld.sock
BUILTIN_EXTENSION_CHECK=$$e=get_loaded_extensions(); natcasesort($$e); \
$$s="The following extensions are built in:"; \
foreach($$e as $$i) { $$s .= " $$i"; } \
echo("php:Extensions=" . wordwrap($$s . ".\n", 75, "\$${Newline}"));
# include the patch/unpatch rules from quilt
include /usr/share/quilt/quilt.make
prepared: prepared-stamp
prepared-stamp: $(QUILT_STAMPFN)
dh_testdir
ifeq (yes,$(PHP5_SUHOSIN))
QUILT_PATCHES=$(QUILT_PATCH_DIR) \
quilt --quiltrc /dev/null import debian/patches/suhosin.patch
QUILT_PATCHES=$(QUILT_PATCH_DIR) \
quilt --quiltrc /dev/null push -a || test $$? = 2
endif
sed -i -e 's/EXTRA_VERSION=""/EXTRA_VERSION="-$(PHP5_DEBIAN_REVISION)"/' configure.in
./buildconf --force
touch prepared-stamp
unprepared:
dh_testdir
sed -i -e 's/EXTRA_VERSION="-$(PHP5_DEBIAN_REVISION)"/EXTRA_VERSION=""/' configure.in
rm -f prepared-stamp
test-results.txt: build-apache2-stamp build-cli-stamp build-cgi-stamp
ifeq (yes,$(RUN_TESTS))
mkdir -p temp_session_store
# start our own mysql server for the tests
$(SHELL) debian/setup-mysql.sh $(MYSQL_PORT) $(MYSQL_DATA_DIR)
extensions=""; \
for f in $(CURDIR)/apache2-build/modules/*.so; do \
ext=`basename "$$f"`; \
test -d "$(CURDIR)/ext/$${ext%.so}/tests" || continue; \
test "$$ext" != "imap.so" || continue; \
test "$$ext" != "interbase.so" || continue; \
test "$$ext" != "ldap.so" || continue; \
test "$$ext" != "odbc.so" || continue; \
test "$$ext" != "pgsql.so" || continue; \
test "$$ext" != "pdo_dblib.so" || continue; \
test "$$ext" != "pdo_firebird.so" || continue; \
test "$$ext" != "pdo_odbc.so" || continue; \
test "$$ext" != "pdo_pgsql.so" || continue; \
test "$$ext" != "snmp.so" || continue; \
extensions="$$extensions -d extension=$$ext"; \
done; \
[ "$$extensions" ] || { echo "extensions list is empty"; exit 1; }; \
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 \
$(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
rm -rf temp_session_store
@for test in `find . -name '*.log' -a '!' -name 'config.log' -a '!' -name 'bootstrap.log' -a '!' -name 'run.log'`; do \
echo; \
echo -n "$${test#./}:"; \
cat $$test; \
echo; \
done | tee -a test-results.txt
$(SHELL) debian/setup-mysql.sh $(MYSQL_PORT) $(MYSQL_DATA_DIR) stop
else
echo 'nocheck found in DEB_BUILD_OPTIONS or unsupported architecture' | tee test-results.txt
endif
build: build-apache2-stamp build-apache2filter-stamp build-cgi-stamp build-cli-stamp build-embed-stamp build-fpm-stamp build-pear-stamp test-results.txt
build-apache2-stamp: configure-apache2-stamp
dh_testdir
cd apache2-build && $(MAKE)
touch build-apache2-stamp
build-apache2filter-stamp: configure-apache2filter-stamp
dh_testdir
cd apache2filter-build && $(MAKE)
touch build-apache2filter-stamp
build-cli-stamp: configure-cli-stamp
dh_testdir
cd cli-build && $(MAKE)
touch build-cli-stamp
build-embed-stamp: configure-embed-stamp
dh_testdir
cd embed-build && $(MAKE)
touch build-embed-stamp
build-fpm-stamp: configure-fpm-stamp
dh_testdir
cd fpm-build && $(MAKE)
touch build-fpm-stamp
build-cgi-stamp: configure-cgi-stamp
dh_testdir
cd cgi-build && $(MAKE) && mv sapi/cgi/php-cgi sapi/cgi/cgi-bin.php5
# Dirty hack to not rebuild everything twice
cd cgi-build/main && \
sed -i -e 's/FORCE_CGI_REDIRECT 1/FORCE_CGI_REDIRECT 0/' \
-e 's/DISCARD_PATH 0/DISCARD_PATH 1/' php_config.h && \
sed -i -e 's/--enable-force-cgi-redirect/--enable-discard-path/' build-defs.h && \
touch ../../ext/standard/info.c && \
touch ../../sapi/cgi/cgi_main.c
cd cgi-build && $(MAKE) && mv sapi/cgi/php-cgi sapi/cgi/usr.bin.php5-cgi
touch build-cgi-stamp
build-pear-stamp: build-cgi-stamp
dh_testdir
-mkdir pear-build
-mkdir pear-build-download
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
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"/' \
$(CURDIR)/pear-build/usr/bin/pear && \
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"/' \
$(CURDIR)/pear-build/usr/bin/pecl && \
sed -i -e 's/-d memory_limit="-1"//' \
-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"/' \
$(CURDIR)/pear-build/usr/bin/peardev
sed -i -re "s#('PEAR_CONFIG_SYSCONFDIR', PHP_SYSCONFDIR)#\1 . '/pear'#" $(CURDIR)/pear-build/usr/share/php/PEAR/Config.php
patch -s -d $(CURDIR)/pear-build/usr/share/php/ -p1 -i $(CURDIR)/debian/patches/PEAR-Builder-print-info-about-php5-dev.patch
touch build-pear-stamp
configure: configure-apache2-stamp configure-apache2filter-stamp configure-cli-stamp configure-embed-stamp configure-fpm-stamp configure-cgi-stamp
configure-apache2-stamp: prepared-stamp
dh_testdir
if [ -d apache2-build ]; then rm -rf apache2-build; fi
-mkdir apache2-build
cd apache2-build && \
CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
--prefix=/usr --with-apxs2=/usr/bin/apxs2 \
--with-config-file-path=/etc/php5/apache2 \
--with-config-file-scan-dir=/etc/php5/apache2/conf.d \
$(COMMON_CONFIG) \
--without-mm \
--with-curl=shared,/usr \
--with-enchant=shared,/usr \
--with-zlib-dir=/usr \
--with-gd=shared,/usr --enable-gd-native-ttf \
--with-gmp=shared,/usr \
--with-jpeg-dir=shared,/usr \
--with-xpm-dir=shared,/usr/X11R6 \
--with-png-dir=shared,/usr \
--with-freetype-dir=shared,/usr \
--with-imap=shared,/usr \
--with-imap-ssl \
--enable-intl=shared \
--without-t1lib \
--with-ldap=shared,/usr \
--with-ldap-sasl=/usr \
--with-mcrypt=shared,/usr \
--with-mysql=shared,/usr \
--with-mysqli=shared,/usr/bin/mysql_config \
--with-pspell=shared,/usr \
--with-unixODBC=shared,/usr \
--with-recode=shared,/usr \
--with-xsl=shared,/usr \
--with-snmp=shared,/usr \
--with-sqlite3=shared,/usr \
--with-mssql=shared,/usr \
--with-tidy=shared,/usr \
--with-xmlrpc=shared \
--with-pgsql=shared,/usr PGSQL_INCLUDE=`pg_config --includedir` \
--enable-pdo=shared \
--without-pdo-dblib \
--with-pdo-mysql=shared,/usr \
--with-pdo-odbc=shared,unixODBC,/usr \
--with-pdo-pgsql=shared,/usr/bin/pg_config \
--with-pdo-sqlite=shared,/usr \
--with-pdo-dblib=shared,/usr \
$(CONFIGURE_APACHE_ARGS)
cd apache2-build && \
cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
Zend/
touch configure-apache2-stamp
configure-apache2filter-stamp: prepared-stamp
dh_testdir
if [ -d apache2filter-build ]; then rm -rf apache2filter-build; fi
-mkdir apache2filter-build
cd apache2filter-build && \
CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
--prefix=/usr --with-apxs2filter=/usr/bin/apxs2 \
--with-config-file-path=/etc/php5/apache2filter \
--with-config-file-scan-dir=/etc/php5/apache2filter/conf.d \
$(COMMON_CONFIG) \
--without-mm \
--disable-pdo \
--without-mysql --without-sybase-ct --without-mssql \
--without-sqlite3
cd apache2filter-build && \
cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
Zend/
touch configure-apache2filter-stamp
configure-cgi-stamp: prepared-stamp
dh_testdir
if [ -d cgi-build ]; then rm -rf cgi-build; fi
-mkdir cgi-build
cd cgi-build && \
CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
--prefix=/usr --enable-force-cgi-redirect --enable-fastcgi \
--with-config-file-path=/etc/php5/cgi \
--with-config-file-scan-dir=/etc/php5/cgi/conf.d \
$(COMMON_CONFIG) \
--without-mm \
--enable-pdo=shared \
--enable-mysqlnd=shared \
--with-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--without-pdo-sqlite \
--without-sybase-ct --without-mssql \
--without-sqlite3 \
--enable-pcntl
cd cgi-build && \
cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
Zend/
touch configure-cgi-stamp
configure-cli-stamp: prepared-stamp
dh_testdir
if [ -d cli-build ]; then rm -rf cli-build; fi
-mkdir cli-build
cd cli-build && \
CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
--prefix=/usr --disable-cgi \
--with-config-file-path=/etc/php5/cli \
--with-config-file-scan-dir=/etc/php5/cli/conf.d \
$(COMMON_CONFIG) \
--without-mm \
--disable-pdo \
--without-mysql --without-sybase-ct \
--without-mssql --without-sqlite3 --enable-pcntl
cd cli-build && \
cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
Zend/
touch configure-cli-stamp
configure-embed-stamp: prepared-stamp
dh_testdir
if [ -d embed-build ]; then rm -rf embed-build; fi
-mkdir embed-build
cd embed-build && \
CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
--prefix=/usr --enable-embed --disable-cgi \
--with-config-file-path=/etc/php5/embed \
--with-config-file-scan-dir=/etc/php5/embed/conf.d \
$(COMMON_CONFIG) \
--without-mm \
--disable-pdo \
--without-mysql --without-sybase-ct \
--without-mssql --without-sqlite3 --enable-pcntl
cd embed-build && \
cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
Zend/
touch configure-embed-stamp
configure-fpm-stamp: prepared-stamp
dh_testdir
if [ -d fpm-build ]; then rm -rf fpm-build; fi
-mkdir fpm-build
cd fpm-build && \
CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
--prefix=/usr --enable-fpm --disable-cgi \
--with-fpm-user=www-data --with-fpm-group=www-data \
--with-config-file-path=/etc/php5/fpm \
--with-config-file-scan-dir=/etc/php5/fpm/conf.d \
$(COMMON_CONFIG) \
--with-libevent-dir=/usr \
--without-mm \
--disable-pdo \
--without-mysql --without-sybase-ct \
--without-mssql --without-sqlite3
cd fpm-build && \
cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
Zend/
touch configure-fpm-stamp
clean: unprepared unpatch
dh_testdir
dh_testroot
ifeq (yes,$(PHP5_SUHOSIN))
QUILT_PATCHES=$(QUILT_PATCH_DIR) \
quilt --quiltrc /dev/null delete debian/patches/suhosin.patch \
|| return 0
endif
rm -f configure-apache2-stamp build-apache2-stamp
rm -f configure-apache2filter-stamp build-apache2filter-stamp
rm -f configure-cgi-stamp build-cgi-stamp
rm -f configure-cli-stamp build-cli-stamp
rm -f configure-embed-stamp build-embed-stamp
rm -f configure-fpm-stamp build-fpm-stamp
rm -f build-pear-stamp
rm -f install-stamp
rm -rf apache2-build
rm -rf apache2filter-build
rm -rf cgi-build
rm -rf cli-build
rm -rf embed-build
rm -rf fpm-build
rm -rf pear-build pear-build-download
rm -f debian/copyright
rm -rf test-results.txt $(MYSQL_DATA_DIR)
dh_clean -Xorig
# clean up autogenerated cruft
cat debian/modulelist | while read package extname dsoname priority; do \
rm -f debian/php5-$$package.postinst; \
rm -f debian/php5-$$package.preinst; \
rm -f debian/php5-$$package.prerm; \
rm -f debian/php5-$$package.postrm; \
done
for sapi in libapache2-mod-php5 libapache2-mod-php5filter php5-cgi php5-cli libphp5-embed php5-fpm; do \
for cruft in postrm links; do \
rm -f debian/$${sapi}.$${cruft}; \
done; \
done
PCNTL_FUNCTIONS := $(shell < ext/pcntl/php_pcntl.h sed -ne "/^PHP_FUNCTION/ s/PHP_FUNCTION(\(.*\));/\1/;t end;d;:end p" | tr '\n' ',')
install: DH_OPTIONS=
install: build
dh_testdir
dh_testroot
dh_prep
dh_installdirs
chmod 01733 debian/php5-common/var/lib/php5
# Add here commands to install the package into debian/php5.
# install apache2 DSO module
cp apache2-build/.libs/libphp5.so \
debian/libapache2-mod-php5/`apxs2 -q LIBEXECDIR`/
cp debian/libapache2-mod-php5.load \
debian/libapache2-mod-php5/etc/apache2/mods-available/php5.load
cp debian/libapache2-mod-php5.conf \
debian/libapache2-mod-php5/etc/apache2/mods-available/php5.conf
# Add here commands to install the package into debian/php5.
# install apache2 DSO filter module
cp apache2filter-build/.libs/libphp5.so \
debian/libapache2-mod-php5filter/`apxs2 -q LIBEXECDIR`/libphp5filter.so
cp debian/libapache2-mod-php5filter.load \
debian/libapache2-mod-php5filter/etc/apache2/mods-available/php5filter.load
cp debian/libapache2-mod-php5filter.conf \
debian/libapache2-mod-php5filter/etc/apache2/mods-available/php5filter.conf
# sanitize php.ini file
cat php.ini-production | tr "\t" " " | sed -e'/short_open_tag =/ s/Off/On/g;/session.gc_probability =/ s/1/0/g;/disable_functions =/ s/$$/ $(PCNTL_FUNCTIONS)/g;' > debian/php5-common/usr/share/php5/php.ini-production
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
cat php.ini-development | tr "\t" " " | sed -e'/short_open_tag =/ s/Off/On/g;/session.gc_probability =/ s/1/0/g;/disable_functions =/ s/$$/ $(PCNTL_FUNCTIONS)/g;' > debian/php5-common/usr/share/php5/php.ini-development
cp test-results.txt debian/php5-common/usr/share/doc/php5-common/
# install embed SAPI
cd embed-build && make install-headers install-build install-sapi install-programs INSTALL_ROOT=$(CURDIR)/debian/libphp5-embed
# install the apache modules' files
cd apache2-build && $(MAKE) install-headers install-build install-modules install-programs INSTALL_ROOT=$(CURDIR)/debian/libapache2-mod-php5
# remove netware and win32 headers that we don't want
cd debian/libapache2-mod-php5/usr/include/php5/ && \
$(RM) TSRM/readdir.h \
TSRM/tsrm_config.nw.h TSRM/tsrm_config.w32.h\
TSRM/tsrm_nw.h TSRM/tsrm_win32.h\
Zend/zend_config.nw.h Zend/zend_config.w32.h\
main/config.nw.h main/config.w32.h\
main/win95nt.h
# install PEAR
cp -a pear-build/* debian/php-pear/
# everything under usr/share/php/data except 'PEAR' is b0rken
# and actually needs to be fixed
[ ! -f debian/php-pear/usr/share/php/data/Structures_Graph/LICENSE ] || \
$(RM) debian/php-pear/usr/share/php/data/Structures_Graph/LICENSE
[ ! -f debian/php-pear/usr/share/php/doc/PEAR/INSTALL ] || \
$(RM) debian/php-pear/usr/share/php/doc/PEAR/INSTALL
[ ! -f debian/php-pear/usr/share/php/doc/Structures_Graph/docs/generate.sh ] || \
$(RM) debian/php-pear/usr/share/php/doc/Structures_Graph/docs/generate.sh
for f in Structures_Graph/publish.sh Structures_Graph/package.sh \
Structures_Graph/genpackage.xml.pl; do \
$(RM) debian/php-pear/usr/share/php/data/$$f; \
done
# we don't want test suites
$(RM) -r debian/php-pear/usr/share/php/test/
[ -d debian/php-pear/usr/share/php/doc ] && { \
mkdir -p debian/php-pear/usr/share/doc/php5-common/PEAR; \
mv debian/php-pear/usr/share/php/doc/* \
debian/php-pear/usr/share/doc/php5-common/PEAR/; \
$(RM) -r debian/php-pear/usr/share/php/doc; \
ln -s ../doc/php-pear/PEAR debian/php-pear/usr/share/php/doc; \
echo "Dummy placeholder to prevent the directory's deletion" > \
debian/php-pear/usr/share/doc/php5-common/PEAR/.placeholder; \
}
# install extensions
ext=`./debian/libapache2-mod-php5/usr/bin/php-config --extension-dir`;\
for i in libapache2-mod-php5 libapache2-mod-php5filter php5-cgi php5-cli libphp5-embed php5-fpm; do \
mkdir -p debian/$$i/$${ext}; \
done; \
cat debian/modulelist debian/extramodulelist | while read package extname dsoname priority; do \
if [ "$$package" = "mysqlnd" ]; then \
modulepath=cgi-build/modules; \
else \
modulepath=debian/libapache2-mod-php5/$${ext}; \
fi; \
if [ -z "$$dsoname" ]; then dsoname=$$package; fi; \
mkdir -p debian/php5-$$package$${ext}; \
install -m 644 -o root -g root \
$${modulepath}/$$dsoname.so \
debian/php5-$$package$${ext}/$$dsoname.so; \
rm $${modulepath}/$$dsoname.so; \
done
# install CGI
cp cgi-build/sapi/cgi/cgi-bin.php5 debian/php5-cgi/usr/lib/cgi-bin/php5
cp cgi-build/sapi/cgi/usr.bin.php5-cgi debian/php5-cgi/usr/bin/php5-cgi
cp cli-build/sapi/cli/php.1 debian/php5-cgi/usr/share/man/man1/php5-cgi.1
# install CLI
cp cli-build/sapi/cli/php debian/php5-cli/usr/bin/php5
cp cli-build/sapi/cli/php.1 debian/php5-cli/usr/share/man/man1/php5.1
# install FPM
mkdir -p debian/php5-fpm/usr/sbin debian/php5-fpm/usr/share/man/man8/ debian/php5-fpm/etc/php5/fpm/pool.d
cp fpm-build/sapi/fpm/php-fpm debian/php5-fpm/usr/sbin/php5-fpm
cp fpm-build/sapi/fpm/php-fpm.8 debian/php5-fpm/usr/share/man/man8/php5-fpm.8
# we don't want the pool definitions on the main file itself:
sed -r '/('"'"'|\[)www('"'"'|\])/Q' < fpm-build/sapi/fpm/php-fpm.conf > \
debian/php5-fpm/etc/php5/fpm/php-fpm.conf
# extract the first pool, called "www," from the config file:
sed -nr '/('"'"'|\[)www('"'"'|\])/{h;p;d};x;/www/{x;p}' < fpm-build/sapi/fpm/php-fpm.conf \
> debian/php5-fpm/etc/php5/fpm/pool.d/www.conf
# move and install -dev files
dh_movefiles --sourcedir=debian/libphp5-embed
dh_movefiles --sourcedir=debian/libapache2-mod-php5
rm -rf debian/libphp5-embed/usr/include/ \
debian/libphp5-embed/usr/bin/
rm -rf debian/libapache2-mod-php5/usr/lib/php5/build/ \
debian/libapache2-mod-php5/usr/include/ \
debian/libapache2-mod-php5/usr/bin/
rm -rf debian/libapache2-mod-php5filter/usr/lib/php5/build/ \
debian/libapache2-mod-php5filter/usr/include/ \
debian/libapache2-mod-php5filter/usr/bin/
for i in Makefile.global acinclude.m4 mkdep.awk phpize.m4 scan_makefile_in.awk; do \
chmod 644 debian/php5-dev/usr/lib/php5/build/$$i; \
done
mkdir -p debian/php5-dev/usr/share/php5
cp -a ext/skeleton ext/ext_skel debian/php5-dev/usr/share/php5
sed -i 's/skel_dir="skeleton"/skel_dir="\/usr\/share\/php5\/skeleton"/' \
debian/php5-dev/usr/share/php5/ext_skel
# shipping duplicate files from other packages is hell for security audits
ln -sf /usr/share/misc/config.guess $(PHPIZE_BUILDDIR)/config.guess
ln -sf /usr/share/misc/config.sub $(PHPIZE_BUILDDIR)/config.sub
ln -sf /usr/share/aclocal/libtool.m4 $(PHPIZE_BUILDDIR)/libtool.m4
ln -sf $(LTMAIN_DIR)ltmain.sh $(PHPIZE_BUILDDIR)/ltmain.sh
ln -sf /usr/bin/shtool $(PHPIZE_BUILDDIR)/shtool
# make php-dev stuff versioned
for i in php-config phpize; do \
mv debian/php5-dev/usr/bin/$$i debian/php5-dev/usr/bin/"$$i"5; \
mv debian/php5-dev/usr/share/man/man1/"$$i".1 debian/php5-dev/usr/share/man/man1/"$$i"5.1; \
done
# remove windows devel file
rm $(CURDIR)/debian/php5-dev/usr/share/php5/skeleton/skeleton.dsp
# install common files
install -m755 debian/maxlifetime debian/php5-common/usr/lib/php5
install -m755 debian/php5enmod debian/php5-common/usr/sbin/php5enmod
ln -s php5enmod debian/php5-common/usr/sbin/php5dismod
# install lintian overrides
cp debian/php5.lintian-overrides $(CURDIR)/debian/php5-common/usr/share/lintian/overrides/php5-common
cp debian/php5-dev.lintian-overrides $(CURDIR)/debian/php5-dev/usr/share/lintian/overrides/php5-dev
cp debian/php-pear.lintian-overrides $(CURDIR)/debian/php-pear/usr/share/lintian/overrides/php-pear
# install some generic lintian overrides
ext=`debian/php5-dev/usr/bin/php-config5 --extension-dir | cut -b2- `; \
for sapi in php5-cli php5-fpm php5-cgi libapache2-mod-php5 libapache2-mod-php5filter libphp5-embed; do \
mkdir -p $(CURDIR)/debian/"$$sapi"/usr/share/lintian/overrides/; \
sed "s/@sapi@/$$sapi/g;s,@extdir@,$$ext,g" \
< $(CURDIR)/debian/php5-sapi.lintian-overrides | \
grep -E "^$${sapi}: " \
>> $(CURDIR)/debian/"$$sapi"/usr/share/lintian/overrides/"$$sapi"; \
done
# directories cleanup:
-rmdir -p debian/libapache2-mod-php5/usr/share/man/man1
-find debian/php-pear -type d -exec rmdir --ignore-fail-on-non-empty -p '{}' \; >/dev/null 2>&1
touch install-stamp
# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: DH_OPTIONS=-i
binary-indep: build install
# Need this version of debhelper for DH_OPTIONS to work.
dh_testdir
dh_testroot
cat debian/copyright.header LICENSE Zend/LICENSE > debian/copyright
dh_installdocs
for package in php5 php-pear; do \
rm -rf debian/$$package/usr/share/doc/$$package; \
ln -s php5-common debian/$$package/usr/share/doc/$$package; \
done
dh_link
dh_compress -Xphp.ini
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
# Build architecture-dependent files here.
binary-arch: build install
# Need this version of debhelper for DH_OPTIONS to work.
dh_testdir
dh_testroot
# Do this first so we don't overwrite any debhelper-generated files
#
# generate the config snippets for various php
# modules from the templates.
cat debian/modulelist debian/extramodulelist | while read package extname dsoname priority; do \
if [ -z "$${dsoname}" ]; then dsoname=$$package; fi; \
if [ -z "$${priority}" ]; then priority=20; fi; \
mkdir -p debian/php5-$$package/usr/share/php5/$$package; \
sed -e"s|@extname@|$${extname}|g; \
s/@dsoname@/$${dsoname}/g; \
s/@priority@/$${priority}/g" \
< debian/php5-module.ini \
> debian/php5-$$package/usr/share/php5/$$package/$${dsoname}.ini; \
echo -n "$$dsoname " >> debian/php5-$$package.modules; \
done
# generate the maintscripts for various php
# modules from the templates.
cat debian/modulelist | while read package extname dsoname priority; do \
modules=$$(cat debian/php5-$$package.modules); \
for script in postinst preinst postrm prerm; do \
sed -e"s/@package@/$${package}/g; \
s/@modules@/$${modules}/g; \
/#EXTRA#/ r debian/php5-$${package}.$${script}.extra" \
< debian/php5-module.$${script} \
| sed -e'/#EXTRA#/ d' \
> debian/php5-$${package}.$${script}; \
done; \
cp debian/php5-module.triggers debian/php5-$${package}.triggers; \
rm debian/php5-$$package.modules; \
done
# likewise, for the different sapi implementations
for tmpl in postrm links; do \
for sapi in cgi cli fpm; do \
sed -e "s/@sapi@/$${sapi}/g; \
s/@package@/php5-$${sapi}/g; \
/#EXTRA#/ r debian/php5-$${sapi}.$${tmpl}.extra" \
< debian/php5-sapi.$${tmpl} \
| sed -e'/#EXTRA#/ d' \
> debian/php5-$${sapi}.$${tmpl}; \
done; \
for sapi in embed; do \
sed -e "s/@sapi@/$${sapi}/g; \
s/@package@/libphp5-$${sapi}/g; \
/#EXTRA#/ r debian/libphp5-$${sapi}.$${tmpl}.extra" \
< debian/php5-sapi.$${tmpl} \
| sed -e'/#EXTRA#/ d' \
> debian/libphp5-$${sapi}.$${tmpl}; \
done; \
for sapi in "" "filter"; do \
sed -e "s/@sapi@/apache2$${sapi}/g; \
s/@package@/libapache2-mod-php5$${sapi}/g; \
/#EXTRA#/ r debian/libapache2-mod-php5$${sapi}.$${tmpl}.extra" \
< debian/php5-sapi.$${tmpl} \
| sed -e'/#EXTRA#/ d' \
> debian/libapache2-mod-php5$${sapi}.$${tmpl}; \
done; \
done
cat debian/copyright.header LICENSE Zend/LICENSE > debian/copyright
dh_installdocs -s
cat debian/modulelist | grep -v common | while read package extname dsoname priority; do \
rm -rf debian/php5-$$package/usr/share/doc/php5-$$package; \
ln -s php5-common debian/php5-$$package/usr/share/doc/php5-$$package; \
done
for package in php5-dbg php5-dev php5-cgi php5-cli php5-fpm libapache2-mod-php5 libapache2-mod-php5filter libphp5-embed; do \
rm -rf debian/$$package/usr/share/doc/$$package; \
ln -s php5-common debian/$$package/usr/share/doc/$$package; \
done
dh_installcron -pphp5-common --name=php5
dh_installchangelogs -pphp5-common NEWS
dh_installinit
dh_strip -s --dbg-package=php5-dbg
dh_link -s
dh_compress -s -Xphp.ini
dh_fixperms -s -X /var/lib/php5
dh_installdeb -s
dh_shlibdeps -s
phpapi=`./debian/php5-dev/usr/bin/php-config5 --phpapi`; \
stored=`cat debian/phpapi`; \
[ "$${phpapi%+lfs}" = "$${stored}" ] || echo "PHPAPI has changed, please modify debian/phpapi"; \
for i in libapache2-mod-php5 libapache2-mod-php5filter php5-cgi php5-cli libphp5-embed php5-fpm; do \
echo "php:Provides=phpapi-$${phpapi}" >> debian/$$i.substvars; \
done; \
cat debian/modulelist | while read package extname dsoname priority; do \
echo "php:Depends=phpapi-$${phpapi}" >> debian/php5-$$package.substvars; \
done
for i in cgi cli fpm; do \
"$$i"-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
>> debian/php5-"$$i".substvars; \
done
for i in embed; do \
"$$i"-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
>> debian/libphp5-"$$i".substvars; \
done
for i in apache2; do \
"$$i"-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
>> debian/lib"$$i"-mod-php5.substvars; \
"$$i"filter-build/sapi/cli/php -n -r '$(BUILTIN_EXTENSION_CHECK)' \
>> debian/lib"$$i"-mod-php5filter.substvars; \
done
echo "apache2:Depends=apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk, apache2.2-common" >>debian/libapache2-mod-php5.substvars
echo "apache2:Depends=apache2-mpm-prefork (>> 2.0.52) | apache2-mpm-itk, apache2.2-common" >>debian/libapache2-mod-php5filter.substvars
echo "libtool:Conflicts=$(LIBTOOL_CONFLICTS)" >>debian/php5-dev.substvars
dh_gencontrol -s
dh_md5sums -s
dh_builddeb -s
binary: binary-arch binary-indep
build-arch: build
build-indep: build
.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install configure
|