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
|
#!/usr/bin/make -f
#-
# Possible flavourisation (in addition to stock Debian rules):
# export DEB_BUILD_OPTIONS=diet
# export DEB_BUILD_OPTIONS=klibc
# export DEB_BUILD_OPTIONS=klibc CC='klcc -shared'
# export DEB_BUILD_OPTIONS='diet debug' (or 'klibc debug')
# export DEB_BUILD_OPTIONS=static (for eglibc)
# All can be combined with 'nopwnam' (aids static linkage).
# The 'nostrip' and 'parallel=n' options are supported as well.
#
# Setting diet or klibc disables -O0/-O2 and -g and, if unset,
# sets CC. Adding debug enables -g3. Cross-compiling also sets
# CC if unset.
#
# Statically linking violates the Policy requirement of having a
# Built-Using header, but since that is only used in local rebuilds
# and not in the Debian archive, it constitutes no Policy violation.
shellescape='$(subst ','\'',$(1))'
shellexport=$(1)=$(call shellescape,${$(1)})
ifeq (,$(findstring diet,${DEB_BUILD_OPTIONS}))
ifeq (,$(findstring klibc,${DEB_BUILD_OPTIONS}))
USE_LIBC:=system
else
USE_LIBC:=klibc
endif
else
USE_LIBC:=dietlibc
endif
DEB_BUILD_ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
# is ${CC} defined anywhere (other than implicit rules?)
ifneq (,$(findstring $(origin CC),default undefined))
# no - then default to gcc (or cross-gcc)
ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
CC= ${DEB_HOST_GNU_TYPE}-gcc
else
ifeq (,$(findstring diet,${DEB_BUILD_OPTIONS}))
ifeq (,$(findstring klibc,${DEB_BUILD_OPTIONS}))
CC= gcc
else
# export CC='klcc -shared' manually if you want that
CC= klcc
endif
else
CC= diet -Os gcc
endif
endif
endif
EXTRA_CFLAGS+= -Wall -Wformat
EXTRA_CFLAGS+= -fno-omit-frame-pointer -fwrapv -fno-strict-aliasing
# adjust when backporting
EXTRA_CFLAGS+= -Wextra -Wno-pointer-sign -Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-old-style-definition -Wno-strict-prototypes \
-Wno-cast-qual \
-Wno-missing-prototypes -Wno-missing-declarations
EXTRA_LDFLAGS= -Wl,--as-needed
ifneq (${USE_LIBC},system)
ifneq (,$(findstring debug,${DEB_BUILD_OPTIONS}))
EXTRA_CFLAGS+= -g3
endif
# SSP currently works with neither dietlibc nor klibc
EXTRA_CFLAGS+= -fno-stack-protector
else
ifneq (,$(findstring static,${DEB_BUILD_OPTIONS}))
EXTRA_LDFLAGS+= -static
endif
endif
ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
# dpkg-dev (>= 1.16.1~)
DEB_CFLAGS_MAINT_APPEND=${EXTRA_CFLAGS}
DEB_LDFLAGS_MAINT_APPEND=${EXTRA_LDFLAGS}
ifneq (${USE_LIBC},system)
# the diet and klcc wrappers take care of optimisation for us
DEB_CFLAGS_MAINT_STRIP=-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -g -g1 -g2 -g3 -ggdb -gdwarf -gstabs
DEB_CFLAGS_MAINT_STRIP+=-specs=/usr/share/dpkg/no-pie-compile.specs
DEB_LDFLAGS_MAINT_STRIP+=-specs=/usr/share/dpkg/no-pie-link.specs
# do not use PIE with strange libcs, either
DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
else
ifneq (,$(findstring static,${DEB_BUILD_OPTIONS}))
# cannot mix PIE with static linkage
DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
else
DEB_BUILD_MAINT_OPTIONS=hardening=+all
endif
endif
include /usr/share/dpkg/buildflags.mk
else
# old-fashioned way to determine build flags
ifneq (${USE_LIBC},system)
CFLAGS=
else
CFLAGS= -O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g
endif
CFLAGS+= ${EXTRA_CFLAGS}
LDFLAGS+= ${EXTRA_LDFLAGS}
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS= $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS+= -j${NUMJOBS}
endif
CONFIGURE_ARGS= --build=${DEB_BUILD_GNU_TYPE} \
--host=${DEB_HOST_GNU_TYPE} \
--prefix=/usr \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--disable-dependency-tracking
ifneq (${USE_LIBC},system)
# prevent picking up system libraries linked against the system C library
CONFIGURE_ARGS+= --disable-search-libs
endif
ifneq (,$(findstring nopwnam,${DEB_BUILD_OPTIONS}))
CONFIGURE_ARGS+= --disable-getpwnam
endif
CONFIGURE_ARGS+= --disable-termidx \
--enable-sysconfjoesubdir=/jupp
debian/.configure_stamp:
dh_testdir
-rm -f debian/.*_stamp
-rm -rf builddir
# apply autotools-dev if it exists
for x in config.guess config.sub; do \
test -e /usr/share/misc/$$x || continue; \
rm -f $$x; \
cp /usr/share/misc/$$x .; \
done
mkdir builddir
cd builddir && exec env \
$(foreach i,CC CFLAGS CPPFLAGS LDFLAGS,$(call shellexport,$i)) \
sh ../configure ${CONFIGURE_ARGS}
@:>$@
debian/.build_stamp: debian/.configure_stamp
dh_testdir
cd builddir && exec ${MAKE}
ln -f builddir/joe builddir/jupp
ln -f builddir/joe.1 builddir/jupp.1
@:>$@
build: build-arch build-indep
build-arch: debian/.build_stamp
build-indep: debian/.configure_stamp
clean:
dh_testdir
-rm -f debian/.*_stamp
-rm -rf builddir
# unapply autotools-dev if it exists
for x in config.guess config.sub; do \
test -e /usr/share/misc/$$x || continue; \
rm -f $$x; \
done
dh_clean
binary-indep: build-indep
dh_testdir
dh_testroot
if test -x "$$(which dh_prep)"; then dh_prep -i; else dh_clean -i -k; fi
dh_installchangelogs -i -Njupp
dh_install -i
dh_installmenu -i
# will be replaced by links to jupp
rm -rf debian/joe-jupp/usr/share/doc/joe-jupp
dh_link -i
dh_fixperms -i
dh_installdeb -i
dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i
# no -Njupp because that's the only arch:any package
binary-arch: build-arch
dh_testdir
dh_testroot
if test -x "$$(which dh_prep)"; then dh_prep -a; else dh_clean -a -k; fi
dh_installchangelogs -pjupp -k NEWS
dh_installdocs -a
dh_install -a
dh_installmenu -a
dh_installman -a
dh_link -a
dh_strip -a
dh_compress -a
dh_fixperms -a
dh_installdeb -a
dh_shlibdeps -a
dh_gencontrol -a
dh_md5sums -a
dh_builddeb -a
binary: binary-arch binary-indep
.PHONY: binary binary-arch binary-indep build build-arch build-indep clean
|