| 1 |
#!/usr/bin/make -f |
| 2 |
export DH_OPTIONS |
| 3 |
|
| 4 |
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) |
| 5 |
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) |
| 6 |
DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU) |
| 7 |
DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU) |
| 8 |
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) |
| 9 |
|
| 10 |
# Handle x86_64 -> x86-64 |
| 11 |
HOST_GNU_TYPE_PKG=$(subst _,-,$(DEB_HOST_GNU_TYPE)) |
| 12 |
|
| 13 |
# Calculating musl based architecture |
| 14 |
MUSL_ARCH=$(DEB_HOST_GNU_CPU) |
| 15 |
MUSL_TRIPLE=$(DEB_HOST_GNU_CPU)-linux-musl |
| 16 |
|
| 17 |
ifneq (,$(findstring armel,$(DEB_HOST_ARCH))) |
| 18 |
MUSL_ARCH=arm |
| 19 |
MUSL_TRIPLE=arm-linux-musleabi |
| 20 |
endif |
| 21 |
|
| 22 |
ifneq (,$(findstring armhf,$(DEB_HOST_ARCH))) |
| 23 |
MUSL_ARCH=armhf |
| 24 |
MUSL_TRIPLE=arm-linux-musleabihf |
| 25 |
endif |
| 26 |
|
| 27 |
ifeq ($(DEB_HOST_ARCH_CPU),i386) |
| 28 |
MUSL_ARCH=i386 |
| 29 |
MUSL_TRIPLE=i386-linux-musl |
| 30 |
endif |
| 31 |
|
| 32 |
ifeq ($(DEB_HOST_ARCH_CPU),sh4) |
| 33 |
MUSL_ARCH=sh |
| 34 |
MUSL_TRIPLE=sh-linux-musl |
| 35 |
endif |
| 36 |
|
| 37 |
ifneq (,$(findstring ppc64el,$(DEB_HOST_ARCH))) |
| 38 |
export DEB_CFLAGS_MAINT_APPEND += -mlong-double-64 |
| 39 |
endif |
| 40 |
|
| 41 |
export MUSL_ARCH |
| 42 |
export MUSL_TRIPLE |
| 43 |
|
| 44 |
CC=$(DEB_HOST_GNU_TYPE)-gcc |
| 45 |
CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- |
| 46 |
export CROSS_COMPILE |
| 47 |
|
| 48 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto |
| 49 |
|
| 50 |
# Substitute control file variables depending on the debian libc type |
| 51 |
# If musl is the native libc, we can provide libc and depend on linux-libc-dev |
| 52 |
ifneq (,$(filter musl-%,$(DEB_HOST_ARCH))) |
| 53 |
GENCTRL_OPTIONS = -Vlibc-dev:Provides=libc-dev -Vlinux-libc-dev:Depends=linux-libc-dev |
| 54 |
GCC_WRAPPER = no |
| 55 |
else |
| 56 |
GENCTRL_OPTIONS = -Vgcc:Depends=gcc-$(HOST_GNU_TYPE_PKG) |
| 57 |
GCC_WRAPPER = yes |
| 58 |
endif |
| 59 |
|
| 60 |
%: |
| 61 |
dh $@ |
| 62 |
|
| 63 |
debian/scripts/$(MUSL_TRIPLE).path: debian/scripts/config.path.in |
| 64 |
sed 's/@MUSL_TRIPLE@/$(MUSL_TRIPLE)/g' $< > $@ |
| 65 |
cp debian/scripts/$(MUSL_TRIPLE).path debian/scripts/ld-musl-$(MUSL_ARCH).path |
| 66 |
|
| 67 |
copy_fts: |
| 68 |
mkdir -p src/fts |
| 69 |
cp debian/musl-fts/fts.c debian/musl-fts/config.h src/fts/ |
| 70 |
cp debian/musl-fts/fts.h include/ |
| 71 |
|
| 72 |
override_dh_auto_configure: debian/scripts/$(MUSL_TRIPLE).path copy_fts |
| 73 |
dh_auto_configure -- --libdir=/usr/lib/$(MUSL_TRIPLE) --includedir=/usr/include/$(MUSL_TRIPLE) --host=$(DEB_HOST_GNU_TYPE) --enable-gcc-wrapper=$(GCC_WRAPPER) --enable-debug |
| 74 |
|
| 75 |
execute_after_dh_auto_install: |
| 76 |
rm debian/tmp/usr/include/$(MUSL_TRIPLE)/crypt.h debian/tmp/usr/lib/$(MUSL_TRIPLE)/libcrypt.a |
| 77 |
|
| 78 |
execute_after_dh_install: |
| 79 |
ifeq ($(GCC_WRAPPER),yes) |
| 80 |
mkdir -p debian/musl-dev/usr/bin |
| 81 |
mv debian/tmp/usr/bin/musl-gcc debian/musl-dev/usr/bin/$(MUSL_TRIPLE)-gcc |
| 82 |
mv debian/tmp/usr/lib/$(MUSL_TRIPLE)/musl-gcc.specs debian/musl-dev/usr/lib/$(MUSL_TRIPLE)/musl-gcc.specs |
| 83 |
endif |
| 84 |
|
| 85 |
override_dh_fixperms: |
| 86 |
dh_fixperms --exclude libc.so |
| 87 |
|
| 88 |
override_dh_gencontrol: |
| 89 |
dh_gencontrol -- $(GENCTRL_OPTIONS) |
| 90 |
|
| 91 |
override_dh_installdeb: |
| 92 |
sed 's/@MUSL_TRIPLE@/$(MUSL_TRIPLE)/g' \ |
| 93 |
debian/musl-dev.postinst.in > debian/musl-dev.postinst |
| 94 |
sed 's/@MUSL_TRIPLE@/$(MUSL_TRIPLE)/g' \ |
| 95 |
debian/musl-dev.postrm.in > debian/musl-dev.postrm |
| 96 |
dh_installdeb |
| 97 |
|
| 98 |
override_dh_installchangelogs: |
| 99 |
dh_installchangelogs WHATSNEW |