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
|
#!/usr/bin/make -f
# $MirOS: contrib/hosted/tg/deb/mksh/debian/rules,v 1.56 2010/07/17 23:08:59 tg Exp $
#-
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
PRINTF_C= extra/printf.c.1.15
LC_ALL:= C
export LC_ALL
CC?= gcc
CFLAGS= -Wall -g
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS+= -O0
else
CFLAGS+= -O2
endif
# nostrip: we use dh_strip, no action needed
# parallel=n: we cannot guarantee to honour ‘n’, thus building sequentially
# CPPFLAGS for /bin/mksh (glibc; full)
CPPFLAGS_f+= -include /usr/include/bsd/bsd.h
# CPPFLAGS for /bin/mksh-static (dietlibc or glibc; small)
CPPFLAGS_s+= -DMKSH_SMALL
# Debian #499139
CPPFLAGS_f+= -DMKSH_BINSHREDUCED
CPPFLAGS_s+= -DMKSH_BINSHREDUCED
BUILD_ENV:= CC='${CC}'
BUILD_ENV+= CFLAGS='${CFLAGS}'
BUILD_ENV+= CPPFLAGS='${CPPFLAGS} ${CPPFLAGS_f}'
BUILD_ENV+= LIBS='-lbsd'
ifeq ($(shell which diet),)
USE_DIETLIBC= 0
else
USE_DIETLIBC= 1
endif
DEB_BUILD_ARCH?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
# Debian #523088
ifeq (${DEB_BUILD_ARCH},s390)
USE_DIETLIBC= 0
endif
ifneq (,$(filter Ubuntu,$(shell dpkg-vendor --query vendor 2>/dev/null || echo unknown)))
# LP #381332
ifeq (${DEB_BUILD_ARCH},powerpc)
USE_DIETLIBC= 0
endif
ifeq (${DEB_BUILD_ARCH},ppc64)
USE_DIETLIBC= 0
endif
endif
# both Ubuntu (weird versions) and Debian (weird trouble)
ifeq (${DEB_BUILD_ARCH},sparc)
USE_DIETLIBC= 0
endif
ifeq (${USE_DIETLIBC},1)
# mksh-static ← dietlibc – diet(1) optimises OK
STATIC_ENV:= CC='diet -v -Os ${CC}'
STATIC_ENV+= CFLAGS='-Wall'
else
# mksh-static ← eglibc – try to optimise as good as we can ourselves
STATIC_ENV:= CC='${CC}'
STATIC_ENV+= CFLAGS='-Os -Wall'
STATIC_ENV+= LDFLAGS='${LDFLAGS} -static'
endif
STATIC_ENV+= CPPFLAGS='${CPPFLAGS} ${CPPFLAGS_s}'
STATIC_ENV+= HAVE_SETLOCALE_CTYPE=0 # no locale for it, either
#STATIC_ENV+= HAVE_CAN_COMBINE=0 # diet eats most of our CFLAGS
# This is already a part of CFLAGS
BUILD_ENV+= HAVE_CAN_WALL=0
STATIC_ENV+= HAVE_CAN_WALL=0
# Debian #532343, #539158
BUILD_ENV+= USE_PRINTF_BUILTIN=1
STATIC_ENV+= USE_PRINTF_BUILTIN=1
# avr32 currently has no locales
ifeq (${DEB_BUILD_ARCH},avr32)
BUILD_ENV+= HAVE_SETLOCALE_CTYPE=0
endif
# shut up build log checkers that don’t know what they are doing
# Debian #492377, #572252, Ubuntu too
_shutup:= | sed \
-e 's!conftest.c:\([0-9]*\(:[0-9]*\)*\): error:!cE(\1) -!g' \
-e 's!conftest.c:\([0-9]*\(:[0-9]*\)*\): warning:!cW(\1) -!g'
build: debian/.build_stamp
do-build:
# Copy extra code implementing printf(1) as a builtin.
cp ../../${PRINTF_C} printf.c
ifeq (0,${HAVE_CAN_COMBINE})
# Try to build mksh. No -combine supported by compiler driver.
@sh ../../Build.sh -r
else
# Try to build mksh. If -combine fails, retry without.
@echo '=== trying to build with -fwhole-program --combine ==='
@if sh ../../Build.sh -r -c combine && test -f mksh; then \
echo '=== done, wonderful ==='; \
else \
echo '=== FAILED because your gcc is broken ==='; \
echo; \
echo '=== trying to build withOUT -fwhole-program' \
'--combine ==='; \
sh ../../Build.sh -r || exit 1; \
echo '=== note: for better optimisation, fix your gcc! ==='; \
fi
endif
# We have a binary!
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
./mksh -c true
#
# Dear buildd administrators,
#
# if this fails, please install /dev/ptmx et al. in your
# chroot, i.e. the devices needed by openpty(). Thanks!
# Note: /dev/tty is required by the regression test too.
#
# script(1) fails on Debian GNU/Hurd in pbuilder; this gets us 30 failures
if test '!' -e ../../attended && test x"$$(uname -s)" = x"GNU"; then \
./test.sh -v; \
else \
echo >test.wait; \
script -qc './test.sh -v; x=$$?; rm -f test.wait; exit $$x'; \
maxwait=0; \
while test -e test.wait; do \
sleep 1; \
maxwait=$$(expr $$maxwait + 1); \
test $$maxwait -lt 900 || break; \
done; \
fi
# end of regression test suite
endif
debian/.build_stamp:
dh_testdir
-rm -rf builddir
mkdir builddir builddir/full builddir/small
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# failure here may lead to testsuite failures
mkdir builddir/tloc
# cf. Debian #522776
-localedef -i en_US -c -f UTF-8 builddir/tloc/en_US.UTF-8
endif
#
# build mksh-full
#
_topdir=$$(pwd); cd builddir/full && env ${BUILD_ENV} \
LC_ALL=C LOCPATH=$$_topdir/builddir/tloc \
$$_topdir/debian/rules -e do-build ${_shutup}
#
# build mksh-diet (if dietlibc), mksh-small (otherwise)
#
_topdir=$$(pwd); cd builddir/small && env ${STATIC_ENV} \
LC_ALL=C LOCPATH=$$_topdir/builddir/tloc \
$$_topdir/debian/rules -e do-build ${_shutup}
ln builddir/small/mksh builddir/small/mksh-static
#
# finished building
#
touch $@
clean:
dh_testdir
-rm -f debian/.*_stamp
-rm -rf builddir
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_install
dh_installmenu
dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
install -m 644 dot.mkshrc debian/mksh/etc/mkshrc
dh_link
dh_strip
dh_compress
cd debian/mksh/usr/share/man/man1 && ln -sf mksh.1.gz mksh-static.1.gz
dh_fixperms
# dh_perl
# dh_python
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install check
|