File: rules

package info (click to toggle)
musl 1.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,020 kB
  • sloc: ansic: 85,404; asm: 7,109; sh: 809; awk: 301; makefile: 231; sed: 9
file content (99 lines) | stat: -rwxr-xr-x 3,016 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
#!/usr/bin/make -f
export DH_OPTIONS

DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

# Handle x86_64 -> x86-64
HOST_GNU_TYPE_PKG=$(subst _,-,$(DEB_HOST_GNU_TYPE))

# Calculating musl based architecture
MUSL_ARCH=$(DEB_HOST_GNU_CPU)
MUSL_TRIPLE=$(DEB_HOST_GNU_CPU)-linux-musl

ifneq (,$(findstring armel,$(DEB_HOST_ARCH)))
  MUSL_ARCH=arm
  MUSL_TRIPLE=arm-linux-musleabi
endif

ifneq (,$(findstring armhf,$(DEB_HOST_ARCH)))
  MUSL_ARCH=armhf
  MUSL_TRIPLE=arm-linux-musleabihf
endif

ifeq ($(DEB_HOST_ARCH_CPU),i386)
  MUSL_ARCH=i386
  MUSL_TRIPLE=i386-linux-musl
endif

ifeq ($(DEB_HOST_ARCH_CPU),sh4)
  MUSL_ARCH=sh
  MUSL_TRIPLE=sh-linux-musl
endif

ifneq (,$(findstring ppc64el,$(DEB_HOST_ARCH)))
  export DEB_CFLAGS_MAINT_APPEND += -mlong-double-64
endif

export MUSL_ARCH
export MUSL_TRIPLE

CC=$(DEB_HOST_GNU_TYPE)-gcc
CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
export CROSS_COMPILE

export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto

# Substitute control file variables depending on the debian libc type
# If musl is the native libc, we can provide libc and depend on linux-libc-dev
ifneq (,$(filter musl-%,$(DEB_HOST_ARCH)))
  GENCTRL_OPTIONS = -Vlibc-dev:Provides=libc-dev -Vlinux-libc-dev:Depends=linux-libc-dev
  GCC_WRAPPER = no
else
  GENCTRL_OPTIONS = -Vgcc:Depends=gcc-$(HOST_GNU_TYPE_PKG)
  GCC_WRAPPER = yes
endif

%:
	dh $@

debian/scripts/$(MUSL_TRIPLE).path: debian/scripts/config.path.in
	sed 's/@MUSL_TRIPLE@/$(MUSL_TRIPLE)/g' $< > $@
	cp debian/scripts/$(MUSL_TRIPLE).path debian/scripts/ld-musl-$(MUSL_ARCH).path

copy_fts:
	mkdir -p src/fts
	cp debian/musl-fts/fts.c debian/musl-fts/config.h src/fts/
	cp debian/musl-fts/fts.h include/

override_dh_auto_configure: debian/scripts/$(MUSL_TRIPLE).path copy_fts
	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

execute_after_dh_auto_install:
	rm debian/tmp/usr/include/$(MUSL_TRIPLE)/crypt.h debian/tmp/usr/lib/$(MUSL_TRIPLE)/libcrypt.a

execute_after_dh_install:
ifeq ($(GCC_WRAPPER),yes)
	mkdir -p  debian/musl-dev/usr/bin
	mv debian/tmp/usr/bin/musl-gcc debian/musl-dev/usr/bin/$(MUSL_TRIPLE)-gcc
	mv debian/tmp/usr/lib/$(MUSL_TRIPLE)/musl-gcc.specs debian/musl-dev/usr/lib/$(MUSL_TRIPLE)/musl-gcc.specs
endif

override_dh_fixperms:
	dh_fixperms --exclude libc.so

override_dh_gencontrol:
	dh_gencontrol -- $(GENCTRL_OPTIONS)

override_dh_installdeb:
	sed 's/@MUSL_TRIPLE@/$(MUSL_TRIPLE)/g' \
		debian/musl-dev.postinst.in > debian/musl-dev.postinst
	sed 's/@MUSL_TRIPLE@/$(MUSL_TRIPLE)/g' \
		debian/musl-dev.postrm.in > debian/musl-dev.postrm
	dh_installdeb

override_dh_installchangelogs:
	dh_installchangelogs WHATSNEW