File: rules

package info (click to toggle)
mingw-w64 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 75,788 kB
  • ctags: 398,517
  • sloc: ansic: 825,770; sh: 5,888; yacc: 3,177; asm: 2,974; makefile: 2,348; lex: 2,043; cpp: 153
file content (165 lines) | stat: -rwxr-xr-x 7,108 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
#!/usr/bin/make -f
# -*- makefile -*-
# Build mingw-w64.

SHELL=/bin/bash

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

top_dir := $(shell pwd)
build_dir := $(top_dir)/build
deb_version := $(shell dpkg-parsechangelog | sed -ne "s/^Version: \(.*\)/\1/p")
deb_upstream_version := $(shell echo $(deb_version) | cut -d- -f1)
gnu_upstream_version := $(shell echo $(deb_upstream_version) | cut -d. -f1-3)

# Target architectures
target32 := i686-w64-mingw32
target64 := x86_64-w64-mingw32
targets := $(target32) $(target64)

# Host architecture
host := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

# Host-based tools
HOST_TOOLS := gendef genidl genpeimg
# Targetted tools
TARGET_TOOLS := widl

# Targetted projects
TARGET_PROJECTS := crt libraries-libmangle libraries-winstorecompat libraries-winpthreads
TARGET32_PROJECTS := libraries-pseh

# No hardening support for now, except in the tools (build-arch-stamp)
dpkg_buildflags = DEB_BUILD_MAINT_OPTIONS="hardening=-all" dpkg-buildflags

CFLAGS = $(shell $(dpkg_buildflags) --get CFLAGS)
CPPFLAGS = $(shell $(dpkg_buildflags) --get CPPFLAGS)
CXXFLAGS = $(shell $(dpkg_buildflags) --get CXXFLAGS)
FFLAGS = $(shell $(dpkg_buildflags) --get FFLAGS)
LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
export CFLAGS CPPFLAGS CXXFLAGS FFLAGS LDFLAGS

clean:
	dh_testdir
	dh_testroot
	dh_autoreconf_clean
	dh_clean
	rm -rf $(build_dir) $(upstream_dir) autotools_files series tmp *-stamp debian/autoreconf

CONFFLAGS = --prefix=/usr

debian/autoreconf:
	find $(top_dir) -name configure.ac | xargs -n 1 dirname > $@

autoreconf-stamp: debian/autoreconf
	dh_autoreconf
	touch $@

# General rules
# Format: host~target~source-folder
# E.g. i486-linux-gnu~i686-w64-mingw32~tools/widl to build a 32-bit
# Linux-hosted widl targeting 32-bit Windows
rulehost = $(word 1,$(subst ~, ,$(1)))
ruletarget = $(word 2,$(subst ~, ,$(1)))
rulepart = $(word 1,$(subst -, ,$(word 3,$(subst ~, ,$(1)))))
rulefolder = $(word 2,$(subst -, ,$(word 3,$(subst ~, ,$(1)))))
sourcefolder = $(top_dir)/mingw-w64-$(call rulepart,$(1))/$(call rulefolder,$(1))
buildfolder = $(build_dir)/$(call rulehost,$(1))-$(call ruletarget,$(1))-$(call rulepart,$(1))$(call rulefolder,$(1))

######################################################################
# Tools

# gendef requires libmangle
$(host)~$(host)~tools-gendef-configure-stamp: autoreconf-stamp $(host)~$(host)~libraries-libmangle-install-stamp
	dh_auto_configure -D$(call sourcefolder,$(host)~$(host)~tools-gendef) -B$(call buildfolder,$(host)~$(host)~tools-gendef) -- --with-mangle=$(top_dir)/debian/tmp/usr $(shell dpkg-buildflags --export=configure)
	touch $@

build-arch-stamp: $(patsubst %,$(host)~$(host)~tools-%-install-stamp,$(HOST_TOOLS)) $(foreach target,$(targets),$(patsubst %,$(host)~$(target)~tools-%-install-stamp,$(TARGET_TOOLS)))
	touch $@

######################################################################
# Libraries

# Override the header configuration
%~headers-configure-stamp: autoreconf-stamp
	dh_auto_configure -D$(call sourcefolder,$*~headers) -B$(call buildfolder,$*~headers) -- --prefix=/usr/$(call ruletarget,$*~headers) --host=$(call rulehost,$*~headers) --enable-sdk=all --enable-secure-api
	touch $*-headers-configure-stamp

# Override CRT configuration to avoid multilib builds
target32crt := $(target32)~$(target32)~crt
$(target32crt)-configure-stamp: $(target32)~$(target32)~headers-install-stamp autoreconf-stamp
	CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$(target32crt))/include" dh_auto_configure -D$(call sourcefolder,$(target32crt)) -B$(call buildfolder,$(target32crt)) -- --prefix=/usr/$(call ruletarget,$(target32crt)) --host=$(call rulehost,$(target32crt)) --target=$(call ruletarget,$(target32crt)) --enable-lib32 --disable-lib64
	touch $@
target64crt := $(target64)~$(target64)~crt
$(target64crt)-configure-stamp: $(target64)~$(target64)~headers-install-stamp autoreconf-stamp
	CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$(target64crt))/include" dh_auto_configure -D$(call sourcefolder,$(target64crt)) -B$(call buildfolder,$(target64crt)) -- --prefix=/usr/$(call ruletarget,$(target64crt)) --host=$(call rulehost,$(target64crt)) --target=$(call ruletarget,$(target64crt)) --disable-lib32 --enable-lib64
	touch $@

build-indep-stamp: $(foreach target,$(targets),$(patsubst %,$(target)~$(target)~%-install-stamp,$(TARGET_PROJECTS))) $(patsubst %,$(target32)~$(target32)~%-install-stamp,$(TARGET32_PROJECTS))
	# Move DLLs to lib, change their permissions to 644, drop .la files
	for target in $(targets); do \
		mv $(top_dir)/debian/tmp/usr/$$target/bin/*.dll $(top_dir)/debian/tmp/usr/$$target/lib/; \
		rmdir $(top_dir)/debian/tmp/usr/$$target/bin; \
		chmod 644 $(top_dir)/debian/tmp/usr/$$target/lib/*.dll; \
		rm $(top_dir)/debian/tmp/usr/$$target/lib/*.la; \
	done
	touch $@

build: build-indep build-arch
build-arch: build-arch-stamp
build-indep: build-indep-stamp

binary-indep: build-indep
	dh $@

binary-arch: build-arch
	dh $@

binary: binary-indep binary-arch

# If we're targetting the build host, configure for hardening
# If we're targetting the target host, disable hardening (see above),
# change the prefix and use the new headers
%-configure-stamp: autoreconf-stamp
	if [ "$(call rulehost,$*)" = "$(host)" ]; then \
		dh_auto_configure -D$(call sourcefolder,$*) -B$(call buildfolder,$*) -- $(shell dpkg-buildflags --export=configure) --host=$(call rulehost,$*) --target=$(call ruletarget,$*); \
	else \
		CPPFLAGS="$(CPPFLAGS) -I$(top_dir)/debian/tmp/usr/$(call ruletarget,$*)/include" dh_auto_configure -D$(call sourcefolder,$*) -B$(call buildfolder,$*) -- --prefix=/usr/$(call ruletarget,$*) --host=$(call rulehost,$*) --target=$(call ruletarget,$*); \
	fi
	touch $*-configure-stamp

%-build-stamp: %-configure-stamp
	dh_auto_build -D$(call sourcefolder,$*) -B$(call buildfolder,$*)
	touch $*-build-stamp

%-install-stamp: %-build-stamp
	dh_auto_install -D$(call sourcefolder,$*) -B$(call buildfolder,$*)
	touch $*-install-stamp

override_dh_install-indep:
# Move duplicate files to mingw-w64-common
	reftarget=$$(echo $(targets) | cut -d\  -f1); \
	testtargets=$$(echo $(targets) | cut -d\  -f2-); \
	for file in $$(cd debian/tmp/usr/$$reftarget; find . -name \*.h); do \
		duptargets=$$reftarget; \
		for testtarget in $$testtargets; do \
			if [ -f debian/tmp/usr/$$testtarget/$$file ]; then \
				if cmp debian/tmp/usr/$$reftarget/$$file debian/tmp/usr/$$testtarget/$$file; then \
					duptargets="$$duptargets $$testtarget"; \
				fi; \
			fi; \
		done; \
		if [ "$$duptargets" != "$$reftarget" ]; then \
			mkdir -p debian/mingw-w64-common/usr/share/mingw-w64/$$(dirname $$file); \
			cp debian/tmp/usr/$$reftarget/$$file debian/mingw-w64-common/usr/share/mingw-w64/$$file; \
			for duptarget in $$duptargets; do \
				rm -f debian/tmp/usr/$$duptarget/$$file; \
				ln -sf /usr/share/mingw-w64/$$file debian/tmp/usr/$$duptarget/$$file; \
			done; \
		fi; \
	done
# Do the rest of the installation
	dh_install -i

.PHONY: binary-indep binary-arch binary clean build-indep build-arch build install