File: rules

package info (click to toggle)
gdb-mingw-w64 13.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 64 kB
  • sloc: makefile: 126
file content (176 lines) | stat: -rwxr-xr-x 6,623 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/make -f
# -*- makefile -*-
# Copyright © 2010-2019 Stephen Kitt <steve@sk2.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 2.1 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Disable package mangling in Launchpad; it currently fails to parse
# Built-Using, which results in build failures
export NO_PKG_MANGLE=1

include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/architecture.mk

top_dir := $(shell pwd)
gdb_dir := /usr/src
upstream_dir := $(top_dir)/upstream
build_gdb_dir := $(top_dir)/build-gdb
build_gdbserver_dir := $(top_dir)/build-gdbserver
source_version := $(shell dpkg-query -W -f="\$${Version}\n" gdb-source)
deb_version := $(source_version)+$(DEB_VERSION)
deb_upstream_version := $(shell echo $(deb_version) | cut -d- -f1)
gnu_upstream_version := $(shell echo $(deb_upstream_version) | cut -d. -f1-3)
package := gdb-mingw-w64

# Targets where the compiler takes a thread-model suffix have that suffix added
targets32 := i686-w64-mingw32-posix
targets64 := x86_64-w64-mingw32-posix x86_64-w64-mingw32ucrt

# Full hardening for Debian-targeted builds
dpkg_buildflags_arch = DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags

# Windows targets don't support relro, bindnow or pie
# We disable PE timestamps to build reproducibly
# We disable format because the gdb build tries to do so (partially)
# anyway, and breaks the build with -Werror=format-security as a result
# We link libstdc++ and libgcc statically to avoid needing the DLLs
# Specifying the host architecture ensures dpkg-buildflags doesn't attempt
# to use architecture-specific flags irrelevant for i686 or x86_64
dpkg_buildflags_indep_32 = DEB_HOST_ARCH=i386 DEB_BUILD_MAINT_OPTIONS="hardening=-relro,-bindnow,-pie,-format" DEB_LDFLAGS_MAINT_APPEND="-Xlinker --no-insert-timestamp -static" dpkg-buildflags
dpkg_buildflags_indep_64 = DEB_HOST_ARCH=amd64 DEB_BUILD_MAINT_OPTIONS="hardening=-relro,-bindnow,-pie,-format" DEB_LDFLAGS_MAINT_APPEND="-Xlinker --no-insert-timestamp -static" dpkg-buildflags

spelling = grep -rl "$(1)" $(upstream_dir) | xargs -r sed -i "s/$(1)/$(2)/g"

%:
	dh $@

unpack-stamp:
	tar xf $(gdb_dir)/gdb.tar.*
	rm -rf $(upstream_dir)
	mv gdb $(upstream_dir)
	$(call spelling,occurences,occurrences)
	$(call spelling,Unkown,Unknown)
	$(call spelling,vaild,valid)
	touch $@

override_dh_auto_clean:
	dh_auto_clean
	rm -rf *-stamp $(build_gdb_dir) $(build_gdbserver_dir) $(upstream_dir)

override_dh_auto_configure-arch: unpack-stamp
	set -e; \
	for target in $(targets32) $(targets64); do \
		target="$${target%-posix}"; \
		mkdir -p $(build_gdb_dir)/$$target; \
		cd $(build_gdb_dir)/$$target; \
		$(upstream_dir)/configure \
			--build=$(DEB_BUILD_GNU_TYPE) \
			--prefix=/usr --enable-lto \
			--with-system-readline --with-system-zlib \
			--enable-tui --with-expat --with-python=python3 \
			--target=$$target --disable-werror \
			$(shell $(dpkg_buildflags_arch) --export=cmdline); \
	done

# We're only interested in gdbserver; that also requires gnulib, libiberty, and gdbsupport
gdbserver_projects := gnulib libiberty gdbsupport gdbserver
override_dh_auto_configure-indep: unpack-stamp
	set -e; \
	for target in $(targets32); do \
		suffix=; \
		if [ "$$target" != "$${target%-posix}" ]; then \
			suffix=-posix; \
		fi; \
		target="$${target%-posix}"; \
		for project in $(gdbserver_projects); do \
			mkdir -p $(build_gdbserver_dir)/$$target/$$project; \
			cd $(build_gdbserver_dir)/$$target/$$project; \
			sh $(upstream_dir)/$$project/configure \
				--build=$(DEB_BUILD_GNU_TYPE) \
				--host=$$target --target=$$target \
				CC=$$target-gcc$$suffix CXX=$$target-g++$$suffix \
				--disable-werror \
				$(shell $(dpkg_buildflags_indep_32) --export=cmdline); \
		done; \
	done
	for target in $(targets64); do \
		suffix=; \
		if [ "$$target" != "$${target%-posix}" ]; then \
			suffix=-posix; \
		fi; \
		target="$${target%-posix}"; \
		for project in $(gdbserver_projects); do \
			mkdir -p $(build_gdbserver_dir)/$$target/$$project; \
			cd $(build_gdbserver_dir)/$$target/$$project; \
			sh $(upstream_dir)/$$project/configure \
				--build=$(DEB_BUILD_GNU_TYPE) \
				--host=$$target --target=$$target \
				CC=$$target-gcc$$suffix CXX=$$target-g++$$suffix \
				--disable-werror \
				$(shell $(dpkg_buildflags_indep_64) --export=cmdline); \
		done; \
	done

override_dh_auto_build-arch:
	set -e; \
	for target in $(targets32) $(targets64); do \
		target="$${target%-posix}"; \
		$(shell $(dpkg_buildflags_arch) --export=sh); \
		dh_auto_build --parallel -B$(build_gdb_dir)/$$target -- V=1; \
	done

override_dh_auto_build-indep:
	set -e; \
	for target in $(targets32); do \
		target="$${target%-posix}"; \
		for project in $(gdbserver_projects); do \
			$(shell $(dpkg_buildflags_indep_32) --export=sh); \
			dh_auto_build --parallel -B$(build_gdbserver_dir)/$$target/$$project -- V=1; \
		done; \
	done; \
	for target in $(targets64); do \
		target="$${target%-posix}"; \
		for project in $(gdbserver_projects); do \
			$(shell $(dpkg_buildflags_indep_64) --export=sh); \
			dh_auto_build --parallel -B$(build_gdbserver_dir)/$$target/$$project -- V=1; \
		done; \
	done

override_dh_auto_install:
	set -e; \
	for target in $(targets32) $(targets64); do \
		target="$${target%-posix}"; \
		dh_auto_install -B$(build_gdb_dir)/$$target; \
	done
# Drop files which will conflict with other packages
	rm -rf debian/tmp/usr/include
	rm -rf debian/tmp/usr/lib
	rm -rf debian/tmp/usr/share/gdb
	rm -rf debian/tmp/usr/share/info
	rm -rf debian/tmp/usr/share/locale
	rm -rf debian/tmp/usr/share/man

override_dh_installchangelogs:
	dh_installchangelogs $(upstream_dir)/ChangeLog

override_dh_gencontrol:
	dh_gencontrol -- -v$(deb_version) -Vlocal:Version=$(deb_upstream_version) -Vgdb:Version=$(source_version)

override_dh_strip-indep:
	i686-w64-mingw32-strip debian/gdb-mingw-w64-target/usr/share/win32/*.exe
	x86_64-w64-mingw32-strip debian/gdb-mingw-w64-target/usr/share/win64/*.exe
	x86_64-w64-mingw32ucrt-strip debian/gdb-mingw-w64-target/usr/share/ucrt64/*.exe