configure (10998B)
1 #!/bin/sh 2 cd "$(dirname "$0")" || exit $? 3 sh=$(which sh) || exit $? 4 export sh 5 6 usage () { 7 cat <<EOF 8 Usage: $0 [OPTION]... 9 10 Defaults for the options are specified in brackets. 11 12 Installation directories: 13 --prefix=PREFIX main installation prefix [/] 14 --dynlibdir=DIR shared library files [PREFIX/lib] 15 --bindir=BINDIR user executables [PREFIX/bin] 16 --libexecdir=DIR package-scoped executables [PREFIX/libexec] 17 --libdir=DIR static library files [PREFIX/lib] 18 --includedir=DIR C header files [PREFIX/include] 19 --sysconfdir=DIR global configuration files [PREFIX/etc] 20 --pkgconfdir=DIR pkg-config .pc files [PREFIX/lib/pkgconfig] 21 22 Dependencies: 23 --with-sysdeps=DIR use sysdeps in DIR [PREFIX/lib/skalibs/sysdeps] 24 --with-include=DIR add DIR to the list of searched directories for headers 25 --with-lib=DIR add DIR to the list of searched directories for static libraries 26 --with-dynlib=DIR add DIR to the list of searched directories for shared libraries 27 --with-pkgconfig[=PROG] use pkg-config to look for dependencies 28 29 If no --prefix option is given, by default sysdeps will be fetched from 30 /usr/lib/skalibs/sysdeps. 31 32 Optional features: 33 --enable-shared build shared libraries [disabled] 34 --disable-static do not build static libraries [enabled] 35 --disable-allstatic do not prefer linking against static libraries [enabled] 36 --enable-static-libc make entirely static binaries [disabled] 37 --disable-all-pic do not build executables or static libs as PIC [enabled] 38 --enable-pkgconfig Build and install .pc files for pkg-config [disabled] 39 --enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled] 40 --enable-absolute-paths hardcode absolute BINDIR/foobar paths in binaries [disabled] 41 --enable-nsss use the nsss library for user information [disabled] 42 --disable-execline don't use the execline library [enabled] 43 44 EOF 45 exit 0 46 } 47 48 stripdir() { 49 eval 'while true; do case $'$1' in (*/) '$1'=${'$1'%/};; (*) break;; esac; done' 50 } 51 52 got_arg() { 53 case $1 in 54 (prefix) arg_prefix=$2; stripdir arg_prefix ;; 55 (dynlibdir) arg_dynlibdir=$2; stripdir arg_dynlibdir ;; 56 (libexecdir) arg_libexecdir=$2; stripdir arg_libexecdir ;; 57 (bindir) arg_bindir=$2; stripdir arg_bindir ;; 58 (libdir) arg_libdir=$2; stripdir arg_libdir ;; 59 (includedir) arg_includedir=$2; stripdir arg_includedir ;; 60 (sysconfdir) arg_sysconfdir=$2; stripdir arg_sysconfdir ;; 61 (pkgconfdir) arg_pkgconfdir=$2; stripdir arg_pkgconfdir ;; 62 (*) return 1 ;; 63 esac 64 } 65 66 got_enable() { 67 case $1 in 68 (shared) 69 case $2 in 70 (libc) enable_shared=libc;; 71 (yes) enable_shared=true;; 72 (no) enable_shared=false;; 73 (*) return 2;; 74 esac 75 ;; 76 (static) 77 case $2 in 78 (yes) enable_shared=false;; 79 (no) enable_shared=true;; 80 (*) return 2;; 81 esac 82 ;; 83 (absolute-paths) 84 case $2 in 85 (manual) enable_abspath=manual;; 86 (yes) enable_abspath=true;; 87 (no) enable_abspath=false;; 88 (*) return 2;; 89 esac 90 ;; 91 (*) return 1 ;; 92 esac 93 } 94 95 got_prog() { 96 case $1 in 97 (awk) prog_awk=$2 ;; 98 (cd) prog_cd=$2 ;; 99 (execlineb) prog_execlineb=$2 ;; 100 (if) prog_if=$2 ;; 101 (importas) prog_importas=$2 ;; 102 (ln) prog_ln=$2 ;; 103 (mkdir) prog_mkdir=$2 ;; 104 (mknod) prog_mknod=$2 ;; 105 (mount) prog_mount=$2 ;; 106 (multisubstitute) prog_multisubstitute=$2 ;; 107 (runblock) prog_runblock=$2 ;; 108 (sh) prog_sh=$2 ;; 109 (shift) prog_shift=$2 ;; 110 (*) return 1 ;; 111 esac 112 } 113 114 parse_args() { 115 for arg ; do 116 case "$arg" in 117 (--help) usage ;; 118 (--enable-*=*) 119 arg1=${arg%%=*} 120 arg1=${arg1#--enable-} 121 arg2=${arg#*=} 122 got_enable "$arg1" "$arg2" && continue 123 ;; 124 (--enable-*) 125 got_enable "${arg#--enable-}" yes && continue 126 ;; 127 (--disable-*=yes) 128 arg1=${arg#--disable-} 129 got_enable "${arg%=*}" no && continue 130 ;; 131 (--disable-*=no) 132 arg1=${arg#--disable-} 133 got_enable "${arg%=*}" yes && continue 134 ;; 135 (--disable-*=*) # error 136 ;; 137 (--disable-*) 138 arg1=${arg#--disable-} 139 got_enable "${arg%=*}" no && continue 140 ;; 141 (--path-to-*=*) 142 arg1=${arg%%=*} 143 arg1=${arg1#--path-to-} 144 arg2=${arg#*=} 145 got_prog "$arg1" "$arg2" && continue 146 ;; 147 (--*=*) 148 arg1=${arg%%=*} 149 arg1=${arg1#--} 150 arg2=${arg#*=} 151 got_arg "$arg1" "$arg2" && continue 152 ;; 153 # --exec-prefix=*) exec_prefix=${arg#*=} ;; 154 # --with-sysdeps=*) sysdeps=${arg#*=} manualsysdeps=true ;; 155 # --with-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ; depincpath="${depincpath}${depincpath:+ }-I$var" ;; 156 # --with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; deplibpath="${deplibpath}${deplibpath:+ }-L$var" ; vpaths="$vpaths $var" ;; 157 # --with-dynlib=*) var=${arg#*=} ; stripdir var ; addlibdpath="$addlibdpath -L$var" ; vpathd="$vpathd $var" ;; 158 # --with-pkgconfig=*) pkgconf=${arg#*=} ;; 159 # --with-pkgconfig) pkgconf=${PKG_CONFIG:-pkg-config} ;; 160 # --without-pkgconfig) pkgconf= ;; 161 # --enable-all-pic|--enable-all-pic=yes) allpic=true ;; 162 # --disable-all-pic|--enable-all-pic=no) allpic=false ;; 163 esac 164 printf >&2 'configure: fatal: unrecognized option: %s\n' "$arg" 165 exit 2 166 done 167 } 168 169 parse_args "$@" 170 171 prefix=${arg_prefix-/usr/local} 172 dynlibdir=${arg_dynlibdir-${prefix}/lib} 173 libexecdir=${arg_libexecdir-${prefix}/libexec} 174 bindir=${arg_bindir-${prefix}/bin} 175 libdir=${arg_libdir-${prefix}/lib} 176 includedir=${arg_includedir-${prefix}/include} 177 sysconfdir=${arg_sysconfdir-${prefix}/etc} 178 pkgconfdir=${arg_pkgconfdir-${prefix}/lib/pkgconfig} 179 180 # CC 181 # CFLAGS 182 : ${CFLAGS=-D_GNU_SOURCE -Werror -pipe -std=c11 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -g} 183 export CFLAGS 184 # CPATH 185 # CPPFLAGS 186 # C_INCLUDE_PATH 187 # LDFLAGS 188 # LDLIBS 189 : ${LDLIBS=-lskarnet -lcap} 190 export LDLIBS 191 # LIBRARY_PATH 192 # LOADLIBES 193 194 case $enable_abspath in 195 (false) 196 : ${prog_awk=awk} 197 : ${prog_cd=cd} 198 : ${prog_execlineb=execlineb} 199 : ${prog_if=if} 200 : ${prog_importas=importas} 201 : ${prog_ln=ln} 202 # : ${prog_lns_mounts_to_env=lns-mounts-to-env} 203 : ${prog_mkdir=mkdir} 204 : ${prog_mknod=mknod} 205 : ${prog_mount=mount} 206 : ${prog_multisubstitute=multisubstitute} 207 : ${prog_runblock=runblock} 208 : ${prog_sh=sh} 209 : ${prog_shift=shift} 210 ;; 211 (true) 212 : ${prog_awk=$(which awk 2>/dev/null )} 213 : ${prog_cd=$(which cd 2>/dev/null )} 214 : ${prog_execlineb=$(which execlineb 2>/dev/null )} 215 : ${prog_if=$(which if 2>/dev/null )} 216 : ${prog_importas=$(which importas 2>/dev/null )} 217 : ${prog_ln=$(which ln 2>/dev/null )} 218 # : ${prog_lns_mounts_to_env=$(which lns-mounts-to-env 2>/dev/null )} 219 : ${prog_mkdir=$(which mkdir 2>/dev/null )} 220 : ${prog_mknod=$(which mknod 2>/dev/null )} 221 : ${prog_mount=$(which mount 2>/dev/null )} 222 : ${prog_multisubstitute=$(which multisubstitute 2>/dev/null )} 223 : ${prog_runblock=$(which runblock 2>/dev/null )} 224 : ${prog_sh=$(which sh 2>/dev/null )} 225 : ${prog_shift=$(which shift 2>/dev/null )} 226 ;; 227 (manual) ;; 228 (*) exit 3 ;; 229 esac 230 231 prog_lns_mounts_to_env=$bindir/lns-mounts-to-env 232 prog_lns_prepare_chroot=$bindir/lns-prepare-chroot 233 234 die_notfound() { 235 printf >&2 "configure: fatal: absolute paths required and path to '%s' was not found\n" "$1" 236 exit 1 237 } 238 239 test -n "$prog_awk" || die_notfound awk 240 test -n "$prog_cd" || die_notfound cd 241 test -n "$prog_execlineb" || die_notfound execlineb 242 test -n "$prog_if" || die_notfound if 243 test -n "$prog_importas" || die_notfound importas 244 test -n "$prog_ln" || die_notfound ln 245 test -n "$prog_lns_mounts_to_env" || die_notfound lns-mounts-to-env 246 test -n "$prog_lns_prepare_chroot" || die_notfound lns-mounts-to-env 247 test -n "$prog_mkdir" || die_notfound mkdir 248 test -n "$prog_mknod" || die_notfound mknod 249 test -n "$prog_mount" || die_notfound mount 250 test -n "$prog_multisubstitute" || die_notfound multisubstitute 251 test -n "$prog_runblock" || die_notfound runblock 252 test -n "$prog_sh" || die_notfound sh 253 test -n "$prog_shift" || die_notfound shift 254 255 replace_if_different() { 256 if ! test -e "$1"; then 257 mv "$1.new" "$1" || exit $? 258 return 0 259 fi 260 local R 261 cmp -s "$1" "$1.new" 262 R=$? 263 case $R in 264 (0) 265 rm "$1.new" || exit $? 266 ;; 267 (1) 268 mv "$1.new" "$1" || exit $? 269 ;; 270 (*) 271 printf >&2 "configure: fatal: failed to compare files %s and %s\n" "$1" "$1.new" 272 exit $R 273 ;; 274 esac 275 } 276 277 generate() { 278 local out=$1 279 shift || exit $? 280 "$@" >"$out.new" || exit $? 281 chmod +x "$out.new" || exit $? 282 replace_if_different "$out" || exit $? 283 } 284 285 mk_script_gen() { 286 set -e 287 awk -f ./scripts/args_to_sh.awk \ 288 awk="$prog_awk" \ 289 cd="$prog_cd" \ 290 execlineb="$prog_execlineb" \ 291 if="$prog_if" \ 292 importas="$prog_importas" \ 293 ln="$prog_ln" \ 294 lns-mounts-to-env="$prog_lns_mounts_to_env" \ 295 lns-prepare-chroot="$prog_lns_prepare_chroot" \ 296 mkdir="$prog_mkdir" \ 297 mknod="$prog_mknod" \ 298 mount="$prog_mount" \ 299 multisubstitute="$prog_multisubstitute" \ 300 runblock="$prog_runblock" \ 301 sh="$prog_sh" \ 302 shift="$prog_shift" 303 } 304 305 mk_config_mk() { 306 set -e 307 printf '%s\n' "INSTALL_BINDIR:=$bindir" 308 case $enable_shared in 309 (false) 310 printf '%s\n' 'install_bin_files:=${script_executable_paths} $(static_executables)' 311 ;; 312 (*) 313 printf '%s\n' 'install_bin_files:=${script_executable_paths} $(shared_executables)' 314 ;; 315 esac 316 } 317 318 mkdir -p conf || exit $? 319 320 generate conf/config.mk mk_config_mk 321 generate conf/script_gen mk_script_gen 322 generate conf/cc awk -f ./scripts/gen-cc 323 generate conf/ld.shared awk -f ./scripts/gen-ld 324 generate conf/ld.static env LDFLAGS="$LDFLAGS -static" awk -f ./scripts/gen-ld