File: rules

package info (click to toggle)
apache 1.3.34-4.1%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 4,824 kB
  • ctags: 90
  • sloc: sh: 1,273; makefile: 686; perl: 215
file content (800 lines) | stat: -rwxr-xr-x 30,242 bytes parent folder | download
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
#!/usr/bin/make -f
# -*- makefile -*-
# Made with the aid of dh_make, by Craig Small.
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Also some stuff taken from debmake scripts, by Christoph Lameter.
# And from the X build system by Adam Heath.
# almost rewritten by the Debian Apache Mainteiner Team.

## Global environment

# upstreams versions (from changelog and upstream dirs)
# THESE MUST BE CHANGED BEFORE EVERY NEW UPSTREAM RELEASE

SOURCE_VERSION   = $(shell dpkg-parsechangelog | grep ^Version | sed "s/Version: //")
UPSTREAM_VERSION = $(shell echo $(SOURCE_VERSION) | sed -e "s/-.*//" -e "s/.*://")
DEB_REVISION     = $(shell echo $(SOURCE_VERSION) | sed -e "s/.*-//")

# apache packages get a version like $(APACHE_MAJOR)$(APACHE_MINOR)-$(DEB_REVISION)
APACHE_MAJOR = 1.3.34
APACHE_MINOR =
APACHE_NEXT_MAJOR = 1.3.$(shell echo $$((`echo $(APACHE_MAJOR) | sed 's/.*\.//'` + 1)))

# mod_perl packages get a version like $(PERL_MAJOR)$(PERL_MINOR)-$(DEB_REVISION)
# PERL_MINOR needs to get bumped any time $(APACHE_MAJOR)$(APACHE_MINOR) is
# incremented without PERL_MAJOR changing.
PERL_MAJOR   = 1.29
PERL_MINOR   = .0.4

# current version of the apache-ssl patch from apache-ssl.org
SSL_MAJOR    = 1.3.33
SSL_MINOR    = 1.55

# current version of the apache-contrib tarball
CONTRIB_MAJOR= 1.0.8a

# ARCH

BUILD_ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)

# shortcuts to specific paths

C=$(SOURCE_DIR)-apache/apache-contrib-$(CONTRIB_MAJOR)
D=libapache-mod-perl-$(PERL_MAJOR)
S=$(SOURCE_DIR)-apache-ssl/apache_$(APACHE_MAJOR)
P=$(SOURCE_DIR)-apache-perl/apache_$(APACHE_MAJOR)
V=$(SOURCE_DIR)-apache/apache_$(APACHE_MAJOR)

inc=usr/include/apache-1.3
lib=usr/lib/apache/1.3
doc=usr/share/doc/apache
man=usr/share/man

# Debian specific

# Uncomment this to turn on verbose modes.
# export DH_VERBOSE=1
# export NOISY=1
export DH_COMPAT=2

include debian/scripts/vars

SHELL=/bin/bash
BUILDINFO=make dpkg-dev debian-policy debhelper
PERL := /usr/bin/perl
LIBPERL := -lperl

# Build *FLAGS

EXTRA_CONFARGS =

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CONFLAGS = -O0
	MODPERLCFLAGS = $(CONFLAGS)
else
	CONFLAGS = -O1
	MODPERLCFLAGS = -O2
endif

COMMONFLAGS = $(CFLAGS) -g -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
CONFLAGS += $(COMMONFLAGS)
MODPERLCFLAGS += $(COMMONFLAGS)

# all the common CONFARGS should be here from now on and they will apply
# to all the build-trees

CONFARGS =	--target=apache --with-layout=Debian \
		--enable-suexec --suexec-caller=www-data \
		--suexec-docroot=/var/www --includedir=/$(inc) \
		--without-confadjust --without-execstrip \
		--enable-shared=max --enable-rule=SHARED_CHAIN \
		--enable-module=most --enable-module=status \
		--enable-module=auth_digest --enable-module=log_referer \
		--enable-module=log_agent --enable-module=auth_db \
		$(EXTRA_CONFARGS) \
		--activate-module=src/modules/extra/mod_macro.c

APACHEARGS =	--suexec-logfile=/var/log/apache/suexec.log \
		$(CONFARGS)

SSLARGS =	--suexec-logfile=/var/log/apache-ssl/suexec.log \
		$(CONFARGS)

PERLARGS =	--suexec-logfile=/var/log/apache-perl/suexec.log \
		--activate-module=src/modules/perl/libperl.a \
		$(CONFARGS) \
		--disable-shared=perl

## Rules

source.make: $(STAMP_DIR)/source.make
$(STAMP_DIR)/source.make:
	@echo -e "\n\n*** unpacking/patching common tree ***\n"
	$(MAKE) -f debian/sys-build.mk source.make
	cp -a $(SOURCE_DIR)/apache_$(APACHE_MAJOR)/src/os/unix/{*.h,*inline.c} \
		$(SOURCE_DIR)/apache_$(APACHE_MAJOR)/src/include/
	cp $(SOURCE_DIR)/pkg.eapi/*.h $(SOURCE_DIR)/apache_$(APACHE_MAJOR)/src/include/
	cp $(SOURCE_DIR)/pkg.eapi/*.c $(SOURCE_DIR)/apache_$(APACHE_MAJOR)/src/ap/
	cp $(SOURCE_DIR)/apache-contrib-$(CONTRIB_MAJOR)/mod_macro/mod_macro.c $(SOURCE_DIR)/apache_$(APACHE_MAJOR)/src/modules/extra
	mv $(SOURCE_DIR) $(SOURCE_DIR)-apache
	@echo -e "\n\n*** creating -ssl and -perl trees ***\n"
	mv $(SOURCE_DIR)-apache/apache-contrib-* .
	cp -rp $(SOURCE_DIR)-apache $(SOURCE_DIR)-apache-ssl
	cp -rp $(SOURCE_DIR)-apache $(SOURCE_DIR)-apache-perl
	mv apache-contrib-* $(SOURCE_DIR)-apache/
	@echo -e "\n\n*** unpackaing mod_perl ***\n"
	tar zxvf upstream/flavours/mod_perl-$(PERL_MAJOR).tar.gz > /dev/null
	mv mod_perl-$(PERL_MAJOR) libapache-mod-perl-$(PERL_MAJOR)
	@echo -e "\n\n*** applying extra patches to specific trees ***\n"
	#-apache
	patch -d $(V) -p0 < $(SOURCE_DIR)-apache/pkg.eapi/eapi.patch
	#-perl
	patch -d $(P) -p0 < $(SOURCE_DIR)-apache-perl/pkg.eapi/eapi.patch
	#-ssl
	cd $(SOURCE_DIR)-apache-ssl && \
		tar zxvf ../upstream/flavours/apache_$(SSL_MAJOR)+ssl_$(SSL_MINOR).tar.gz > /dev/null && \
		for i in `export LC_COLLATE=C && ls ../debian/patches/ssl/0*`; do patch -p1 < $$i; done
	cp -vpr $(SOURCE_DIR)-apache-ssl/src $(SOURCE_DIR)-apache-ssl/apache_$(APACHE_MAJOR)/
	rm -fr $(SOURCE_DIR)-apache-ssl/src
	patch -d $(S) -p1 < $(SOURCE_DIR)-apache-ssl/SSLpatch
	patch -d $(S) -p0 < $(SOURCE_DIR)-apache-ssl/pkg.eapi/eapi.patch
	#libapache-mod-perl
	patch -d $(D) -p1 < debian/patches/mod-perl/DBD::Pg_mem_leak_workaround.diff
	patch -d $(D) -p1 < debian/patches/mod-perl/debian_libperl_debug_fix.diff
	patch -d $(D) -p1 < debian/patches/mod-perl/r_dir_config_fix.diff
	patch -d $(D) -p1 < debian/patches/mod-perl/CVE-2007-1349

$(STAMP_DIR)/configure-stamp: $(STAMP_DIR)/source.make $(STAMP_DIR)/configure-stamp-apache $(STAMP_DIR)/configure-stamp-ssl $(STAMP_DIR)/configure-stamp-perl $(STAMP_DIR)/configure-stamp-mod-perl
	touch $(STAMP_DIR)/configure-stamp

$(STAMP_DIR)/configure-stamp-apache: $(STAMP_DIR)/source.make
	@echo -e "\n\n*** Configuring apache ***\n\n"

	cd $(V) && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CONFLAGS)" ./configure $(APACHEARGS)

	@echo -e "\n\n*** Creating apaci (apache) *** \n\n"

	sed -e "s,@PACKAGE@,apache," debian/apaci.append.real > \
		debian/apaci.append
	chmod +x debian/ubersed
	(debian/ubersed $(V)/src/apaci; \
		cat debian/apaci.append) > debian/apaci
	install debian/apaci $(V)/src/apaci

	@echo -e "\n\n*** Buiding apxs (apache) *** \n\n"

	cd $(V)/src/support && $(MAKE) apxs
	set -e; INCL=$$(echo $$(pwd)/$(V)/src/include); \
	 SBIN=$$(echo $$(pwd)/$(V)/src); sed \
	 	-e "s;^#!/.*;#!/usr/bin/perl;" \
		-e "s;\@prefix\@;/usr;" \
		-e "s;\@sbindir\@;$$SBIN;" \
		-e "s;\@libexecdir\@;/usr/lib/apache/1.3;" \
		-e "s;\@includedir\@;$$INCL;" \
		-e "s;\@sysconfdir\@;/etc/apache;" \
		-e "s;/httpd;/apache;g" \
		-e "s;-lm;-lc -lm;" \
		-e "s;-ldbm -ldb;;" \
		-e "s;-lndbm -ldb;;" \
		-e "s;-DTARGET;-DEAPI -DTARGET;" \
		-e "s;CFG_SYSCONFDIR/\$$CFG_TARGET;CFG_SYSCONFDIR/httpd;g" \
		$(V)/src/support/apxs > debian/local-apxs; \
	set -e; INCL=$$(echo $$(pwd)/$(V)/src/include); \
	 SBIN=$$(echo $$(pwd)/$(V)/src); sed \
	 	-e "s;$$INCL;/usr/include/apache-1.3;" \
		-e "s;$$SBIN;/usr/sbin;" \
		debian/local-apxs > debian/apxs
	chmod +x debian/{apxs,local-apxs}
	touch $(STAMP_DIR)/configure-stamp-apache

$(STAMP_DIR)/configure-stamp-ssl: $(STAMP_DIR)/source.make
	@echo -e "\n\n*** Configuring apache-ssl ***\n\n"

	cd $(S) && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CONFLAGS)" ./configure $(SSLARGS)

	@echo -e "\n\n*** Creating apaci (apache-ssl) *** \n\n"

	sed -e "s,@PACKAGE@,apache-ssl," debian/apaci.append.real > \
		debian/apaci.append-ssl
	chmod +x debian/ubersed-ssl
	(debian/ubersed-ssl $(S)/src/apaci; \
		cat debian/apaci.append-ssl) > debian/apaci-ssl
	install debian/apaci-ssl $(S)/src/apaci

	@echo -e "\n\n*** Buiding apxs (apache-ssl) *** \n\n"

	cd $(S)/src/support && $(MAKE) apxs
	set -e; INCL=$$(echo $$(pwd)/$(S)/src/include); \
	 SBIN=$$(echo $$(pwd)/$(S)/src); sed \
	 	-e "s;^#!/.*;#!/usr/bin/perl;" \
		-e "s;\@prefix\@;/usr;" \
		-e "s;\@sbindir\@;$$SBIN;" \
		-e "s;\@libexecdir\@;/usr/lib/apache/1.3;" \
		-e "s;\@includedir\@;$$INCL;" \
		-e "s;\@sysconfdir\@;/etc/apache-ssl;" \
		-e "s;/httpd;/apache-ssl;g" \
		-e "s;-lm;-lc -lm;" \
		-e "s;-ldbm -ldb;;" \
		-e "s;-lndbm -ldb;;" \
		-e "s;-DTARGET;-DEAPI -DTARGET;" \
		-e "s;CFG_SYSCONFDIR/\$$CFG_TARGET;CFG_SYSCONFDIR/httpd;g" \
		$(S)/src/support/apxs > debian/local-apxs-ssl; \
	set -e; INCL=$$(echo $$(pwd)/$(S)/src/include); \
	 SBIN=$$(echo $$(pwd)/$(S)/src); sed \
	 	-e "s;$$INCL;/usr/include/apache-1.3;" \
		-e "s;$$SBIN;/usr/sbin;" \
		debian/local-apxs-ssl > debian/apxs-ssl
	chmod +x debian/{apxs-ssl,local-apxs-ssl}
	touch $(STAMP_DIR)/configure-stamp-ssl

$(STAMP_DIR)/configure-stamp-perl: $(STAMP_DIR)/source.make
	@echo -e "\n\n*** Configuring apache-perl ***\n\n"

	cd $(D) && \
		$(PERL) Makefile.PL INSTALLDIRS=vendor \
		USE_DSO=0 USE_APACI=1 DO_HTTPD=1 NO_HTTPD=1 PREP_HTTPD=1 \
		APACHE_SRC=$(shell pwd)$(A)/$(P)/src \
		PERL_SECTIONS=1 PERL_SSI=1 PERL_METHOD_HANDLERS=1 ALL_HOOKS=1 \
		PERL_TIE_TABLES=1 PERL_DIRECTIVE_HANDLERS=1 PERL_STACKED_HANDLERS=1 \
		PERL_TRACE=0 PERL_LOG_API=1 PERL_URI_API=1 PERL_UTIL_API=1 \
		PERL_TABLE_API=1 PERL_FILE_API=1

	cd $(P) && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CONFLAGS)" ./configure $(PERLARGS)

	@echo -e "\n\n*** Creating apaci (apache-perl) *** \n\n"

	sed -e "s,@PACKAGE@,apache-perl," debian/apaci.append.real > \
		debian/apaci.append-perl
	chmod +x debian/ubersed-perl
	(debian/ubersed-perl $(P)/src/apaci; \
		cat debian/apaci.append-perl) > debian/apaci-perl
	install debian/apaci-perl $(P)/src/apaci

	@echo -e "\n\n*** Buiding apxs (apache-perl) *** \n\n"

	cd $(P)/src/support && $(MAKE) apxs
	set -e; INCL=$$(echo $$(pwd)/$(P)/src/include); \
	 SBIN=$$(echo $$(pwd)/$(P)/src); sed \
		-e "s;^#!/.*;#!/usr/bin/perl;" \
		-e "s;\@prefix\@;/usr;" \
		-e "s;\@sbindir\@;$$SBIN;" \
		-e "s;\@libexecdir\@;/usr/lib/apache/1.3;" \
		-e "s;\@includedir\@;$$INCL;" \
		-e "s;\@sysconfdir\@;/etc/apache-perl;" \
		-e "s;/httpd;/apache-perl;g" \
		-e "s;-lm;-lc -lm;" \
		-e "s;-ldbm -ldb;;" \
		-e "s;-lndbm -ldb;;" \
		-e "s;-DTARGET;-DEAPI -DTARGET;" \
		-e "s;CFG_SYSCONFDIR/\$$CFG_TARGET;CFG_SYSCONFDIR/httpd;g" \
		$(P)/src/support/apxs > debian/local-apxs-perl
	set -e; INCL=$$(echo $$(pwd)/$(P)/src/include); \
	 SBIN=$$(echo $$(pwd)/$(P)/src); sed \
	 	-e "s;$$INCL;/usr/include/apache-1.3;" \
		-e "s;$$SBIN;/usr/sbin;" \
		debian/local-apxs-perl > debian/apxs-perl
	chmod +x debian/{apxs-perl,local-apxs-perl}
	touch $(STAMP_DIR)/configure-stamp-perl

$(STAMP_DIR)/configure-stamp-mod-perl: $(STAMP_DIR)/source.make $(STAMP_DIR)/configure-stamp-apache
	@echo -e "\n\n*** Configuring libapache-mod-perl ***\n\n"

	# still a small workaround but it avoids a lot of headackes
	cp debian/local-apxs $(D)/
	
	cd $(D) && \
	$(PERL) Makefile.PL USE_APXS=1 WITH_APXS=`pwd`/local-apxs \
		PERL_SECTIONS=1 PERL_SSI=1 PERL_METHOD_HANDLERS=1 ALL_HOOKS=1 \
		PERL_TIE_TABLES=1 PERL_DIRECTIVE_HANDLERS=1 PERL_STACKED_HANDLERS=1 \
		PERL_TRACE=0 PERL_LOG_API=1 PERL_URI_API=1 PERL_UTIL_API=1 \
		PERL_TABLE_API=1 PERL_FILE_API=1 \
		INSTALLDIRS=vendor # PERL_DEBUG=1
	touch $(STAMP_DIR)/configure-stamp-mod-perl

build: $(STAMP_DIR)/build-stamp

$(STAMP_DIR)/build-stamp: $(STAMP_DIR)/configure-stamp $(STAMP_DIR)/build-stamp-apache $(STAMP_DIR)/build-stamp-ssl $(STAMP_DIR)/build-stamp-perl $(STAMP_DIR)/build-stamp-mod-perl $(STAMP_DIR)/expand-debian

$(STAMP_DIR)/build-stamp-apache: $(STAMP_DIR)/configure-stamp-apache
	dh_testdir

	@echo -e "\n\n*** Compiling apache daemon and modules ***\n\n"
	cd $(V) && $(MAKE)

	@echo -e "\n\n*** Compiling experimental modules ***\n\n"
	export APXS=$(CURDIR)/debian/local-apxs && \
	cd $(V)/src/modules/experimental/ && \
	$$APXS -c mod_backtrace.c && \
	$$APXS -c -I$(CURDIR)/$(V)/src/main/ mod_whatkilledus.c

	@echo -e "\n\n*** Compiling contrib modules ***\n\n"
	cd $(C) && $(MAKE) APXS=$(CURDIR)/debian/local-apxs

	@echo -e "\n\n*** apache modules sanity check ***\n\n"
	find $(SOURCE_DIR)-apache/ \
		-name "*.so" -exec install -m 644 {} $(V) \;
	@set -e; echo; cd $(V) && cat $(CURDIR)/debian/module-manifest \
		| xargs -i ls -l --no-group {}; echo
	touch $(STAMP_DIR)/build-stamp-apache

$(STAMP_DIR)/build-stamp-ssl: $(STAMP_DIR)/configure-stamp-ssl
	dh_testdir

	@echo -e "\n\n*** Compiling apache-ssl daemon and modules ***\n\n"
	cd $(S) && $(MAKE)

	@echo -e "\n\n*** apache-ssl modules sanity check ***\n\n"
	find $(SOURCE_DIR)-apache-ssl/ \
		-name "*.so" -exec install -m 644 {} $(S) \;
	@set -e; echo; cd $(S) && cat $(CURDIR)/debian/module-manifest-ssl \
		| xargs -i ls -l --no-group {}; echo
	touch $(STAMP_DIR)/build-stamp-ssl

$(STAMP_DIR)/build-stamp-perl: $(STAMP_DIR)/configure-stamp-perl
	dh_testdir

	@echo -e "\n\n*** Compiling apache-perl daemon and modules ***\n\n"
	cd $(P) && $(MAKE)

	@echo -e "\n\n*** apache-perl modules sanity check ***\n\n"
	find $(SOURCE_DIR)-apache-perl/ \
		-name "*.so" -exec install -m 644 {} $(P) \;
	@set -e; echo; cd $(S) && cat $(CURDIR)/debian/module-manifest-perl \
		| xargs -i ls -l --no-group {}; echo
	touch $(STAMP_DIR)/build-stamp-perl

$(STAMP_DIR)/build-stamp-mod-perl: $(STAMP_DIR)/configure-stamp-mod-perl
	dh_testdir
	@echo -e "\n\n*** Compiling libapache-mod-perl ***\n"
	cd $(D) && $(MAKE) OPTIMIZE="$(MODPERLCFLAGS)"
	touch $(STAMP_DIR)/build-stamp-mod-perl

expand-debian: $(STAMP_DIR)/source.make $(STAMP_DIR)/expand-debian
$(STAMP_DIR)/expand-debian:
	@echo -e "\n\n*** Populating debian/ from debian/pkgtemplates ***\n\n"

	chmod +x debian/scripts/populate
	debian/scripts/populate $(APACHE_MAJOR) $(PERL_MAJOR) $(DEB_REVISION) $(APACHE_MINOR)

	chmod +x debian/{*post*,*preinst*,*prerm*}

	@echo -e "\n\n*** Checking maintainer scripts ***\n\n"
	set -e ; for foo in debian/*inst* debian/*ostrm debian/*rerm ; \
		do echo -n "$$foo " ; sh -n $$foo ; done ; echo
	
	@echo -e "\n\n*** Fixing png icons ***\n\n"
	cd $(V)/icons && for i in *.gif;do convert $$i $${i%.gif}.png;done
	cd $(V)/icons/small && for i in *.gif;do convert $$i $${i%.gif}.png;done
	cd debian && uudecode logos.uue && tar -zxf logos.tar.gz
	for i in `find debian/logos -name *.gif`; do \
		convert $$i $${i%.gif}.png; done
	cd debian && uudecode logos.ssl.uue && tar -zxf logos.ssl.tar.gz
	for i in `find debian/logos.ssl -name *.gif`; do \
		convert $$i $${i%.gif}.png; done

	touch $(STAMP_DIR)/expand-debian

install: build $(STAMP_DIR)/install-stamp
$(STAMP_DIR)/install-stamp: $(STAMP_DIR)/pre-install-stamp-deb $(STAMP_DIR)/install-stamp-common $(STAMP_DIR)/install-stamp-dev $(STAMP_DIR)/install-stamp-dbg $(STAMP_DIR)/install-stamp-doc $(STAMP_DIR)/install-stamp-apache $(STAMP_DIR)/install-stamp-ssl $(STAMP_DIR)/install-stamp-perl $(STAMP_DIR)/install-stamp-mod-perl
	touch $(STAMP_DIR)/install-stamp

$(STAMP_DIR)/pre-install-stamp-deb:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	touch $(STAMP_DIR)/pre-install-stamp-deb

$(STAMP_DIR)/install-stamp-utils: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache-utils ***\n\n"
	dh_testdir
	dh_testroot

	# from apache-ssl
	install $(S)/src/support/{check_forensic,logresolve,ab,rotatelogs} \
		debian/apache-utils/usr/sbin
	debian/ubersed < $(S)/src/support/logresolve.8 \
		> debian/apache-utils/$(man)/man8/logresolve.8
	debian/ubersed < $(S)/src/support/ab.8 \
		> debian/apache-utils/$(man)/man8/ab.8
	debian/ubersed < $(S)/src/support/rotatelogs.8 \
		> debian/apache-utils/$(man)/man8/rotatelogs.8
	install debian/check_forensic.8 debian/apache-utils/$(man)/man8/check_forensic.8

	# from apache
	install $(V)/src/support/{htpasswd,htdigest,dbmmanage} \
		debian/apache-utils/usr/bin
	debian/ubersed < $(V)/src/support/htpasswd.1 \
		> debian/apache-utils/$(man)/man1/htpasswd.1
	debian/ubersed < $(V)/src/support/htdigest.1 \
		> debian/apache-utils/$(man)/man1/htdigest.1
	debian/ubersed < $(V)/src/support/dbmmanage.1 \
		> debian/apache-utils/$(man)/man1/dbmmanage.1

	touch $(STAMP_DIR)/install-stamp-utils

$(STAMP_DIR)/install-stamp-common: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache-common ***\n\n"
	dh_testdir
	dh_testroot

	# default configs
	cd debian && \
	for i in apache apache-ssl apache-perl; do \
		cp -a srm.conf access.conf apache-common/usr/share/apache/default-configs/$$i && \
		cp -a $$i.httpd.conf apache-common/usr/share/apache/default-configs/$$i/httpd.conf && \
		cp -a $$i.intro.html apache-common/usr/share/apache/default-configs/$$i/intro.html ; \
	done

	# modules
	cp -a $$(find $(V) info/ -maxdepth 1 -name "*.info") \
		$$(find $(V) -maxdepth 1 -name "*.so") \
		debian/apache-common/$(lib)
	for mod in $$(cd $(C) && sh -c "find * -maxdepth 0 -type d") ; do \
		if [ -f $(C)/$$mod/README ] ; then \
			echo "++ $(C)/$$mod/README" && \
			cp -a $(C)/$$mod/README \
				debian/apache-common/$(doc)-common/README.$$mod; \
		fi; \
	done
	rm -f debian/apache-common/$(doc)-common/README.mod_eaccess
	cp $(C)/mod_eaccess/doc/index.html debian/apache-common/$(doc)-common/mod_eaccess.html
	cp -v $(C)/*/*.html debian/apache-common/$(doc)-common/
	cp $(C)/mod_auth_cache*/{ChangeLog,INSTALL,README,TODO} \
		debian/apache-common/$(doc)-common/mod_auth_cache/

	@echo -e "\n--- sanity: module .info check ---\n"
	chmod +x debian/scripts/modchk && debian/scripts/modchk

	# scripts
	chmod +x debian/listconffiles
	chmod +x debian/listlogfiles
	cp -a debian/{postinst.common,listconffiles,listlogfiles} \
	      debian/apache-common/usr/share/apache/
	chmod +x debian/modules-config
	cp -a debian/modules-config debian/apache-common/usr/sbin/apache-modconf
	cp debian/modules-config.8 debian/apache-common/$(man)/man8/apache-modconf.8
	cd debian/apache-common/usr/sbin && ln -sf apache-modconf modules-config
	cd debian/apache-common/$(man)/man8 && ln -sf apache-modconf.8 modules-config.8

	# icons
	cp -a $(V)/icons/*.{gif,png} debian/logos/* \
		debian/apache-common/usr/share/apache/icons
	cp -a $(V)/icons/small/*.{gif,png} \
		debian/apache-common/usr/share/apache/icons/small
	cp -a $(V)/icons/README \
		debian/apache-common/$(doc)-common/README.icons
	cp -a $(V)/icons/small/README.txt \
		debian/apache-common/$(doc)-common/README.small.icons

	# misc
	cp -a $(V)/src/include/ap_config.h \
		debian/apache-common/$(doc)-common/
	debian/ubersed < $(V)/src/support/suexec.8 \
		> debian/apache-common/$(man)/man8/suexec.8
	cp -a debian/apache-common.lintian \
		debian/apache-common/usr/share/lintian/overrides/apache-common
	cp -a debian/apache-common.presubj \
		debian/apache-common/usr/share/bug/apache-common/presubj

	touch $(STAMP_DIR)/install-stamp-common

$(STAMP_DIR)/install-stamp-dev: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache-dev ***\n\n"
	dh_testdir
	dh_testroot

	# apxs
	install debian/apxs debian/apache-dev/usr/bin/apxs
	install debian/apxs-perl debian/apache-dev/usr/bin/apxs-perl
	install debian/apxs-ssl debian/apache-dev/usr/bin/apxs-ssl
	debian/ubersed < $(V)/src/support/apxs.8 \
		> debian/apache-dev/$(man)/man1/apxs.1
	debian/ubersed-perl < $(P)/src/support/apxs.8 \
		> debian/apache-dev/$(man)/man1/apxs-perl.1
	debian/ubersed-ssl < $(S)/src/support/apxs.8 \
		> debian/apache-dev/$(man)/man1/apxs-ssl.1

	# includes
	cp -a $(V)/src/include/* debian/apache-dev/$(inc)
	cp -a $(V)/src/modules/standard/mod_rewrite.h debian/apache-dev/$(inc)/modules/rewrite
	cp -a $(V)/src/modules/proxy/mod_proxy.h debian/apache-dev/$(inc)/modules/proxy

	# apaci
	install -m644 debian/apaci debian/apache-dev/$(doc)-dev/apaci

	# misc
	cp -a debian/README.modules debian/apache-dev/$(doc)-dev/

	touch $(STAMP_DIR)/install-stamp-dev

$(STAMP_DIR)/install-stamp-dbg: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache-dbg ***\n\n"
	dh_testdir
	dh_testroot

	# daemons
	install $(V)/src/apache debian/apache-dbg/usr/sbin/apache.dbg
	install $(P)/src/apache debian/apache-dbg/usr/sbin/apache-perl.dbg
	install $(S)/src/apache debian/apache-dbg/usr/sbin/apache-ssl.dbg

	debian/ubersed < $(V)/src/support/httpd.8 \
		> debian/apache-dbg/$(man)/man8/apache.dbg.8
	debian/ubersed-perl < $(P)/src/support/httpd.8 \
		> debian/apache-dbg/$(man)/man8/apache-perl.dbg.8
	debian/ubersed-ssl < $(S)/src/support/httpd.8 \
		> debian/apache-dbg/$(man)/man8/apache-ssl.dbg.8
	
	# misc
	cp -a debian/apache-dbg.lintian \
		debian/apache-dbg/usr/share/lintian/overrides/apache-dbg
	touch $(STAMP_DIR)/install-stamp-dbg

$(STAMP_DIR)/install-stamp-doc: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache-doc ***\n\n"
	dh_testdir
	dh_testroot

	cp -a $(V)/src/README debian/apache-doc/$(doc)-doc/README.src
	cp -a $(V)/htdocs/manual/* debian/apache-doc/$(doc)-doc/manual
	rm -f debian/apache-doc/$(doc)-doc/manual/LICENSE
	debian/ubersed < $(V)/htdocs/index.html.en \
		> debian/apache-doc/$(doc)-doc/manual.html
	ln -s ../../apache/icons debian/apache-doc/$(doc)-doc/icons

	# fixing manual browsing
	chmod +x debian/scripts/doc_fix
	debian/scripts/doc_fix debian/apache-doc/$(doc)-doc/manual
	cd debian/apache-doc/usr/share/doc/apache-doc && ln -fs manual html

	touch $(STAMP_DIR)/install-stamp-doc

$(STAMP_DIR)/install-stamp-apache: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache ***\n\n"
	dh_testdir
	dh_testroot

	chown www-data:www-data debian/apache/var/cache/apache

	# apache
	install $(V)/src/apache debian/apache/usr/sbin
	debian/ubersed < $(V)/src/support/httpd.8 \
		> debian/apache/$(man)/man8/apache.8

	# apachectl
	debian/ubersed < $(V)/src/support/apachectl \
		>  debian/apache/usr/sbin/apachectl
	chmod +x debian/apache/usr/sbin/apachectl
	debian/ubersed < $(V)/src/support/apachectl.8 \
		> debian/apache/$(man)/man8/apachectl.8

	# suexec
	install -m 4755 $(V)/src/support/suexec \
		debian/apache/usr/lib/apache/suexec.disabled

	# misc
	cd debian/apache/usr/sbin && ln -sf apache-modconf apacheconfig
	cd debian/apache/$(man)/man8 && ln -sf apache-modconf.8.gz apacheconfig.8.gz
	cp -a debian/apache.httpd.conf debian/apache/$(doc)/examples/httpd.conf
	cp -a debian/apache.lintian \
		debian/apache/usr/share/lintian/overrides/apache
	cp -a debian/apache.presubj \
		debian/apache/usr/share/bug/apache/presubj

	touch $(STAMP_DIR)/install-stamp-apache

$(STAMP_DIR)/install-stamp-ssl: $(STAMP_DIR)/pre-install-stamp-deb
	@echo -e "\n\n*** Installing apache-ssl ***\n\n"
	dh_testdir
	dh_testroot

	chown www-data:www-data debian/apache-ssl/var/cache/apache-ssl

	# apache-ssl
	install $(S)/src/apache debian/apache-ssl/usr/sbin/apache-ssl
	debian/ubersed-ssl < $(S)/src/support/httpd.8 \
		> debian/apache-ssl/$(man)/man8/apache-ssl.8
	
	# apache-sslctl
	debian/ubersed-ssl < $(S)/src/support/apachectl \
		>  debian/apache-ssl/usr/sbin/apache-sslctl
	chmod +x debian/apache-ssl/usr/sbin/apache-sslctl
	debian/ubersed-ssl < $(S)/src/support/apachectl.8 \
		> debian/apache-ssl/$(man)/man8/apache-sslctl.8

	# suexec
	install -m 4755 -s $(S)/src/support/suexec \
		debian/apache-ssl/usr/lib/apache-ssl/suexec.disabled

	# gcache
	install $(S)/src/modules/ssl/gcache debian/apache-ssl/usr/lib/apache-ssl/

	# apache-ssl modules
	install -m 644 $(S)/src/modules/standard/mod_log_config.so \
		debian/apache-ssl/$(lib)/mod_log_config_ssl.so
	install -m 644 $(S)/src/modules/standard/mod_mime.so \
		debian/apache-ssl/$(lib)/mod_mime_ssl.so
	install -m 644 $(S)/src/modules/standard/mod_auth.so \
		debian/apache-ssl/$(lib)/mod_auth_ssl.so
	install -m 644 $(S)/src/modules/ssl/libssl.so \
		debian/apache-ssl/$(lib)/libssl.so
	install -m 644 info/020mod_log_config_ssl.info \
		debian/apache-ssl/$(lib)/
	install -m 644 info/050mod_mime_ssl.info \
		debian/apache-ssl/$(lib)/
	install -m 644 info/390mod_auth_ssl.info \
		debian/apache-ssl/$(lib)/
	install -m 644 info/380apache-ssl.info \
		debian/apache-ssl/$(lib)/

	# ssleay
	cp -a debian/apache-ssl.ssleay.cnf debian/apache-ssl/usr/share/apache-ssl/ssleay.cnf
	ln -s ../../../apache-ssl/ssleay.cnf debian/apache-ssl/$(doc)-ssl/examples/

	# html documentation

	cat debian/apache-ssl.docs.html | \
		sed -e 's/\.gif/\.png/g' >> debian/apache-ssl/$(doc)-ssl/manual/docs.html
	cp -a debian/logos.ssl/* debian/apache-ssl/$(doc)-ssl/manual/

	# misc
	cp -a debian/apache.pem.5 debian/apache-ssl/$(man)/man5/apache.pem.5
	cd debian/apache-ssl/usr/sbin/ && ln -sf apache-modconf apache-sslconfig
	cd debian/apache-ssl/$(man)/man8 && ln -sf apache-modconf.8.gz apache-sslconfig.8.gz
	cp -p $(SOURCE_DIR)-apache-ssl/*.SSL $(SOURCE_DIR)-apache-ssl/SECURITY debian/apache-ssl/$(doc)-ssl
	mv debian/apache-ssl/$(doc)-ssl/LICENCE.SSL debian/apache-ssl/$(doc)-ssl/README.APACHESSL
	cp -a debian/apache-ssl.lintian \
		debian/apache-ssl/usr/share/lintian/overrides/apache-ssl
	cp -a debian/apache-ssl.httpd.conf debian/apache-ssl/$(doc)-ssl/examples/httpd.conf
	cp -a debian/apache-ssl.presubj \
		debian/apache-ssl/usr/share/bug/apache-ssl/presubj

	touch $(STAMP_DIR)/install-stamp-ssl

$(STAMP_DIR)/install-stamp-perl:
	@echo -e "\n\n*** Installing apache-perl ***\n\n"
	dh_testdir
	dh_testroot

	chown www-data:www-data debian/apache-perl/var/cache/apache-perl

	# apache-perl
	install $(P)/src/apache debian/apache-perl/usr/sbin/apache-perl
	debian/ubersed-perl < $(P)/src/support/httpd.8 \
		> debian/apache-perl/usr/share/man/man8/apache-perl.8

	# apache-perlctl
	debian/ubersed-perl < $(P)/src/support/apachectl \
		> debian/apache-perl/usr/sbin/apache-perlctl
	chmod +x debian/apache-perl/usr/sbin/apache-perlctl
	debian/ubersed-perl < $(P)/src/support/apachectl.8 \
		> debian/apache-perl/usr/share/man/man8/apache-perlctl.8

	# suexec
	install -m 4755 $(P)/src/support/suexec \
		debian/apache-perl/usr/lib/apache-perl/suexec.disabled

	# misc
	cd debian/apache-perl/usr/sbin/ && ln -sf apache-modconf apache-perlconfig
	cd debian/apache-perl/$(man)/man8 && ln -sf apache-modconf.8.gz apache-perlconfig.8.gz
	cp -a debian/README-perl.Debian debian/apache-perl/$(doc)-perl/README-perl.Debian
	cp -a debian/apache-perl.httpd.conf debian/apache-perl/$(doc)-perl/examples/httpd.conf
	cp -a debian/apache-perl.lintian \
		debian/apache-perl/usr/share/lintian/overrides/apache-perl
	cp -a debian/apache-perl.presubj \
		debian/apache-perl/usr/share/bug/apache-perl/presubj

	touch $(STAMP_DIR)/install-stamp-perl

$(STAMP_DIR)/install-stamp-mod-perl:
	@echo -e "\n\n*** Installing libapache-mod-perl ***\n\n"
	dh_testdir
	dh_testroot

	# mod-perl
	cd $(D) && \
	$(MAKE) PREFIX=`pwd`/../debian/libapache-mod-perl/usr/ install_vendor
	install -m 644 $(D)/apaci/libperl.so debian/libapache-mod-perl/usr/lib/apache/1.3/mod_perl.so
	install -m 644 info/400mod_perl.info debian/libapache-mod-perl/usr/lib/apache/1.3/400mod_perl.info

	# examples
	cp -rp $(D)/eg/* debian/libapache-mod-perl/usr/share/doc/libapache-mod-perl/examples

	# includes
	cd debian/libapache-mod-perl && \
	mv usr/lib/perl5/auto/Apache/include/modules usr/include/apache-1.3/ && \
	rm -rf usr/lib/perl5/auto/Apache/include && \
	ln -sf ../../../../include/apache-1.3 usr/lib/perl5/auto/Apache/include
	cd debian/libapache-mod-perl/usr/lib/perl5/Apache/ && \
	sed -e "s,'APXS.*,'APXS' => '/usr/bin/apxs'\,," < MyConfig.pm > MyConfig.pm2 && \
	mv MyConfig.pm2 MyConfig.pm

	# misc
	cp debian/libapache-mod-perl.olddebianchangelog debian/libapache-mod-perl/usr/share/doc/libapache-mod-perl/historical-Debian-changelog
	cp -a debian/libapache-mod-perl.lintian \
		debian/libapache-mod-perl/usr/share/lintian/overrides/libapache-mod-perl

	# some cleanup (imported from the old maintainer and needs more investigation)
	find `pwd`/debian/libapache-mod-perl \( -name .packlist -o -name perllocal.pod \) -exec \
		rm -f '{}' \;
	find `pwd`/debian/libapache-mod-perl -type f \( -name \*.pm -o -name \*.pl \) \
		-exec chmod a-x '{}' \;
	find `pwd`/debian/libapache-mod-perl -type f -name .cvsignore -exec rm '{}' ';'
	find `pwd`/debian/libapache-mod-perl -type f -name mod_perl.exp -exec rm '{}' ';'
	-find `pwd`/debian/libapache-mod-perl -type d -print0 | xargs -0 \
		--no-run-if-empty rmdir -p --ignore-fail-on-non-empty
	touch $(STAMP_DIR)/install-stamp-mod-perl

# since we know perform install: only once we need to clean up
# debhelper files since they are not idempotent
pre-binary:
	rm -f debian/*.debhelper

# Build architecture-independent files here.
binary-indep: build install
	@echo -e "\n\n*** Building architecture indepdendent packages ***\n\n"
	dh_testdir -i
	dh_testroot -i
	dh_installdocs -i -A debian/README.Debian debian/TODO.Debian
	dh_installexamples -i
	dh_installmenu -i
	dh_installdebconf -i
	dh_installlogrotate -i
#	dh_installcron -i
	dh_installchangelogs -i $(V)/src/CHANGES
	dh_link -i
	dh_compress -i
	dh_fixperms -i --exclude=suexec.disabled
	dh_installdeb -i
	dh_gencontrol -i -- -isp -Vnext:Major=$(APACHE_NEXT_MAJOR)
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	@echo -e "\n\n*** Building architecture specific packages ***\n\n"
	dh_testdir -a
	dh_testroot -a
	dh_installdocs -a -A debian/README.Debian debian/TODO.Debian
	dh_installexamples -a
	dh_installmenu -a
	dh_installinit -a -- defaults 91
	dh_installdebconf -a
	dh_installlogrotate -a
#	dh_installcron -a
	dh_installchangelogs -a $(V)/src/CHANGES
	(cd debian/libapache-mod-perl/usr/share/doc/libapache-mod-perl && mv Changes changelog)
	dh_strip -a --exclude=dbg
	dh_link -a
#	This avoids a lintian warning by breaking policy -- fun, eh?	
	dh_compress -a --exclude=log_server_status \
		--exclude=httpd.conf --exclude=access.conf --exclude=srm.conf
	dh_fixperms -a --exclude=suexec.disabled --exclude=var/cache/apache
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a -- -isp -Vnext:Major=$(APACHE_NEXT_MAJOR)
	dh_gencontrol -v -plibapache-mod-perl -- -Vnext:Major=$(APACHE_NEXT_MAJOR) \
		      -v$(PERL_MAJOR)$(PERL_MINOR)-$(DEB_REVISION)
	dh_md5sums -a
	dh_builddeb -a

clean:
	dh_testdir
	dh_testroot
	rm -f debian/apache{,-ssl,-perl}.{presubj,init,conffiles,config,dirs,docs,examples,lintian,intro.html}
	rm -f debian/apache{,-ssl,-perl}.{logrotate,postinst,postrm,preinst,prerm,httpd.conf}
	rm -f debian/apaci{,-ssl,-perl,.append{,-ssl,-perl}}
	rm -f debian/{apache-common.examples,apache-dev.docs,libapache-mod-perl.docs}
	rm -f debian/{*.gz,local-apxs*,apxs*} o debian/o debian/buildinfo.Debian
	rm -rf debian/logos debian/logos.ssl
	chmod +x debian/{ubersed,modules-config,sys-build.mk,scripts/*.*,scripts/modchk}
	$(MAKE) -f debian/sys-build.mk source.clean
	rm -rf $(SOURCE_DIR)-*
	rm -rf debian.diff debian/stampdir
	rm -rf $(D)
	dh_clean

binary: pre-binary binary-indep binary-arch
	echo -e "\n\n*** HEY THIS IS YOUR LUCKY DAY! ***\n\n"

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