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
|
#!/usr/bin/make -f
#
# debian/rules for perl.
#
export SHELL = /bin/sh
fullversion := $(shell /bin/bash debian/config.debian --full-version)
version := $(shell /bin/bash debian/config.debian --version)
installtype := $(shell /bin/bash debian/config.debian --install-type)
test_target := $(shell /bin/bash debian/config.debian --test-target)
strip := $(shell /bin/bash debian/config.debian --strip)
srcdir := $(shell pwd)
packages := $(shell sed -n 's/^Package: *\(.*\)/\1/p' debian/control)
tmp = debian/tmp
bin = $(tmp)/usr/bin
man = $(tmp)/usr/share/man
lib = $(tmp)/usr/lib/perl/$(version)
share = $(tmp)/usr/share/perl/$(version)
build = debian/build
patches = patches-applied
checkdir = test -d debian
checkroot = test `id -u` -eq 0
checkperl = $(SHELL) debian/checkperl
# control file substitutions
subst_upstream = -VUpstream-Version=$(fullversion)
subst_perlapi = -Vperlapi:Provides="`./perl.static debian/mkprovides`"
build: build-stamp
install: install-stamp
build-stamp: perl.static perl.debug libperl.so.$(fullversion)
touch $@
config.over: debian/config.over
cp $? $@
perl.static: config.over
$(checkdir)
rm -f libperl.so* # must be built last
-$(MAKE) distclean
$(SHELL) debian/config.debian --static
$(MAKE) perl $(test_target)
mv libperl.a libperl-static
mv perl perl.static
perl.debug: config.over
$(checkdir)
rm -f libperl.so* # must be built last
-$(MAKE) distclean
$(SHELL) debian/config.debian --debug
$(MAKE) perl
mv libperl.a libperl-debug
mv perl perl.debug
libperl.so.$(fullversion): config.over
$(checkdir)
-$(MAKE) distclean
$(SHELL) debian/config.debian --shared
$(MAKE) SHRPLDFLAGS='$$(LDDLFLAGS) -Wl,-soname,libperl.so.$(version)' $@
ln -s libperl.so.$(fullversion) libperl.so.$(version)
ln -s libperl.so.$(version) libperl.so
$(MAKE) all $(test_target) || { rm -f libperl.so*; exit 1; }
clean:
$(checkdir)
$(checkroot)
test -f $(patches) # maintainer sanity check
-$(MAKE) distclean
rm -rf config.over perl.static perl.debug libperl-static \
libperl-debug libperl.so* build-stamp install-stamp \
t/auto debian/shlibs.local debian/perl-base.shlibs \
debian/libperl$(version).shlibs debian/substvars \
debian/files debian/list.tmp $(tmp) $(build)
install-stamp: build-stamp
$(checkperl)
$(checkroot)
$(checkdir)
rm -rf $(tmp) $(build)
$(MAKE) install
# remove temporary prefix on install vars and switch man
# extensions to 1p and 3pm for vendor module installs
./perl.static -i -pe 's!$(srcdir)/$(tmp)/!/! if /install/;' \
-e 's/^(man1ext=).*/$$1'\''1p'\''/;' \
-e 's/^(man3ext=).*/$$1'\''3pm'\''/;' \
$(lib)/Config.pm $(lib)/Config_heavy.pl
# convert required header files
-cd /usr/include; $(srcdir)/perl.static -I $(srcdir)/lib \
$(srcdir)/utils/h2ph -a -d $(srcdir)/$(lib) \
`cat $(srcdir)/debian/headers`
# fix up generated headers
./perl.static -Ilib debian/fixheaders $(lib)
# simple wrapper around Errno module
cp debian/errno.ph $(lib)
# remove some cruft
rm -f $(bin)/suidperl
rm -f $(lib)/.packlist
rm -f $(lib)/CORE/sperl.o
# installperl copies the symlinks as a files
rm -f $(lib)/CORE/libperl.so $(lib)/CORE/libperl.so.$(version)
# remove versioned binary, relink after moving files
rm -f $(bin)/perl$(fullversion)
# relocate perl libraries and create links
cp libperl-static $(tmp)/usr/lib/libperl.a
cp libperl-debug $(tmp)/usr/lib/libperld.a
mv $(lib)/CORE/libperl.so.$(fullversion) $(tmp)/usr/lib
ln -s libperl.so.$(fullversion) $(tmp)/usr/lib/libperl.so.$(version)
ln -s libperl.so.$(version) $(tmp)/usr/lib/libperl.so
# move to full version (symlinks created in perl-base below)
mv $(lib) $(tmp)/usr/lib/perl/$(fullversion)
mv $(share) $(tmp)/usr/share/perl/$(fullversion)
ifeq ($(installtype),static)
cp perl.static $(bin)/perl
endif
# install debug binary as debugperl
cp perl.debug $(bin)/debugperl
# split packages
for p in $(packages); \
do \
test -f debian/$$p.files || exit 1; \
mkdir -p $(build)/$$p; \
(cd $(tmp); \
find `cat ../$$p.files ../$$p.files.$(installtype) 2>/dev/null` \
! -type d) >debian/list.tmp; \
(cd $(tmp); cpio -vdumpl ../build/$$p) <debian/list.tmp 2>&1 | \
grep -v ' linked to '; \
(cd $(tmp); ../../perl.static -nle unlink) <debian/list.tmp; \
done
# ensure that all file have been moved from debian/tmp
test `find $(tmp) ! -type d | wc -l` -eq 0
# move pod out of -base modules and into .pod files in -doc
./perl.static debian/splitdoc $(build)/perl-base
# re-create versioned link so that suidperl works
ln $(build)/perl-base/usr/bin/perl \
$(build)/perl-base/usr/bin/perl$(fullversion)
# provide suidperl link
ln -s perl $(build)/perl-suid/usr/bin/suidperl
# create symlinks to match @INC
ln -s $(fullversion) $(build)/perl-base/usr/lib/perl/$(version)
ln -s $(fullversion) $(build)/perl-base/usr/share/perl/$(version)
# move section 1 manual pages back to perl for installed programs
mkdir -p $(build)/perl/usr/share/man/man1
find $(build)/perl/usr/bin -type f -printf "%f\n" | \
while read prog; \
do \
m=$(build)/perl-doc/usr/share/man/man1/$$prog.1; \
if test -f $$m; \
then \
mv $$m $(build)/perl/usr/share/man/man1; \
else \
echo "warning: no manual page for $$prog" >&2; \
fi; \
done
# remove some linked man pages (symlinked later and cause
# problems as-is when compressing)
rm -f $(build)/perl/usr/share/man/man1/pstruct.1 \
$(build)/perl/usr/share/man/man1/psed.1
# the diagnostics module needs perldiag.pod
mkdir $(build)/perl-modules/usr/share/perl/$(fullversion)/pod
mv $(build)/perl-doc/usr/share/perl/$(fullversion)/pod/perldiag.pod \
$(build)/perl-modules/usr/share/perl/$(fullversion)/pod
# copy dummy perldoc to perl package
cp debian/perl.perldoc $(build)/perl/usr/bin/perldoc
chmod 755 $(build)/perl/usr/bin/perldoc
# install rename script to bin (as prename, alternative configured)
cp debian/rename $(build)/perl/usr/bin/prename
chmod 755 $(build)/perl/usr/bin/prename
./perl.static -Ilib $(build)/perl/usr/bin/pod2man --official \
debian/rename >$(build)/perl/usr/share/man/man1/prename.1
# install docs
for p in $(packages); \
do \
doc=$(build)/$$p/usr/share/doc; \
test -d $$doc || mkdir -p $$doc; \
if test -f debian/$$p.docs; \
then \
while read src target; \
do \
d=`expr $$target : '\([^/][^/]*\)'`; \
test -d $$doc/$$d || mkdir $$doc/$$d; \
cp -p $$src $$doc/$$target; \
done <debian/$$p.docs; \
fi; \
test -d $$doc/$$p || ln -s perl $$doc/$$p; \
done
# move module docs to /usr/share/doc/perl
while read src target; \
do \
doc=$(build)/perl-doc/usr/share/doc/perl/$$target; \
test -d $$doc || mkdir $$doc; \
mv $(build)/perl-modules/usr/share/perl/$(fullversion)/$$src $$doc; \
done <debian/perl-doc.moduledocs
# remove empty directories left after moving module docs
find $(build)/perl-modules/usr/share/perl/$(fullversion) \
-depth -type d -empty | xargs -r rmdir
# want these in /etc since /usr may not be writable
mkdir -p $(build)/perl-modules/etc/perl/CPAN \
$(build)/perl-modules/etc/perl/Net
# default configuration for libnet
cp debian/libnet.cfg $(build)/perl-modules/etc/Net
# compress
find $(build)/*/usr/share/man -type f -print | xargs -r gzip -9
find $(build)/*/usr/share/doc -type f \
\( -name changelog\* -o \( -size +4k ! -name copyright \) \) \
-print | xargs -r gzip -9
ifeq ($(strip),yes)
# strip
find $(build)/*/usr/bin $(build)/*/usr/lib -type f \
\( -name \*.so\* -o -name \*.a -o -perm +111 \) -print | \
grep -v ^$(build)/perl-debug/ | \
while read f; \
do \
case `file $$f` in \
*ELF*) strip --remove-section=.comment \
--remove-section=.note $$f;; \
esac; \
done
endif
# fixperms
find $(build) -print | xargs -r chown -h root:root
find $(build) -type d -print | xargs -r chmod 755
find $(build) -type f -print | xargs -r chmod go=rX,u+rw,a-s
find $(build)/*/usr/bin -type f -print | xargs -r chmod a+x
find $(build)/*/usr/lib -type f -name \*.so\* -print | xargs -r chmod a-x
find $(build)/*/usr/share/doc $(build)/*/usr/share/man -type f \
-print | xargs -r chmod 644
# suidperl needs to be...
chmod u+s $(build)/perl-suid/usr/bin/sperl$(fullversion)
# links
mkdir -p $(build)/perl-debug/usr/share/man/man1 \
$(build)/perl-suid/usr/share/man/man1
ln -s perl.1.gz $(build)/perl-debug/usr/share/man/man1/debugperl.1.gz
ln -s perl.1.gz $(build)/perl-suid/usr/share/man/man1/suidperl.1.gz
ln -s c2ph.1.gz $(build)/perl/usr/share/man/man1/pstruct.1.gz
ln -s s2p.1.gz $(build)/perl/usr/share/man/man1/psed.1.gz
ln -s changelog.gz $(build)/perl/usr/share/doc/perl/Changes.gz
ln -s ../perl/changelog.gz \
$(build)/libcgi-fast-perl/usr/share/doc/libcgi-fast-perl/changelog.gz
touch $@
# Build architecture-independent files here.
binary-indep: build-stamp install-stamp
$(checkdir)
$(checkroot)
rm -f debian/substvars
for p in `./perl.static -l -00ne 'print $$1 if /^Architecture:\s+all/m \
and /^Package:\s+(.*)/m' debian/control`; \
do \
rm -rf $(build)/$$p/DEBIAN; \
mkdir $(build)/$$p/DEBIAN; \
chmod 755 $(build)/$$p/DEBIAN; \
for c in preinst postinst prerm postrm; \
do \
test -f debian/$$p.$$c || continue; \
cp debian/$$p.$$c $(build)/$$p/DEBIAN/$$c; \
chmod 755 $(build)/$$p/DEBIAN/$$c; \
done; \
test -d $(build)/$$p/etc && find $(build)/$$p/etc -type f \
-printf '/etc/%P\n' >$(build)/$$p/DEBIAN/conffiles; \
(cd $(build)/$$p; find usr -type f -print | xargs -r md5sum) \
>$(build)/$$p/DEBIAN/md5sums; \
dpkg-gencontrol -p$$p -isp -P$(build)/$$p $(subst_upstream); \
dpkg --build $(build)/$$p ..; \
done
# Build architecture-dependent files here.
binary-arch: build-stamp install-stamp
$(checkdir)
$(checkroot)
ifeq ($(installtype),static)
echo 'libperl $(version) libperl$(version) (= $${Source-Version})' \
>debian/shlibs.local
echo 'libperl $(version) libperl$(version) (>= $(fullversion))' \
>debian/libperl$(version).shlibs
else
echo 'libperl $(version)' >debian/shlibs.local
echo 'libperl $(version) libperl$(version) (>= $(fullversion))' \
>debian/perl-base.shlibs
endif
for p in `./perl.static -l -00ne 'print $$1 if /^Architecture:\s+any/m \
and /^Package:\s+(.*)/m' debian/control`; \
do \
rm -rf $(build)/$$p/DEBIAN debian/substvars; \
mkdir $(build)/$$p/DEBIAN; \
for c in preinst postinst prerm postrm; \
do \
test -f debian/$$p.$$c || continue; \
cp debian/$$p.$$c $(build)/$$p/DEBIAN/$$c; \
chmod 755 $(build)/$$p/DEBIAN/$$c; \
done; \
test -f debian/$$p.shlibs && cp debian/$$p.shlibs \
$(build)/$$p/DEBIAN/shlibs; \
(cd $(build)/$$p; find usr -type f -print | xargs -r md5sum) \
>$(build)/$$p/DEBIAN/md5sums; \
LD_LIBRARY_PATH=$$LD_LIBRARY_PATH$${LD_LIBRARY_PATH:+:}/usr/lib:$(srcdir)/$(build)/libperl$(version)/usr/lib; \
find $(build)/$$p/usr -type f \
\( -perm +111 -o -name \*.so\* \) -print | \
xargs -r dpkg-shlibdeps; \
dpkg-gencontrol -p$$p -isp -P$(build)/$$p $(subst_perlapi) $(subst_upstream); \
dpkg --build $(build)/$$p ..; \
done
binary: binary-indep binary-arch
# maintainer targets
patch:
test ! -f $(patches) # already patched
ls debian/patches/* >$(patches)
cat `cat $(patches)` | patch -p1 --no-backup-if-mismatch
unpatch:
test -f $(patches) # not patched
cat `tac $(patches)` | patch -Rp1 --no-backup-if-mismatch
rm -f $(patches)
.PHONY: build clean binary-indep binary-arch binary install patch unpatch
|