#!/usr/bin/make -f include /usr/share/dpkg/architecture.mk include /usr/share/dpkg/buildflags.mk %: dh $@ export DH_VERBOSE = 1 CC = gcc VERSION := $(shell dpkg-parsechangelog | perl -ne '/Version:\s+(.+)-[^-]+/ && print $1') # We must have this libraries so packages can be compiled, # but if we just use filters provided by illumos gate, it causes # some rare FTBFS with GNU ld. We can't use symlink (e. g. libpthread -> libc), # because in this case libc can go before libgcc_s, and some other packages # will crash in runtime. So we make a dummy library. libs_filters := \ libaio \ libdoor \ libintl \ libpthread \ librt \ libsendfile \ libthread \ libxnet \ fake_libs := \ $(libs_filters) \ libposix4 \ libdl \ # These lists are used in packing orig tarball # and in building binaries. Anything that need a # special way of building is extracted in a special way too, # for example ld and ldd. # XXX order is important for building: # usr/src/lib/* : libs := \ common \ libavl \ libc \ libc_db \ libgen \ libcrypt \ libmd \ libmp \ libnsl \ libresolv \ libresolv2 \ librpcsvc \ libsecdb \ libsocket \ crypt_modules \ $(libs_filters) # usr/src/lib/nsswitch/* : nsswitch := \ files \ user \ nis \ dns \ compat \ # XXX order is important for building # usr/src/cmd/sgs/* : sgs := \ libconv \ libdl \ liblddbg \ libelf \ libld \ librtld \ librtld_db \ rtld \ lddstub \ crle \ # usr/src/cmd/* for libc functionality: cmd := \ utmp_update \ utmpd \ zic \ getconf \ locale \ localedef \ zdump \ rpcinfo \ rpcgen \ getent \ gencat \ man1 := $(filter-out utmp_update,$(cmd)) man1 += $(filter-out lib% lddstub rtld, $(sgs) ld ldd) # usr/src/common: common := \ atomic \ avl \ crypto \ dtrace \ elfcap \ sgsrtcid \ unicode \ util \ xattr \ BUILD = build-tree ROOT = $(BUILD)/root ILLUMOS_GATE = illumos-gate $(ILLUMOS_GATE): dh_illumos_gate --checkout --destdir=$(ILLUMOS_GATE) .PHONY: create-orig create-orig: $(ILLUMOS_GATE) dh_illumos_gate --create-orig --build \ $(ILLUMOS_GATE)/usr/src/cmd/netfiles \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/Makefile* \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/include \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/ld \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/ldd \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/messages \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/packages/common/SUNWonld-README \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/packages/common/readme_revision \ $(ILLUMOS_GATE)/usr/src/cmd/sgs/tools \ $(ILLUMOS_GATE)/usr/src/head \ $(ILLUMOS_GATE)/usr/src/lib/nsswitch/Makefile* \ $(ILLUMOS_GATE)/usr/src/man/man2/\*.2 \ $(ILLUMOS_GATE)/usr/src/man/man3/\*.3 \ $(ILLUMOS_GATE)/usr/src/man/man3c/\*.3c \ $(ILLUMOS_GATE)/usr/src/man/man4/crypt.conf.4 \ $(ILLUMOS_GATE)/usr/src/man/man5/crypt_\*.5 \ $(ILLUMOS_GATE)/usr/src/uts/\*/\*/krtld \ $(ILLUMOS_GATE)/usr/src/uts/\*/krtld \ $(ILLUMOS_GATE)/usr/src/uts/common/sys/avl*.h \ $(cmd:%=$(ILLUMOS_GATE)/usr/src/cmd/%) \ $(common:%=$(ILLUMOS_GATE)/usr/src/common/%) \ $(libs:%=$(ILLUMOS_GATE)/usr/src/lib/%) \ $(man1:%=$(ILLUMOS_GATE)/usr/src/man/man1\*/%.\*) \ $(nsswitch:%=$(ILLUMOS_GATE)/usr/src/lib/nsswitch/%) \ $(sgs:%=$(ILLUMOS_GATE)/usr/src/cmd/sgs/%) \ test-orig: create-orig ./debian/rules clean rm -rf usr .pc tar xf ../libc_$(VERSION).orig.tar.xz --strip=1 quilt push -a ./debian/rules build fakeroot ./debian/rules binary # libs having "install_h" target to install headers first: libs_headers := \ libc \ libmd \ libsocket \ libnsl \ libgen \ override_dh_auto_configure: dh_illumos_gate --configure --destdir=$(BUILD) --root=$(ROOT) echo 'export DEB_CRYPT_MODULE_DIR_32="$$DEB_LIBDIR_32/security"' >> $(BUILD)/usr/env.sh echo 'export DEB_CRYPT_MODULE_DIR_64="$$DEB_LIBDIR_64/security"' >> $(BUILD)/usr/env.sh find $(BUILD)/usr/src/head -name \*.x -exec ./debian/fix.x.pl {} \; override_dh_auto_build: . $(BUILD)/usr/env.sh; mkdir -p \ $(ROOT)/$$DEB_CRYPT_MODULE_DIR_32 \ $(ROOT)/$$DEB_CRYPT_MODULE_DIR_64 \ $(ROOT)/$$DEB_LIBDIR_32 \ $(ROOT)/$$DEB_LIBDIR_64 \ $(ROOT)/$$DEB_USRLIBDIR_32 \ $(ROOT)/$$DEB_USRLIBDIR_64 \ $(ROOT)/etc/default \ $(ROOT)/usr/include/sys \ $(ROOT)/usr/bin \ $(ROOT)/usr/sbin # We are changing soname, but keep links for build time. # These links also will go into libsunXXX-dev packages. # Watch out: libc build-conflicts with other libelf-dev and libavl-dev # implementations, and libsunXXX-dev will do too. . $(BUILD)/usr/env.sh; \ ln -svf $$ROOT/$$DEB_LIBDIR_32/libsunelf.so.1 \ $$ROOT/$$DEB_USRLIBDIR_32/libelf.so && \ ln -svf $$ROOT/$$DEB_LIBDIR_64/libsunelf.so.1 \ $$ROOT/$$DEB_USRLIBDIR_64/libelf.so && \ ln -svf $$ROOT/$$DEB_LIBDIR_32/libsunavl.so.1 \ $$ROOT/$$DEB_USRLIBDIR_32/libavl.so && \ ln -svf $$ROOT/$$DEB_LIBDIR_64/libsunavl.so.1 \ $$ROOT/$$DEB_USRLIBDIR_64/libavl.so # This is for ld and other to find the right library: . $(BUILD)/usr/env.sh; \ ln -svf $$ROOT/$$DEB_LIBDIR_32/libld.so.4 \ $$ROOT/$$DEB_USRLIBDIR_32/libld.so && \ ln -svf $$ROOT/$$DEB_LIBDIR_64/libld.so.4 \ $$ROOT/$$DEB_USRLIBDIR_64/libld.so && \ ln -svf $$ROOT/$$DEB_LIBDIR_32/liblddbg.so.4 \ $$ROOT/$$DEB_USRLIBDIR_32/liblddbg.so && \ ln -svf $$ROOT/$$DEB_LIBDIR_64/liblddbg.so.4 \ $$ROOT/$$DEB_USRLIBDIR_64/liblddbg.so # install headers dh_illumos_make $(make) $(BUILD)/usr/src/head -t install_h dh_illumos_make $(make) $(libs_headers:%=$(BUILD)/usr/src/lib/%) -t install_h cp -vf $(BUILD)/usr/src/uts/common/sys/avl*.h $(ROOT)/usr/include/sys/ cp -vrf debian/compat_headers/* $(ROOT)/usr/include/ # build libs # libutil is brought by our patch, it's not a part of the gate dh_illumos_make $(patsubst %,$(BUILD)/usr/src/lib/%,$(libs) libutil) dh_illumos_make $(nsswitch:%=$(BUILD)/usr/src/lib/nsswitch/%) # build sgs dh_illumos_make --native $(BUILD)/usr/src/cmd/sgs/tools dh_illumos_make $(sgs:%=$(BUILD)/usr/src/cmd/sgs/%) cp usr/src/man/man1/ld.1 $(BUILD)/usr/src/man/man1/sunld.1 # these two are patched: dh_illumos_make --native \ $(BUILD)/usr/src/cmd/sgs/ld/i386 \ $(BUILD)/usr/src/cmd/sgs/ldd/i386 \ # build tools: dh_illumos_make --native $(make) $(cmd:%=$(BUILD)/usr/src/cmd/%) . $(BUILD)/usr/env.sh; unset LD_ALTEXEC; \ $(CC) $(CFLAGS) -o $(ROOT)/usr/bin/crle \ -DDEB_USRLIBDIR_32=\"$$DEB_USRLIBDIR_32\" \ -DDEB_USRLIBDIR_64=\"$$DEB_USRLIBDIR_64\" \ -DDEB_HOST_ARCH_BITS=$$DEB_HOST_ARCH_BITS \ debian/crle.c override_dh_auto_install: rm -rf debian/tmp cp -a $(ROOT) debian/tmp for l in `find debian/tmp/lib32 -maxdepth 1 -type l -name \*.so`; do \ ln -sf `readlink -f $$l` debian/tmp/usr/lib32/`basename $$l`; \ rm $$l; \ done for l in `find debian/tmp/lib/$(DEB_HOST_MULTIARCH) -maxdepth 1 -type l -name \*.so`; do \ ln -sf `readlink -f $$l` debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/`basename $$l`; \ rm $$l; \ done symlinks -c debian/tmp/usr/lib32 symlinks -c debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) set -x; for l in $(subst lib,,$(fake_libs)); do \ rm -f debian/tmp/usr/lib32/lib$$l.so && \ rm -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lib$$l.so && \ echo "ASSERT(1, \"This is a fake library: ld -l$$l works, but nothing is linked\")" > debian/tmp/usr/lib32/lib$$l.so && \ echo "ASSERT(1, \"This is a fake library: ld -l$$l works, but nothing is linked\")" > debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/lib$$l.so; \ done : # Make everybody happy: rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libc.so echo 'INPUT(libc.so.1 AS_NEEDED(-lsocket -lnsl -lresolv -liconv /usr/lib/$(DEB_HOST_MULTIARCH)/libssp.so.0))' \ > debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libc.so : # Even sunld: ln -sf libc.so.1 debian/tmp/lib/$(DEB_HOST_MULTIARCH)/libc.so override_dh_install: debian/LC_DATA.gz debian/locales.config dh_install find debian/locales/usr/share/i18n/locales -name *.UTF-8.src | \ xargs sed -i '/^LC_CTYPE/,/^END LC_CTYPE/d' ./debian/generate-locales-all override_dh_installman: # language=C because of ld.so.1.1 dh_installman --language=C override_dh_strip: : # we don't strip *this* libc override_dh_fixperms: dh_fixperms chmod 0755 \ debian/*/usr/lib/*/lddstub \ debian/*/usr/lib?*/lddstub \ debian/*/usr/lib/*/crle \ debian/*/usr/lib?*/crle \ debian/*/lib/*/ld.so.* \ debian/*/lib?*/ld.so.* chmod 4755 debian/*/usr/lib/utmp_update override_dh_makeshlibs: dh_makeshlibs -- -c4 # We remove LC_DATA from all *.UTF-8.src # and when regenerating locales will insert contents of LC_DATA # into source locale file. Illumos localedef does not support # copy action for including other files source files. debian/LC_DATA.gz: sh $(BUILD)/usr/src/cmd/localedef/data/ctype.sh \ $(BUILD)/usr/src/cmd/localedef/data/*.UTF-8.src \ | gzip -c -9 > $@ debian/locales.config: debian/locales.config.in perl -pe 'BEGIN {undef $$/; open(IN, "debian/SUPPORTED"); $$j=;} s/__PROVIDED_LOCALES__/$$j/g;' \ $< > $@ override_dh_auto_clean: rm -rf $(BUILD) rm -f debian/LC_DATA.* rm -f debian/locales.config