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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
empty:=
space:=$(empty) $(empty)
xsedx:=$(shell printf '\027')
mute_warn := expansion-to-defined
cpp_nowarn := $(foreach w,$(mute_warn),-Wno-$(w))
export DEB_CPPFLAGS_MAINT_APPEND = $(cpp_nowarn)
export DEB_BUILD_MAINT_OPTIONS := hardening=+all optimize=+lto
TARGET_DEB_BUILD_OPTIONS := hardening=-all optimize=-lto
ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
export DH_VERBOSE := 1
endif
include /usr/share/dpkg/default.mk
build := $(CURDIR)/build
stamp := $(build)/stamp
tmpdst := $(build)/tmp
target32 := i686-w64-mingw32
target64 := x86_64-w64-mingw32
targets := $(target32) $(target64)
host = $(DEB_HOST_GNU_TYPE)
tools_host := gendef genidl genlib genpeimg
tools_target := widl
lib_target := winpthreads
lib_target32 :=
ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
lib_target += winstorecompat
lib_target32 += pseh
endif
%:
dh $@
.NOTPARALLEL:
override_dh_update_autotools_config:
override_dh_autoreconf:
rule_words = $(subst ~,$(space),$(1))
rule_host = $(word 1,$(call rule_words,$(1)))
rule_target = $(word 2,$(call rule_words,$(1)))
rule_path = $(subst $(space),/,$(wordlist 3,$(words $(call rule_words,$(1))),$(call rule_words,$(1))))
source_folder = $(CURDIR)/mingw-w64-$(call rule_path,$(1))
build_folder = $(build)/$(call rule_host,$(1))_$(call rule_target,$(1))_$(subst /,-,$(call rule_path,$(1)))
build_flags = $(call build_folder,$(1)).flags
build_ldspec = $(call build_folder,$(1)).ldspecs
$(stamp)/$(host)~$(host)~tools~gendef~configure: \
$(stamp)/%~tools~gendef~configure: \
$(stamp)/%~libraries~libmangle~install \
$(stamp)/%~tools~gendef~preconf
cd '$(call build_folder,$(*)~tools~gendef)' ; \
. '$(call build_flags,$(*)~tools~gendef)' ; \
'$(call source_folder,$(*)~tools~gendef)/configure' \
--host=$(call rule_host,$(*)~tools~gendef) \
--target=$(call rule_target,$(*)~tools~gendef) \
--prefix=/usr \
--with-mangle='$(tmpdst)/usr'
touch '$(stamp)/$(*)~tools~gendef~configure'
$(stamp)/$(host)~$(host)~tools~genlib~configure: \
$(stamp)/%~tools~genlib~configure: \
$(stamp)/%~libraries~libmangle~install \
$(stamp)/%~tools~genlib~preconf
cd '$(call build_folder,$(*)~tools~genlib)' ; \
. '$(call build_flags,$(*)~tools~genlib)' ; \
'$(call source_folder,$(*)~tools~genlib)/configure' \
--host=$(call rule_host,$(*)~tools~genlib) \
--target=$(call rule_target,$(*)~tools~genlib) \
--program-prefix=mingw- \
--prefix=/usr \
--with-mangle'=$(tmpdst)/usr'
touch '$(stamp)/$(*)~tools~genlib~configure'
$(stamp)/%~headers~configure: \
$(stamp)/%~headers~preconf
cd '$(call build_folder,$(*)~headers)' ; \
. '$(call build_flags,$(*)~headers)' ; \
'$(call source_folder,$(*)~headers)/configure' \
--host=$(call rule_host,$(*)~headers) \
--target=$(call rule_target,$(*)~headers) \
--prefix=/usr/$(call rule_target,$(*)~headers)
touch '$(stamp)/$(*)~headers~configure'
$(foreach t,$(targets),$(stamp)/$(t)~$(t)~crt~configure): \
$(stamp)/%~crt~configure: \
$(stamp)/%~headers~install \
$(stamp)/%~crt~preconf
cd '$(call build_folder,$(*)~crt)' ; \
. '$(call build_flags,$(*)~crt)' ; \
'$(call source_folder,$(*)~crt)/configure' \
--host=$(call rule_host,$(*)~crt) \
--target=$(call rule_target,$(*)~crt) \
--prefix=/usr/$(call rule_target,$(*)~crt) \
--$(if $(filter $(call rule_target,$(*)~crt),$(target64)),enable,disable)-lib64 \
--$(if $(filter $(call rule_target,$(*)~crt),$(target32)),enable,disable)-lib32
touch '$(stamp)/$(*)~crt~configure'
$(stamp)/%~autoreconf:
cd '$(call source_folder,$(*))' ; \
[ -x configure ] || autoreconf -fiv
touch '$(stamp)/$(*)~autoreconf'
$(stamp)/%~ldspecs: $(stamp)/%~autoreconf
if [ '$(host)' != '$(call rule_host,$(*))' ] ; then \
sed 's$(xsedx)@@PATH@@$(xsedx)$(tmpdst)/usr/$(call rule_host,$(*))/lib$(xsedx)g' \
< debian/specs.in \
> '$(call build_ldspec,$(*))' ; \
fi
touch '$(stamp)/$(*)~ldspecs'
$(stamp)/%~builddir: $(stamp)/%~ldspecs
mkdir -p '$(call build_folder,$(*))'
touch '$(stamp)/$(*)~builddir'
$(stamp)/%~flags: $(stamp)/%~builddir
if [ '$(host)' != '$(call rule_host,$(*))' ] ; then \
export DEB_BUILD_MAINT_OPTIONS='$(TARGET_DEB_BUILD_OPTIONS)' ; \
export DEB_CPPFLAGS_MAINT_PREPEND='-I$(tmpdst)/usr/$(call rule_target,$(*))/include' ; \
export DEB_LDFLAGS_MAINT_PREPEND='-L$(tmpdst)/usr/$(call rule_target,$(*))/lib' ; \
fi ; \
dpkg-buildflags --export=sh > '$(call build_flags,$(*))'
sed -i -E '/-f.+-prefix-map/{s$(xsedx)"$$$(xsedx) -ffile-prefix-map=$(call build_folder,$(*))=/build"$(xsedx)}' \
'$(call build_flags,$(*))'
sed -i -E '/-f.+-prefix-map/{s$(xsedx)"$$$(xsedx) -ffile-prefix-map=$(tmpdst)/=/"$(xsedx)}' \
'$(call build_flags,$(*))'
. '$(call build_flags,$(*))' ; \
for o in $${CFLAGS} ; do \
case "$$o" in \
-f*-prefix-map=*) \
map=$${o
sed -i -E '/^export CFLAGS=/{s$(xsedx)"$$$(xsedx) -Wa,--debug-prefix-map,'"$${map}"'"$(xsedx)}' \
'$(call build_flags,$(*))' ; \
;; \
esac ; \
done
if [ '$(host)' != '$(call rule_host,$(*))' ] ; then \
sed -i -E '/^export LDFLAGS=/{s$(xsedx)-specs=[^"[:space:]]+$(xsedx)$(xsedx)}' \
'$(call build_flags,$(*))' ; \
sed -i -E '/^export LDFLAGS=/{s$(xsedx)"$$$(xsedx) -specs=$(call build_ldspec,$(*))"$(xsedx)}' \
'$(call build_flags,$(*))' ; \
RCFLAGS="-I$(tmpdst)/usr/$(call rule_target,$(*))/include$${RCFLAGS:+ }$${RCFLAGS}" ; \
printf 'export RCFLAGS="%s"\n' "$${RCFLAGS}" >> '$(call build_flags,$(*))' ; \
fi
touch '$(stamp)/$(*)~flags'
$(stamp)/%~preconf: $(stamp)/%~flags
touch '$(stamp)/$(*)~preconf'
# 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 and libraries
$(stamp)/%~configure: $(stamp)/%~preconf
cd '$(call build_folder,$(*))' ; \
. '$(call build_flags,$(*))' ; \
if [ '$(host)' = '$(call rule_host,$(*))' ] ; then \
'$(call source_folder,$(*))/configure' \
--host=$(call rule_host,$(*)) \
--target=$(call rule_target,$(*)) \
--prefix=/usr \
; \
else \
'$(call source_folder,$(*))/configure' \
--host=$(call rule_host,$(*)) \
--target=$(call rule_target,$(*)) \
--prefix=/usr/$(call rule_target,$(*)) \
--with-widl-includedir=/usr/$(call rule_target,$(*))/include \
; \
fi
touch '$(stamp)/$(*)~configure'
$(stamp)/%~postconf: $(stamp)/%~configure
touch '$(stamp)/$(*)~postconf'
$(stamp)/%~build: $(stamp)/%~postconf
. '$(call build_flags,$(*))' ; \
dh_auto_build --sourcedir='$(call source_folder,$(*))' --builddir='$(call build_folder,$(*))'
touch '$(stamp)/$(*)~build'
$(stamp)/%~install: $(stamp)/%~build
dh_auto_install --sourcedir='$(call source_folder,$(*))' --builddir='$(call build_folder,$(*))' --destdir='$(tmpdst)'
touch '$(stamp)/$(*)~install'
execute_before_dh_auto_configure:
# perform source cleanup from tarball to repository state (close enough)
for n in aclocal.m4 'build-aux/*' config.h.in configure Makefile.in ; do \
find -wholename "*/$$n" -type f -delete ; \
done
# remove extra libtool/m4 files
for n in libtool ltoptions ltsugar ltversion 'lt~obsolete' ; do \
find -wholename "*/$$n.m4" -type f -delete ; \
done
mkdir -p '$(build)' '$(stamp)' '$(tmpdst)'
override_dh_auto_configure-arch: $(foreach x,$(tools_host),$(stamp)/$(host)~$(host)~tools~$(x)~install)
override_dh_auto_configure-indep: $(foreach t,$(targets),$(stamp)/$(t)~$(t)~crt~install)
override_dh_auto_build-arch: $(foreach x,$(tools_target),$(foreach t,$(targets),$(stamp)/$(host)~$(t)~tools~$(x)~install))
override_dh_auto_build-indep: $(foreach x,$(lib_target),$(foreach t,$(targets),$(stamp)/$(t)~$(t)~libraries~$(x)~install))
override_dh_auto_build-indep: $(foreach x,$(lib_target32),$(stamp)/$(target32)~$(target32)~libraries~$(x)~install)
# Nothing to test here yet
override_dh_auto_test:
override_dh_auto_install-indep:
# Move DLLs to lib, drop .la files
d='$(tmpdst)/usr' ; \
for T in $(targets) ; do \
find "$$d/$$T/lib/" -name '*.la' -delete ; \
find "$$d/$$T/bin/" -name '*.dll' -exec mv -nt "$$d/$$T/lib" '{}' '+' ; \
done
# Move duplicate files to mingw-w64-common
s='$(tmpdst)/usr' ; \
d='usr/share/mingw-w64' ; \
refT='$(word 1,$(targets))' ; \
testT='$(wordlist 2,$(words $(targets)),$(targets))' ; \
for file in $$(cd "$$s/$$refT" ; find . -type f ! -name '*.a' -printf '%P\n') ; do \
dupT="$$refT" ; \
for target in $$testT ; do \
[ -f "$$s/$$target/$$file" ] || continue ; \
if cmp -s "$$s/$$refT/$$file" "$$s/$$target/$$file" ; then \
dupT="$$dupT $$target" ; \
fi ; \
done ; \
if [ "$$dupT" = "$$refT" ] ; then continue ; fi ; \
mkdir -p "debian/mingw-w64-common/$$d/$$(dirname $$file)" ; \
cp "$$s/$$refT/$$file" "debian/mingw-w64-common/$$d/$$file" ; \
for duptarget in $$dupT ; do \
rm -f "$$s/$$duptarget/$$file" ; \
ln -sf "/$$d/$$file" "$$s/$$duptarget/$$file" ; \
done ; \
done
override_dh_auto_install-arch:
# Remove mingw-w64 libmangle artifacts (if any)
rm -f \
'$(tmpdst)/usr/include/libmangle.h' \
'$(tmpdst)/usr/lib/libmangle.a'
execute_after_dh_auto_install:
# Move files to appropriate location for debhelper
mkdir -p debian/tmp
mv -t debian/tmp '$(tmpdst)/'*
|