Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2 include /usr/share/dpkg/architecture.mk
3 include /usr/share/dpkg/buildopts.mk
4 include /usr/share/dpkg/pkg-info.mk
5 DEB_BUILD_OPTION_PARALLEL ?= 1
6
7 # Some GCC sources use non-string literals as format strings,
8 # for example to define their own wrapper functions.
9 export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-format
10
11 gnu_type = sh-elf
12 gcc-version-major != sed -En 's/.*gcc-(.*)-source.*/\1/p' debian/control
13
14 # Version of the GCC source Debian package.
15 gcc-version != dpkg-query -Wf'$${source:Version}' gcc-$(gcc-version-major)-source
16 gdb-version != dpkg-query -Wf'$${source:Version}' gdb-source
17 newlib-upstream-version != dpkg-query -Wf'$${source:Upstream-Version}' newlib-source
18 newlib-source-version != dpkg-query -Wf'$${source:Version}' newlib-source
19
20 # https://gcc.gnu.org/install/configure.html recommends out-of-tree builds.
21 %:
22 dh $@
23
24 execute_before_dh_update_autotools_config: src
25 src:
26 tar -xf /usr/src/gcc-$(gcc-version-major)/gcc-*.tar.xz
27 mv gcc-* $@
28 rm -rf $@/zlib
29 # This first patch may be empty.
30 patch -p1 -i /usr/src/gcc-$(gcc-version-major)/patches/git-updates.diff || true;
31 patch -p1 -i /usr/src/gcc-$(gcc-version-major)/patches/gcc-gfdl-build.diff
32 tar -xf /usr/src/newlib/newlib-*.tar.xz
33 tar -xf /usr/src/gdb.tar.xz
34 rm -rf gdb*/readline gdb*/zlib
35 # Symbolically link directories from GDB and Newlib into the GCC tree.
36 cd $@ && for i in ../gdb*/* ../newlib*/*; \
37 do \
38 if [ ! -e `basename "$$i"` -a -d "$$i" ]; \
39 then ln -s "$$i" . || exit 1; \
40 fi; \
41 done
42 # gcc's configure script is too old to build GDB right.
43 cd $@ && rm -f Makefile.def Makefile.in configure
44 cd $@ && cp ../gdb*/Makefile.def ../gdb*/Makefile.in ../gdb*/configure .
45
46 # Avoid dh_auto_*, see
47 # https://gcc.gnu.org/legacy-ml/gcc/2013-04/msg00171.html.
48
49 # gcc-major-version: for consistency with native gcc
50 CONFIG_OPTS = \
51 --build=$(DEB_BUILD_GNU_TYPE) \
52 --host=$(DEB_HOST_GNU_TYPE) \
53 --target=$(gnu_type) \
54 SED=/bin/sed \
55 SHELL=/bin/sh \
56 BASH=/bin/bash \
57 CONFIG_SHELL=/bin/bash \
58 --prefix=/usr \
59 --disable-gdb \
60 --disable-libcc1 \
61 --enable-languages=c \
62 --with-gcc-major-version-only \
63 --without-included-gettext \
64 --with-pkgversion='GCC $(gcc-version) Debian $(DEB_VERSION)' \
65 --with-bugurl="https://www.debian.org/Bugs/" \
66 --with-system-zlib \
67 --with-newlib
68
69 override_dh_auto_configure bld:
70 mkdir -p bld
71 if echo $(DEB_BUILD_OPTIONS) | grep -q terse; \
72 then QUIET_OPTS='--quiet --enable-silent-rules'; \
73 fi; \
74 cd bld && ../src/configure $(CONFIG_OPTS) $$QUIET_OPTS
75
76 override_dh_auto_build:
77 $(MAKE) -C bld -j$(DEB_BUILD_OPTION_PARALLEL)
78
79 override_dh_auto_test:
80 # With GCC, it is normal and expected that some of the tests will fail.
81 # Running the tests allows checking for regressions by comparing build logs.
82 $(MAKE) -C bld -j$(DEB_BUILD_OPTION_PARALLEL) check-gcc RUNTESTFLAGS="--target_board sh-sim"
83
84 override_dh_auto_install:
85 $(MAKE) -C bld install DESTDIR=`pwd`/debian/gcc-$(gnu_type)
86 # The documentation is empty due to being licensed GFDL with invariant sections,
87 # and the localization files are provided by gcc-*-locales
88 rm -r debian/gcc-$(gnu_type)/usr/share/info debian/gcc-$(gnu_type)/usr/share/man debian/gcc-$(gnu_type)/usr/share/locale
89 # The *.la files are unnecessary and strongly discouraged from being distributed in Debian.
90 find debian/gcc-$(gnu_type) -name '*.la' -type f -exec rm {} \;
91 $(MAKE) -C bld install-target-newlib DESTDIR=`pwd`/debian/libnewlib-$(gnu_type)-dev
92 # We installed everything into gcc-sh-elf and now prune out Newlib.
93 cd debian/libnewlib-$(gnu_type)-dev && find * -type f -exec rm -rf ../gcc-$(gnu_type)/{} \;
94 find debian/gcc-$(gnu_type) debian/libnewlib-$(gnu_type)-dev -type d -empty -delete
95 if ! echo $(DEB_BUILD_OPTIONS) | grep -q nostrip; \
96 then find debian/libnewlib-$(gnu_type)-dev/ -name '*.a' -exec \
97 $(gnu_type)-strip --strip-unneeded --remove-section=.comment --remove-section=.note {} + ; \
98 fi
99
100 # Shipping copyright information applicable to the binaries is required by Debian Policy.
101 execute_before_dh_installdocs: debian/gcc-$(gnu_type).copyright debian/libnewlib-$(gnu_type)-dev.copyright
102 debian/gcc-$(gnu_type).copyright: debian/copyright /usr/share/doc/gcc-$(gcc-version-major)-source/copyright /usr/share/doc/gdb-source/copyright
103 cp debian/copyright $@
104 printf -- "\n-----BEGIN GCC-$(gcc-version-major)-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
105 cat /usr/share/doc/gcc-$(gcc-version-major)-source/copyright >> $@
106 printf -- "-----END GCC-$(gcc-version-major)-SOURCE COPYRIGHT INFORMATION-----\n" \
107 "\n-----BEGIN GDB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
108 cat /usr/share/doc/gdb-source/copyright >> $@
109 printf -- "-----END GDB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
110 debian/libnewlib-$(gnu_type)-dev.copyright: debian/copyright /usr/share/doc/newlib-source/copyright
111 cp debian/copyright $@
112 printf -- "\n-----BEGIN NEWLIB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
113 cat /usr/share/doc/newlib-source/copyright >> $@
114 printf -- "-----END NEWLIB-SOURCE COPYRIGHT INFORMATION-----\n" >> $@
115
116 # The private shared library does not need ldconfig triggers.
117 override_dh_makeshlibs:
118 dh_makeshlibs --no-scripts
119
120 override_dh_gencontrol:
121 dh_gencontrol -p gcc-$(gnu_type) -- -v$(gcc-version)+$(DEB_VERSION) \
122 -Vgcc-version=$(gcc-version) \
123 -Vgcc-version-major=$(gcc-version-major) \
124 -Vgdb-version=$(gdb-version)
125 dh_gencontrol -p libnewlib-$(gnu_type)-dev -- -v$(newlib-upstream-version)+$(DEB_VERSION) \
126 -Vnewlib-source-version=$(newlib-source-version)