File: rules

package info (click to toggle)
gcc-xtensa-lx106 13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 84 kB
  • sloc: makefile: 130; ansic: 99; sh: 66
file content (153 lines) | stat: -rwxr-xr-x 4,452 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/make -f
export DH_VERBOSE=1

target=xtensa-lx106-elf

GCC_VERSION=12
GCC_PACKAGE=gcc-$(GCC_VERSION)
GCC_DIR := /usr/src/gcc-12
GCC_TARBALL := $(notdir $(wildcard $(GCC_DIR)/gcc-*.tar.*))
GM2_TARBALL := $(notdir $(wildcard $(GCC_DIR)/gm2-*.tar.*))

package=gcc-xtensa-lx106
top_dir=$(shell pwd)
gcc_dir=/usr/src/$(GCC_PACKAGE)
doc_dir=/usr/share/doc/$(package)
build_doc_dir=$(top_dir)/debian/$(package)$(doc_dir)
stampdir=debian/stamp

source_version := $(shell dpkg-query -W -f="\$${Version}\n" $(GCC_PACKAGE)-source)
deb_version := $(source_version)+$(shell dpkg-parsechangelog | sed -ne "s/^Version: \(.*\)/\1/p")
deb_upstream_version := $(shell echo $(deb_version) | cut -d- -f1)
base_version := $(shell echo $(deb_version) | sed -e 's/\([1-9]\.[0-9]\).*-.*/\1/')
BUILT_USING := $(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W $(GCC_PACKAGE)-source)

unpack_stamp=$(stampdir)/unpack
tar_stamp=$(stampdir)/tar

build_dir=build

export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-format
buildflags:=$(shell dpkg-buildflags --export=configure) INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"

target_tools=\
	AR_FOR_TARGET=$(target)-ar \
	AS_FOR_TARGET=$(target)-as \
	LD_FOR_TARGET=$(target)-ld \
	NM_FOR_TARGET=$(target)-nm \
	OBJDUMP_FOR_TARGET=$(target)-objdump \
	RANLIB_FOR_TARGET=$(target)-ranlib \
	READELF_FOR_TARGET=$(target)-readelf \
	STRIP_FOR_TARGET=$(target)-strip

configure_flags = \
	--enable-languages=c,c++,d,lto \
	--prefix=/usr/lib \
	--infodir=/usr/share/doc/$(package)/info \
	--mandir=/usr/share/man \
	--htmldir=/usr/share/doc/$(package)/html \
	--pdfdir=/usr/share/doc/$(package)/pdf \
	--bindir=/usr/bin \
	--libexecdir=/usr/lib \
	--libdir=/usr/lib \
	--with-system-zlib \
	--enable-multilib \
	--disable-decimal-float \
	--disable-libffi \
	--disable-libgomp \
	--disable-libmudflap \
	--disable-libphobos \
	--disable-libquadmath \
	--disable-libquadmath-support \
	--disable-libssp \
	--disable-libstdcxx-pch \
	--disable-libstdc++-v3 \
	--disable-nls \
	--disable-shared \
	--disable-threads \
	--disable-tls \
	--enable-lto \
	--enable-target-optspace \
	--disable-__cxa_atexit \
	--without-long-double-128 \
	--disable-multilib \
	--enable-cxx-flags=-fno-exceptions \
	--build=$(DEB_BUILD_GNU_TYPE) \
	--host=$(DEB_HOST_GNU_TYPE) \
	--target=$(target) \
	--with-gnu-as \
	--with-gnu-ld \
	--with-headers=no \
	--without-newlib \
	"--with-pkgversion=$(deb_version)" \
	--without-included-gettext \
	SED=/bin/sed \
	SHELL=/bin/sh \
	BASH=/bin/bash \
	CONFIG_SHELL=/bin/bash \
	$(buildflags) \
	$(target_tools)

%:
	dh $@ -Dsrc -B$(build_dir)

$(unpack_stamp): $(tar_stamp)
	set -ex; \
		GFDL_INVARIANT_FREE=yes \
		patchdir=$(top_dir)/patches \
		stampdir=$(top_dir)/$(stampdir) \
		make -f $(GCC_DIR)/debian/rules.patch series; \
		QUILT_PATCHES=$(top_dir)/patches QUILT_PATCH_OPTS='-E' \
		quilt --quiltrc /dev/null push -a; \
	touch src/gcc/distro-defaults.h; \
	set -ex; \
		cd gcc-*; \
		for patch in ../debian/local-patches/[0-9]*.patch; do \
			echo Applying patch "$$patch"; \
			patch -p1 < "$$patch"; \
		done
	touch $@

$(tar_stamp):
	tar xf $(GCC_DIR)/$(GCC_TARBALL)
	ln -s gcc-$(GCC_VERSION)* src
	tar xf $(GCC_DIR)/$(GM2_TARBALL)
	(cd gm2 && tar cf - gcc libgm2) | (cd src && tar xf -)
	rm -rf gm2
	cp debian/overlay/include/xtensa-config.h src/include/
	mkdir -p $(stampdir)
	cp /usr/share/doc/$(GCC_PACKAGE)-source/copyright debian/copyright-gcc
	cp -a $(GCC_DIR)/debian/patches .
	touch $@

override_dh_autoreconf: $(unpack_stamp)
	autoreconf2.69 -f -i src

override_dh_auto_configure: $(unpack_stamp)
	mkdir -p $(build_dir)
	dh_auto_configure -Dsrc -B$(build_dir) -- $(configure_flags)

override_dh_auto_clean:
	rm -rf gcc-* $(build_dir) debian/tmp debian/copyright-gcc $(stampdir)
	dh_autoreconf_clean

override_dh_auto_test:
	@echo "no testing, that's way too painful"
#	dh_auto_test -Dsrc -B$(build_dir) --max-parallel=1

override_dh_gencontrol:
	dh_gencontrol -a -- -v$(deb_version) -Vlocal:Version=$(deb_upstream_version) -Vgcc:Version=$(source_version) -VBuilt-Using="$(BUILT_USING)"

override_dh_auto_install:
	mkdir -p $(top_dir)/debian/tmp
	cd build/xtensa-lx106-elf/libgcc/ && xtensa-lx106-elf-ar -M <$(top_dir)/debian/strip-libgcc-funcs.txt
	cd $(top_dir)/build && make install DESTDIR=$(top_dir)/debian/tmp

override_dh_installchangelogs:
	dh_installchangelogs src/ChangeLog

override_dh_compress:
	dh_compress -Xexamples/

override_dh_strip:
	dh_strip -X.a