3 # Build a binary package using polypkg
4 # Usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]
7 # Make sure IFS is set to space, tab, newline in that order.
15 usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]"
19 while test $# -gt 0; do
24 PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}"
27 flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
28 PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
36 PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
40 arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
41 PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg"
48 PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2"
52 arg=`echo "$1" | sed -n 's/^--osversion=\(.*\)/\1/p'`
65 configure_opts="${configure_opts}${configure_opts+$tab}$1"
68 # Pass unknown options to configure
69 configure_opts="${configure_opts}${configure_opts+$tab}$1"
75 top_srcdir=`dirname $0`
77 : ${osversion="`$top_srcdir/pp --probe`"}
78 test -n "$osversion" || exit 1
79 osrelease=`echo "$osversion" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`
84 # Linux distros may build binaries as pie files.
85 # This is really something libtool should figure out, but it does not.
87 *-s390*|*-sparc*|*-alpha*)
95 # Choose compiler options by osversion if not cross-compiling.
96 if [ "$crossbuild" = "false" ]; then
99 # Use the HP ANSI C compiler on HP-UX if possible
100 if [ -z "$CC" -a -x /opt/ansic/bin/cc ]; then
101 CC=/opt/ansic/bin/cc; export CC
102 if [ -z "$CFLAGS" ]; then
103 CFLAGS=-O; export CFLAGS
108 # Use the Sun Studio C compiler on Solaris if possible
109 if [ -z "$CC" -a -x /usr/bin/cc ]; then
110 CC=/usr/bin/cc; export CC
111 if [ -z "$CFLAGS" ]; then
112 CFLAGS=-O; export CFLAGS
119 # Choose configure options by osversion.
120 # We use the same configure options as vendor packages when possible.
124 if [ $osrelease -ge 50 ]; then
125 # RHEL 5 and up build pies and have audit support
126 export CFLAGS="-O2 $F_PIE" LDFLAGS="-pie"
127 configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit"
128 PPVARS="${PPVARS}${PPVARS+$space}linux_audit=1.4.0"
130 # Note, must indent with tabs, not spaces due to IFS trickery
131 configure_opts="$configure_opts
133 --with-logging=syslog
134 --with-logfac=authpriv
138 --with-editor=/bin/vi
144 --with-passprompt=[sudo] password for %p: "
148 if [ $osrelease -ge 10 ]; then
149 # SLES 10 and higher build pies
150 export CFLAGS="-O2 $F_PIE" LDFLAGS="-pie"
151 if [ $osrelease -ge 11 ]; then
152 # SLES 11 and higher has SELinux
153 configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
156 # SuSE doesn't have /usr/libexec
158 *64*) libexec=lib64;;
161 # Note, must indent with tabs, not spaces due to IFS trickery
162 # XXX - SuSE uses secure path but only for env_reset
163 configure_opts="$configure_opts
165 --libexecdir=$prefix/$libexec/sudo
166 --with-logging=syslog
171 --enable-shell-sets-home
172 --with-sudoers-mode=0440
177 --with-passprompt=%p\'s password: "
179 make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
183 # If Ubuntu, add --enable-admin-flag
186 configure_opts="${configure_opts}${configure_opts+$tab}--enable-admin-flag${tab}--without-lecture"
189 # Note, must indent with tabs, not spaces due to IFS trickery
190 if test "$flavor" = "ldap"; then
191 configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap
192 --with-ldap-conf-file=/etc/sudo-ldap.conf"
194 configure_opts="$configure_opts
201 --with-logging=syslog
202 --with-logfac=authpriv
204 --with-editor=/usr/bin/editor
206 --with-password-timeout=0
207 --with-passprompt=[sudo] password for %p:
208 --with-timedir=/var/lib/sudo
209 --disable-root-mailer
211 --with-sendmail=/usr/sbin/sendmail
212 --mandir=/usr/share/man
213 --libexecdir=/usr/lib/sudo
214 --with-secure-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"
217 # For Solaris, add project support and use let configure choose zlib.
218 # For all others, use the builtin zlib.
220 sol*) configure_opts="${configure_opts}${configure_opts+$tab}--with-project";;
221 *) configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin";;
223 if test "$flavor" = "ldap"; then
224 configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap"
226 # Note, must indent with tabs, not spaces due to IFS trickery
227 configure_opts="$configure_opts
229 --with-insults=disabled
230 --with-logging=syslog
232 --with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi
237 # Remove spaces from IFS when setting $@ so that passprompt may include them
240 set -- $configure_opts $extra_opts
242 if [ -r Makefile ]; then
243 make $make_opts distclean
245 $top_srcdir/configure "$@" || exit 1
246 make $make_opts && make $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package
247 test $debug -eq 0 && rm -rf destdir