This file is indexed.

/usr/share/cross-gcc/template/rules.generic is in cross-gcc-dev 14+deb8u1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/make -f

SHELL := /bin/bash

THIS_PKG       := $(shell dpkg-parsechangelog --show-field=Source)
THIS_PKG_VER   := $(shell dpkg-parsechangelog --show-field=Version)
DEB_HOST_ARCH  := $(shell dpkg-architecture -qDEB_HOST_ARCH)

THIS_PKG_MAINT    :=$(shell <debian/control.template awk '/Maintainer:/{$$1=""; sub("^ ",""); print; exit}')
THIS_PKG_UPLOADERS:=$(shell <debian/control.template awk '/Uploaders:/ {$$1=""; sub("^ ",""); print; exit}')
stamp            := stamps/

DISTRO ?= $(shell dpkg-vendor --query vendor)

# defaults
ifeq ($(DISTRO),Debian)
HOST_LIST ?= amd64
BASE_VER_GCC ?= 4.9
else # Ubuntu
HOST_LIST ?= amd64
BASE_VER_GCC ?= 4.9
endif

# 3-digit upstream gcc version (tarball name)
VER_GCC     := $(shell  dpkg-parsechangelog -l/usr/src/gcc-$(BASE_VER_GCC)/debian/changelog --show-field=Version | cut -f 1 -d '-'|cut -d '.' -f1-3)
# Package base version (directory name)
PKG_VER_GCC := $(shell dpkg-parsechangelog -l/usr/src/gcc-$(BASE_VER_GCC)/debian/changelog --show-field=Version | cut -f 1 -d '-')
# Debian package version (with '-')
DEB_VER_GCC := $(shell dpkg-parsechangelog -l/usr/src/gcc-$(BASE_VER_GCC)/debian/changelog --show-field=Version)

GCC_DIR  := /usr/src/gcc-$(BASE_VER_GCC)

# Don't try to build the HOST=TARGET (ie. non-cross) combination on/for this arch
TARGETS := $(filter-out ${DEB_HOST_ARCH}, ${DEB_TARGET_ARCH})


info:
	@echo "Gcc version:         ${VER_GCC}	${DEB_VER_GCC}	${PKG_VER_GCC}"
	@echo
	@echo "Target architecture:      ${DEB_TARGET_ARCH}"     
	@echo "Host architecture:        ${DEB_HOST_ARCH}"

$(stamp): 
	mkdir $(stamp) -p

debian/tmp:
	mkdir debian/tmp -p

$(stamp)init-dirs: $(stamp) debian/tmp
	touch $@

init: $(stamp)init-dirs $(stamp)init

PATCHDIR:=/usr/share/cross-gcc/patches/gcc-$(BASE_VER_GCC)
$(stamp)init:
	@echo START $@
	tar -x -f ${GCC_DIR}/gcc-${VER_GCC}*.tar.[gx]z
	set -e; \
	cd gcc-${PKG_VER_GCC} ;\
	cp -a ${GCC_DIR}/debian/ . ;\
	if [ -n "$$(grep -v '^\#' $(PATCHDIR)/series)" ]; then \
	  QUILT_PATCHES=$(PATCHDIR) quilt --quiltrc /dev/null push -a; \
	fi; \

	touch $@

# There are 3 ways to specify a target arch to the build:
#
# DEB_TARGET_ARCH env var
# dpkg-buildpackage --target-arch
# debian/target file
#
# Those have all been broken at various points in time, so I can't simply pick
# one method. Instead I use one of two methods: (if available, --target-arch
# else DEB_TARGET_ARCH). Hopefully this always works
#
# dpkg-buildpackage target-arch setting changed from env var to option from
# dpkg 1.17.17, so I pass --target-arch if this is available.
DPKG_HAS_TARGETARCH = $(shell (cd /; dpkg-buildpackage --target-arch 2> /dev/null; if [ $$? -eq 2 ] ; then echo 'no'; fi))
ifeq ($(DPKG_HAS_TARGETARCH),no)
dpkg_target_cmd = DEB_TARGET_ARCH=$* with_deps_on_target_arch_pkgs=yes DEB_BUILD_OPTIONS="nolang=biarch,d,go,java,objc,obj-c++" DEB_CROSS_NO_BIARCH=yes dpkg-buildpackage
else # must use --target-arch
dpkg_target_cmd = with_deps_on_target_arch_pkgs=yes DEB_BUILD_OPTIONS="nolang=biarch,d,go,java,objc,obj-c++" DEB_CROSS_NO_BIARCH=yes dpkg-buildpackage --target-arch $*
endif

$(stamp)build-%: $(stamp)init
	@echo START $@
	set -e; \
	cd gcc-${PKG_VER_GCC}; \
	$(dpkg_target_cmd) -d -T control; \
	$(dpkg_target_cmd) -B -d -uc -us; \
	cd ..; \
	touch $@


clean:
	rm -rf gcc-*
	rm -rf debian/tmp debian/files
	find debian -name '*~' | xargs -r rm -f
	rm -f *.deb *.changes
	rm -rf repackfiles tmp
	rm -rf $(stamp)
	mkdir $(stamp)


BUILD_TARGET := $(patsubst %,$(stamp)build-%,${DEB_TARGET_ARCH})

build-arch: build
build-indep: 
build: $(BUILD_TARGET)
	rm -f *.changes

binary: binary-arch binary-indep 
binary-arch:  build-arch mangle-debian-files
binary-indep:

# Get the list of binaries we care about
PACKAGES := $(patsubst  %,%*.deb, $(shell awk  '/^Package: / { print $$2 }' debian/control)) 

#
# Repack resulting packages to make changes:
# - Set Source and Version to this package 
# - Change Maintainer for cross packages
# - Change Uploaders for cross packages, taking care to not barf is not previous Uploaders exist
# - Get rid of unecessary gcc-<ver>-base dep - all docs are in cpp-<triplet> package
define repack_deb
	echo "repacking $$deb ...";										 \
	rm -rf tmp/*;												 \
	dpkg-deb -R $$deb tmp;											 \
	pkgname=`echo $$deb | cut -d'_' -f1`;									 \
	sed -i -e's/^Source:.*/Source: ${THIS_PKG} (${THIS_PKG_VER})/' tmp/DEBIAN/control;			 \
														 \
	sed -i -e"s/^Maintainer:.*/Maintainer: ${THIS_PKG_MAINT}\nXB-Original-Source-&/"     tmp/DEBIAN/control; \
	if grep -q '^Uploaders:' tmp/DEBIAN/control; then							 \
	  sed -i -e"s/^Uploaders:.*/Uploaders: ${THIS_PKG_UPLOADERS}\nXB-Original-Source-&/" tmp/DEBIAN/control; \
	else													 \
	  sed -i -e"s/^XB-Original-Source-Maintainer.*/&\nUploaders: ${THIS_PKG_UPLOADERS}/" tmp/DEBIAN/control; \
	fi;													 \
														 \
	sed -i -e's/gcc-${BASE_VER_GCC}-base[^,]*,//' tmp/DEBIAN/control;					 \
	if [ -e debian/overrides/$$pkgname ]; then								 \
	  mkdir -p tmp/usr/share/lintian/overrides;								 \
	  cp debian/overrides/$$pkgname tmp/usr/share/lintian/overrides/;					 \
	fi;													 \
	(cd tmp && md5sum `find usr -type f` >>DEBIAN/md5sums);							 \
	dpkg-deb -b tmp/ ../$$deb;										 \
	echo "        done";
endef


repack-debs:
	@echo START $@
	install -d repackfiles; \
	for deb in $(wildcard ${PACKAGES}); \
	do \
	  $(call repack_deb, $${deb}) \
	done; \


$(stamp)debian-files-base:
	@echo START $@
	rm -f debian/files
	touch $@

define generate_debian_files
	@echo Debs: $1
	@for deb in $1; \
	do \
		echo -n "`basename $$deb` " >>debian/files; \
		dpkg-deb -f $$deb Section  | tr "\n" ' ' >>debian/files; \
		dpkg-deb -f $$deb Priority | tr -d "\n"  >>debian/files; \
		echo "" >>debian/files; \
	done
endef

mangle-debian-files: $(stamp)debian-files-base repack-debs
	@echo START $@
	$(call generate_debian_files,  $(wildcard ${PACKAGES}))


# Generate the control file from head plus stanza for each binary
# Set the TARGET arch when doing it:
# e.g: DEB_TARGET_ARCH=armhf debian/rules control
# HOST=TARGET doesn't make sense.
GCC_DEBIAN_RELEASE=$(shell \
  source /usr/share/cross-gcc/cross-gcc-dev-helpers.sh; \
  get_debian_release ${BASE_VER_GCC})

control: debian/control.template
	DEB_TARGET_ARCH=${DEB_TARGET_ARCH} ; \
	DEB_TARGET_GNU_TYPE=`dpkg-architecture -a$${DEB_TARGET_ARCH} -qDEB_HOST_GNU_TYPE -f 2>/dev/null`; \
	ARCH_LIST_FOR_BINARY=`echo ${HOST_LIST}`; \
	< debian/control.template \
	sed -e "s/DEB_TARGET_ARCH/$${DEB_TARGET_ARCH}/g" | \
	sed -e "s/GCC_DEBIAN_RELEASE/${GCC_DEBIAN_RELEASE}/g" | \
	sed -e "s/BASE_VER_GCC/${BASE_VER_GCC}/g" | \
	sed -e "s/ARCH_LIST_FOR_BINARY/$${ARCH_LIST_FOR_BINARY}/g" | \
	sed -e "s/DEB_TARGET_GNU_TYPE/$${DEB_TARGET_GNU_TYPE}/g" > debian/control;