File: rules

package info (click to toggle)
gcc-sh-elf 8.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 140 kB
  • sloc: ansic: 237; makefile: 93; sh: 54
file content (126 lines) | stat: -rwxr-xr-x 5,476 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/make -f
include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildopts.mk
include /usr/share/dpkg/pkg-info.mk
DEB_BUILD_OPTION_PARALLEL ?= 1

# Some GCC sources use non-string literals as format strings,
# for example to define their own wrapper functions.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-format

gnu_type = sh-elf
gcc-version-major != sed -En 's/.*gcc-(.*)-source.*/\1/p' debian/control

# Version of the GCC source Debian package.
gcc-version	!= dpkg-query -Wf'$${source:Version}' gcc-$(gcc-version-major)-source
gdb-version	!= dpkg-query -Wf'$${source:Version}' gdb-source
newlib-upstream-version	!= dpkg-query -Wf'$${source:Upstream-Version}' newlib-source
newlib-source-version != dpkg-query -Wf'$${source:Version}' newlib-source

# https://gcc.gnu.org/install/configure.html recommends out-of-tree builds.
%:
	dh $@

execute_before_dh_update_autotools_config: src
src:
	tar -xf /usr/src/gcc-$(gcc-version-major)/gcc-*.tar.xz
	mv gcc-* $@
	rm -rf $@/zlib
# This first patch may be empty.
	patch -p1 -i /usr/src/gcc-$(gcc-version-major)/patches/git-updates.diff || true;
	patch -p1 -i /usr/src/gcc-$(gcc-version-major)/patches/gcc-gfdl-build.diff
	tar -xf /usr/src/newlib/newlib-*.tar.xz
	tar -xf /usr/src/gdb.tar.xz
	rm -rf gdb*/readline gdb*/zlib
# Symbolically link directories from GDB and Newlib into the GCC tree.
	cd $@ && for i in ../gdb*/* ../newlib*/*; \
	do \
		if [ ! -e `basename "$$i"` -a -d "$$i" ]; \
		then ln -s "$$i" . || exit 1; \
		fi; \
	done
# gcc's configure script is too old to build GDB right.
	cd $@ && rm -f Makefile.def Makefile.in configure
	cd $@ && cp ../gdb*/Makefile.def ../gdb*/Makefile.in ../gdb*/configure .

# Avoid dh_auto_*, see
# https://gcc.gnu.org/legacy-ml/gcc/2013-04/msg00171.html.

# gcc-major-version: for consistency with native gcc
CONFIG_OPTS = \
	--build=$(DEB_BUILD_GNU_TYPE) \
	--host=$(DEB_HOST_GNU_TYPE) \
	--target=$(gnu_type) \
	SED=/bin/sed \
	SHELL=/bin/sh \
	BASH=/bin/bash \
	CONFIG_SHELL=/bin/bash \
	--prefix=/usr \
	--disable-gdb \
	--disable-libcc1 \
	--enable-languages=c \
	--with-gcc-major-version-only \
	--without-included-gettext \
	--with-pkgversion='GCC $(gcc-version) Debian $(DEB_VERSION)' \
	--with-bugurl="https://www.debian.org/Bugs/" \
	--with-system-zlib \
	--with-newlib

override_dh_auto_configure bld:
	mkdir -p bld
	if echo $(DEB_BUILD_OPTIONS) | grep -q terse; \
	then QUIET_OPTS='--quiet --enable-silent-rules'; \
	fi; \
	cd bld && ../src/configure $(CONFIG_OPTS) $$QUIET_OPTS

override_dh_auto_build:
	$(MAKE) -C bld -j$(DEB_BUILD_OPTION_PARALLEL)

override_dh_auto_test:
# With GCC, it is normal and expected that some of the tests will fail.
# Running the tests allows checking for regressions by comparing build logs.
	$(MAKE) -C bld -j$(DEB_BUILD_OPTION_PARALLEL) check-gcc RUNTESTFLAGS="--target_board sh-sim"

override_dh_auto_install:
	$(MAKE) -C bld install DESTDIR=`pwd`/debian/gcc-$(gnu_type)
# The documentation is empty due to being licensed GFDL with invariant sections,
# and the localization files are provided by gcc-*-locales
	rm -r debian/gcc-$(gnu_type)/usr/share/info debian/gcc-$(gnu_type)/usr/share/man debian/gcc-$(gnu_type)/usr/share/locale
# The *.la files are unnecessary and strongly discouraged from being distributed in Debian.
	find debian/gcc-$(gnu_type) -name '*.la' -type f -exec rm {} \;
	$(MAKE) -C bld install-target-newlib DESTDIR=`pwd`/debian/libnewlib-$(gnu_type)-dev
# We installed everything into gcc-sh-elf and now prune out Newlib.
	cd debian/libnewlib-$(gnu_type)-dev && find * -type f -exec rm -rf ../gcc-$(gnu_type)/{} \;
	find debian/gcc-$(gnu_type) debian/libnewlib-$(gnu_type)-dev -type d -empty -delete
	if ! echo $(DEB_BUILD_OPTIONS) | grep -q nostrip; \
	then find debian/libnewlib-$(gnu_type)-dev/ -name '*.a' -exec \
		$(gnu_type)-strip --strip-unneeded --remove-section=.comment --remove-section=.note {} + ; \
	fi

# Shipping copyright information applicable to the binaries is required by Debian Policy.
execute_before_dh_installdocs: debian/gcc-$(gnu_type).copyright debian/libnewlib-$(gnu_type)-dev.copyright
debian/gcc-$(gnu_type).copyright: debian/copyright /usr/share/doc/gcc-$(gcc-version-major)-source/copyright /usr/share/doc/gdb-source/copyright
	cp debian/copyright $@
	printf -- "\n-----BEGIN GCC-$(gcc-version-major)-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
	cat /usr/share/doc/gcc-$(gcc-version-major)-source/copyright >> $@
	printf -- "-----END GCC-$(gcc-version-major)-SOURCE COPYRIGHT INFORMATION-----\n" \
		"\n-----BEGIN GDB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
	cat /usr/share/doc/gdb-source/copyright >> $@
	printf -- "-----END GDB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
debian/libnewlib-$(gnu_type)-dev.copyright: debian/copyright /usr/share/doc/newlib-source/copyright
	cp debian/copyright $@
	printf -- "\n-----BEGIN NEWLIB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
	cat /usr/share/doc/newlib-source/copyright >> $@
	printf -- "-----END NEWLIB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@

# The private shared library does not need ldconfig triggers.
override_dh_makeshlibs:
	dh_makeshlibs --no-scripts

override_dh_gencontrol:
	dh_gencontrol -p gcc-$(gnu_type) -- -v$(gcc-version)+$(DEB_VERSION) \
		-Vgcc-version=$(gcc-version) \
		-Vgcc-version-major=$(gcc-version-major) \
		-Vgdb-version=$(gdb-version)
	dh_gencontrol -p libnewlib-$(gnu_type)-dev -- -v$(newlib-upstream-version)+$(DEB_VERSION) \
		-Vnewlib-source-version=$(newlib-source-version)