Thu, 14 Mar 2024 22:05:20 +0100
fix superfluous semicolon
universe@753 | 1 | #!/bin/sh |
universe@753 | 2 | |
universe@753 | 3 | # create temporary directory |
universe@753 | 4 | TEMP_DIR=".tmp-`uname -n`" |
universe@753 | 5 | rm -Rf "$TEMP_DIR" |
universe@753 | 6 | if mkdir -p "$TEMP_DIR"; then |
universe@753 | 7 | : |
universe@753 | 8 | else |
universe@753 | 9 | echo "Cannot create tmp dir $TEMP_DIR" |
universe@753 | 10 | echo "Abort" |
universe@753 | 11 | exit 1 |
universe@753 | 12 | fi |
universe@753 | 13 | touch "$TEMP_DIR/options" |
universe@753 | 14 | touch "$TEMP_DIR/features" |
universe@753 | 15 | |
universe@753 | 16 | # define standard variables |
universe@753 | 17 | # also define standard prefix (this is where we will search for config.site) |
universe@753 | 18 | prefix=/usr |
universe@753 | 19 | exec_prefix= |
universe@753 | 20 | bindir= |
universe@753 | 21 | sbindir= |
universe@753 | 22 | libdir= |
universe@753 | 23 | libexecdir= |
universe@753 | 24 | datarootdir= |
universe@753 | 25 | datadir= |
universe@753 | 26 | sysconfdir= |
universe@753 | 27 | sharedstatedir= |
universe@753 | 28 | localstatedir= |
universe@753 | 29 | runstatedir= |
universe@753 | 30 | includedir= |
universe@753 | 31 | infodir= |
universe@753 | 32 | localedir= |
universe@753 | 33 | mandir= |
universe@753 | 34 | |
universe@753 | 35 | # custom variables |
universe@753 | 36 | src_dir=`pwd` |
universe@753 | 37 | DOXYGEN=`command -v doxygen` |
universe@753 | 38 | PANDOC=`command -v pandoc` |
universe@753 | 39 | |
universe@753 | 40 | # features |
universe@753 | 41 | |
universe@753 | 42 | # clean abort |
universe@753 | 43 | abort_configure() |
universe@753 | 44 | { |
universe@753 | 45 | rm -Rf "$TEMP_DIR" |
universe@753 | 46 | exit 1 |
universe@753 | 47 | } |
universe@753 | 48 | |
universe@753 | 49 | # help text |
universe@753 | 50 | printhelp() |
universe@753 | 51 | { |
universe@753 | 52 | echo "Usage: $0 [OPTIONS]..." |
universe@753 | 53 | cat << __EOF__ |
universe@753 | 54 | Installation directories: |
universe@753 | 55 | --prefix=PREFIX path prefix for architecture-independent files |
universe@753 | 56 | [/usr] |
universe@753 | 57 | --exec-prefix=EPREFIX path prefix for architecture-dependent files |
universe@753 | 58 | [PREFIX] |
universe@753 | 59 | |
universe@753 | 60 | --bindir=DIR user executables [EPREFIX/bin] |
universe@753 | 61 | --sbindir=DIR system admin executables [EPREFIX/sbin] |
universe@753 | 62 | --libexecdir=DIR program executables [EPREFIX/libexec] |
universe@753 | 63 | --sysconfdir=DIR system configuration files [PREFIX/etc] |
universe@753 | 64 | --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] |
universe@753 | 65 | --localstatedir=DIR modifiable single-machine data [PREFIX/var] |
universe@753 | 66 | --runstatedir=DIR run-time variable data [LOCALSTATEDIR/run] |
universe@753 | 67 | --libdir=DIR object code libraries [EPREFIX/lib] |
universe@753 | 68 | --includedir=DIR C header files [PREFIX/include] |
universe@753 | 69 | --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] |
universe@753 | 70 | --datadir=DIR read-only architecture-independent data [DATAROOTDIR] |
universe@753 | 71 | --infodir=DIR info documentation [DATAROOTDIR/info] |
universe@753 | 72 | --mandir=DIR man documentation [DATAROOTDIR/man] |
universe@753 | 73 | --localedir=DIR locale-dependent data [DATAROOTDIR/locale] |
universe@753 | 74 | |
universe@753 | 75 | Options: |
universe@753 | 76 | --debug add extra compile flags for debug builds |
universe@753 | 77 | --release add extra compile flags for release builds |
universe@753 | 78 | --with-docs=(all|html|api|none) |
universe@753 | 79 | |
universe@772 | 80 | Optional Features: |
universe@772 | 81 | --enable-coverage |
universe@772 | 82 | |
universe@753 | 83 | __EOF__ |
universe@753 | 84 | } |
universe@753 | 85 | |
universe@753 | 86 | # |
universe@753 | 87 | # parse arguments |
universe@753 | 88 | # |
universe@753 | 89 | BUILD_TYPE="default" |
universe@753 | 90 | for ARG in "$@" |
universe@753 | 91 | do |
universe@753 | 92 | case "$ARG" in |
universe@753 | 93 | "--prefix="*) prefix=${ARG#--prefix=} ;; |
universe@753 | 94 | "--exec-prefix="*) exec_prefix=${ARG#--exec-prefix=} ;; |
universe@753 | 95 | "--bindir="*) bindir=${ARG#----bindir=} ;; |
universe@753 | 96 | "--sbindir="*) sbindir=${ARG#--sbindir=} ;; |
universe@753 | 97 | "--libdir="*) libdir=${ARG#--libdir=} ;; |
universe@753 | 98 | "--libexecdir="*) libexecdir=${ARG#--libexecdir=} ;; |
universe@753 | 99 | "--datarootdir="*) datarootdir=${ARG#--datarootdir=} ;; |
universe@753 | 100 | "--datadir="*) datadir=${ARG#--datadir=} ;; |
universe@753 | 101 | "--sysconfdir="*) sysconfdir=${ARG#--sysconfdir=} ;; |
universe@753 | 102 | "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;; |
universe@753 | 103 | "--localstatedir="*) localstatedir=${ARG#--localstatedir=} ;; |
universe@753 | 104 | "--includedir="*) includedir=${ARG#--includedir=} ;; |
universe@753 | 105 | "--infodir="*) infodir=${ARG#--infodir=} ;; |
universe@753 | 106 | "--mandir"*) mandir=${ARG#--mandir} ;; |
universe@753 | 107 | "--localedir"*) localedir=${ARG#--localedir} ;; |
universe@753 | 108 | "--help"*) printhelp; abort_configure ;; |
universe@753 | 109 | "--debug") BUILD_TYPE="debug" ;; |
universe@753 | 110 | "--release") BUILD_TYPE="release" ;; |
universe@753 | 111 | "--with-docs="*) OPT_WITH_DOCS=${ARG#--with-docs=} ;; |
universe@772 | 112 | "--enable-coverage") FEATURE_COVERAGE=on ;; |
universe@772 | 113 | "--disable-coverage") unset FEATURE_COVERAGE ;; |
universe@753 | 114 | "-"*) echo "unknown option: $ARG"; abort_configure ;; |
universe@753 | 115 | esac |
universe@753 | 116 | done |
universe@753 | 117 | |
universe@753 | 118 | |
universe@753 | 119 | |
universe@753 | 120 | # set defaults for dir variables |
universe@753 | 121 | : ${exec_prefix:="$prefix"} |
universe@753 | 122 | : ${bindir:='${exec_prefix}/bin'} |
universe@753 | 123 | : ${sbindir:='${exec_prefix}/sbin'} |
universe@753 | 124 | : ${libdir:='${exec_prefix}/lib'} |
universe@753 | 125 | : ${libexecdir:='${exec_prefix}/libexec'} |
universe@753 | 126 | : ${datarootdir:='${prefix}/share'} |
universe@753 | 127 | : ${datadir:='${datarootdir}'} |
universe@753 | 128 | : ${sysconfdir:='${prefix}/etc'} |
universe@753 | 129 | : ${sharedstatedir:='${prefix}/com'} |
universe@753 | 130 | : ${localstatedir:='${prefix}/var'} |
universe@753 | 131 | : ${runstatedir:='${localstatedir}/run'} |
universe@753 | 132 | : ${includedir:='${prefix}/include'} |
universe@753 | 133 | : ${infodir:='${datarootdir}/info'} |
universe@753 | 134 | : ${mandir:='${datarootdir}/man'} |
universe@753 | 135 | : ${localedir:='${datarootdir}/locale'} |
universe@753 | 136 | |
universe@753 | 137 | # check if a config.site exists and load it |
universe@753 | 138 | if [ -n "$CONFIG_SITE" ]; then |
universe@753 | 139 | # CONFIG_SITE may contain space separated file names |
universe@753 | 140 | for cs in $CONFIG_SITE; do |
universe@753 | 141 | printf "loading defaults from $cs... " |
universe@753 | 142 | . "$cs" |
universe@753 | 143 | echo ok |
universe@753 | 144 | done |
universe@753 | 145 | elif [ -f "$prefix/share/config.site" ]; then |
universe@753 | 146 | printf "loading site defaults... " |
universe@753 | 147 | . "$prefix/share/config.site" |
universe@753 | 148 | echo ok |
universe@753 | 149 | elif [ -f "$prefix/etc/config.site" ]; then |
universe@753 | 150 | printf "loading site defaults... " |
universe@753 | 151 | . "$prefix/etc/config.site" |
universe@753 | 152 | echo ok |
universe@753 | 153 | fi |
universe@753 | 154 | |
universe@753 | 155 | # Test for availability of pkg-config |
universe@753 | 156 | PKG_CONFIG=`command -v pkg-config` |
universe@753 | 157 | : ${PKG_CONFIG:="false"} |
universe@753 | 158 | |
universe@753 | 159 | # Simple uname based platform detection |
universe@753 | 160 | # $PLATFORM is used for platform dependent dependency selection |
universe@753 | 161 | OS=`uname -s` |
universe@753 | 162 | OS_VERSION=`uname -r` |
universe@753 | 163 | printf "detect platform... " |
universe@753 | 164 | if [ "$OS" = "SunOS" ]; then |
universe@753 | 165 | PLATFORM="solaris sunos unix svr4" |
universe@815 | 166 | elif [ "$OS" = "Linux" ]; then |
universe@753 | 167 | PLATFORM="linux unix" |
universe@815 | 168 | elif [ "$OS" = "FreeBSD" ]; then |
universe@753 | 169 | PLATFORM="freebsd bsd unix" |
universe@815 | 170 | elif [ "$OS" = "OpenBSD" ]; then |
universe@815 | 171 | PLATFORM="openbsd bsd unix" |
universe@815 | 172 | elif [ "$OS" = "NetBSD" ]; then |
universe@815 | 173 | PLATFORM="netbsd bsd unix" |
universe@815 | 174 | elif [ "$OS" = "Darwin" ]; then |
universe@753 | 175 | PLATFORM="macos osx bsd unix" |
universe@815 | 176 | elif echo "$OS" | grep -i "MINGW" > /dev/null; then |
universe@753 | 177 | PLATFORM="windows mingw" |
universe@753 | 178 | fi |
universe@753 | 179 | : ${PLATFORM:="unix"} |
universe@753 | 180 | |
universe@753 | 181 | PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` |
universe@753 | 182 | echo "$PLATFORM_NAME" |
universe@753 | 183 | |
universe@753 | 184 | isplatform() |
universe@753 | 185 | { |
universe@753 | 186 | for p in $PLATFORM |
universe@753 | 187 | do |
universe@753 | 188 | if [ "$p" = "$1" ]; then |
universe@753 | 189 | return 0 |
universe@753 | 190 | fi |
universe@753 | 191 | done |
universe@753 | 192 | return 1 |
universe@753 | 193 | } |
universe@753 | 194 | notisplatform() |
universe@753 | 195 | { |
universe@753 | 196 | for p in $PLATFORM |
universe@753 | 197 | do |
universe@753 | 198 | if [ "$p" = "$1" ]; then |
universe@753 | 199 | return 1 |
universe@753 | 200 | fi |
universe@753 | 201 | done |
universe@753 | 202 | return 0 |
universe@753 | 203 | } |
universe@815 | 204 | istoolchain() |
universe@815 | 205 | { |
universe@815 | 206 | for t in $TOOLCHAIN |
universe@815 | 207 | do |
universe@815 | 208 | if [ "$t" = "$1" ]; then |
universe@815 | 209 | return 0 |
universe@815 | 210 | fi |
universe@815 | 211 | done |
universe@815 | 212 | return 1 |
universe@815 | 213 | } |
universe@815 | 214 | notistoolchain() |
universe@815 | 215 | { |
universe@815 | 216 | for t in $TOOLCHAIN |
universe@815 | 217 | do |
universe@815 | 218 | if [ "$t" = "$1" ]; then |
universe@815 | 219 | return 1 |
universe@815 | 220 | fi |
universe@815 | 221 | done |
universe@815 | 222 | return 0 |
universe@815 | 223 | } |
universe@753 | 224 | |
universe@753 | 225 | |
universe@753 | 226 | # generate vars.mk |
universe@753 | 227 | cat > "$TEMP_DIR/vars.mk" << __EOF__ |
universe@821 | 228 | prefix=$prefix |
universe@821 | 229 | exec_prefix=$exec_prefix |
universe@821 | 230 | bindir=$bindir |
universe@821 | 231 | sbindir=$sbindir |
universe@821 | 232 | libdir=$libdir |
universe@821 | 233 | libexecdir=$libexecdir |
universe@821 | 234 | datarootdir=$datarootdir |
universe@821 | 235 | datadir=$datadir |
universe@821 | 236 | sysconfdir=$sysconfdir |
universe@821 | 237 | sharedstatedir=$sharedstatedir |
universe@821 | 238 | localstatedir=$localstatedir |
universe@821 | 239 | runstatedir=$runstatedir |
universe@821 | 240 | includedir=$includedir |
universe@821 | 241 | infodir=$infodir |
universe@821 | 242 | mandir=$mandir |
universe@821 | 243 | localedir=$localedir |
universe@821 | 244 | src_dir=$src_dir |
universe@821 | 245 | DOXYGEN=$DOXYGEN |
universe@821 | 246 | PANDOC=$PANDOC |
universe@753 | 247 | __EOF__ |
universe@753 | 248 | |
universe@753 | 249 | # toolchain detection utilities |
universe@753 | 250 | . make/toolchain.sh |
universe@753 | 251 | |
universe@753 | 252 | # |
universe@753 | 253 | # DEPENDENCIES |
universe@753 | 254 | # |
universe@753 | 255 | |
universe@753 | 256 | # check languages |
universe@753 | 257 | lang_c= |
universe@753 | 258 | lang_cpp= |
universe@753 | 259 | if detect_c_compiler ; then |
universe@753 | 260 | lang_c=1 |
universe@753 | 261 | fi |
universe@753 | 262 | |
universe@753 | 263 | # create buffer for make variables required by dependencies |
universe@753 | 264 | echo > "$TEMP_DIR/make.mk" |
universe@753 | 265 | |
universe@753 | 266 | test_pkg_config() |
universe@753 | 267 | { |
universe@753 | 268 | if "$PKG_CONFIG" --exists "$1" ; then : |
universe@753 | 269 | else return 1 ; fi |
universe@753 | 270 | if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : |
universe@753 | 271 | else return 1 ; fi |
universe@753 | 272 | if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : |
universe@753 | 273 | else return 1 ; fi |
universe@753 | 274 | if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : |
universe@753 | 275 | else return 1 ; fi |
universe@753 | 276 | return 0 |
universe@753 | 277 | } |
universe@753 | 278 | |
universe@796 | 279 | print_check_msg() |
universe@796 | 280 | { |
universe@796 | 281 | if [ -z "$1" ]; then |
universe@796 | 282 | shift |
universe@796 | 283 | printf "$@" |
universe@796 | 284 | fi |
universe@796 | 285 | } |
universe@796 | 286 | |
universe@772 | 287 | dependency_error_coverage() |
universe@772 | 288 | { |
universe@796 | 289 | print_check_msg "$dep_checked_coverage" "checking for coverage... " |
universe@815 | 290 | # dependency coverage toolchain="gnuc" |
universe@772 | 291 | while true |
universe@772 | 292 | do |
universe@815 | 293 | if notistoolchain "gnuc"; then |
universe@815 | 294 | break |
universe@815 | 295 | fi |
universe@788 | 296 | TEMP_CFLAGS="$TEMP_CFLAGS \${COVERAGE_CFLAGS}" |
universe@788 | 297 | TEMP_LDFLAGS="$TEMP_LDFLAGS \${COVERAGE_LDFLAGS}" |
universe@796 | 298 | print_check_msg "$dep_checked_coverage" "yes\n" |
universe@796 | 299 | dep_checked_coverage=1 |
universe@772 | 300 | return 1 |
universe@772 | 301 | done |
universe@772 | 302 | |
universe@796 | 303 | print_check_msg "$dep_checked_coverage" "no\n" |
universe@796 | 304 | dep_checked_coverage=1 |
universe@772 | 305 | return 0 |
universe@772 | 306 | } |
universe@753 | 307 | dependency_error_pandoc() |
universe@753 | 308 | { |
universe@796 | 309 | print_check_msg "$dep_checked_pandoc" "checking for pandoc... " |
universe@753 | 310 | # dependency pandoc |
universe@753 | 311 | while true |
universe@753 | 312 | do |
universe@753 | 313 | if test -n "$PANDOC" > /dev/null ; then |
universe@753 | 314 | : |
universe@753 | 315 | else |
universe@753 | 316 | break |
universe@753 | 317 | fi |
universe@796 | 318 | print_check_msg "$dep_checked_pandoc" "yes\n" |
universe@796 | 319 | dep_checked_pandoc=1 |
universe@753 | 320 | return 1 |
universe@753 | 321 | done |
universe@753 | 322 | |
universe@796 | 323 | print_check_msg "$dep_checked_pandoc" "no\n" |
universe@796 | 324 | dep_checked_pandoc=1 |
universe@753 | 325 | return 0 |
universe@753 | 326 | } |
universe@753 | 327 | dependency_error_c() |
universe@753 | 328 | { |
universe@796 | 329 | print_check_msg "$dep_checked_c" "checking for c... " |
universe@753 | 330 | # dependency c platform="mingw" |
universe@753 | 331 | while true |
universe@753 | 332 | do |
universe@753 | 333 | if notisplatform "mingw"; then |
universe@753 | 334 | break |
universe@753 | 335 | fi |
universe@753 | 336 | if [ -z "$lang_c" ] ; then |
universe@753 | 337 | break |
universe@753 | 338 | fi |
universe@753 | 339 | cat >> $TEMP_DIR/make.mk << __EOF__ |
universe@753 | 340 | # Dependency: c |
universe@753 | 341 | AR=ar |
universe@753 | 342 | ARFLAGS=r |
universe@753 | 343 | STLIB_EXT=.lib |
universe@753 | 344 | SHLIB_EXT=.dll |
universe@753 | 345 | __EOF__ |
universe@796 | 346 | print_check_msg "$dep_checked_c" "yes\n" |
universe@796 | 347 | dep_checked_c=1 |
universe@753 | 348 | return 1 |
universe@753 | 349 | done |
universe@753 | 350 | |
universe@753 | 351 | # dependency c platform="macos" |
universe@753 | 352 | while true |
universe@753 | 353 | do |
universe@753 | 354 | if notisplatform "macos"; then |
universe@753 | 355 | break |
universe@753 | 356 | fi |
universe@753 | 357 | if [ -z "$lang_c" ] ; then |
universe@753 | 358 | break |
universe@753 | 359 | fi |
universe@753 | 360 | cat >> $TEMP_DIR/make.mk << __EOF__ |
universe@753 | 361 | # Dependency: c |
universe@753 | 362 | AR=ar |
universe@753 | 363 | ARFLAGS=r |
universe@753 | 364 | STLIB_EXT=.a |
universe@753 | 365 | SHLIB_EXT=.dylib |
universe@753 | 366 | __EOF__ |
universe@796 | 367 | print_check_msg "$dep_checked_c" "yes\n" |
universe@796 | 368 | dep_checked_c=1 |
universe@753 | 369 | return 1 |
universe@753 | 370 | done |
universe@753 | 371 | |
universe@753 | 372 | # dependency c platform="unix" |
universe@753 | 373 | while true |
universe@753 | 374 | do |
universe@753 | 375 | if notisplatform "unix"; then |
universe@753 | 376 | break |
universe@753 | 377 | fi |
universe@753 | 378 | if [ -z "$lang_c" ] ; then |
universe@753 | 379 | break |
universe@753 | 380 | fi |
universe@753 | 381 | cat >> $TEMP_DIR/make.mk << __EOF__ |
universe@753 | 382 | # Dependency: c |
universe@753 | 383 | AR=ar |
universe@753 | 384 | ARFLAGS=r |
universe@753 | 385 | STLIB_EXT=.a |
universe@753 | 386 | SHLIB_EXT=.so |
universe@753 | 387 | __EOF__ |
universe@796 | 388 | print_check_msg "$dep_checked_c" "yes\n" |
universe@796 | 389 | dep_checked_c=1 |
universe@753 | 390 | return 1 |
universe@753 | 391 | done |
universe@753 | 392 | |
universe@796 | 393 | print_check_msg "$dep_checked_c" "no\n" |
universe@796 | 394 | dep_checked_c=1 |
universe@753 | 395 | return 0 |
universe@753 | 396 | } |
universe@753 | 397 | dependency_error_file_tools() |
universe@753 | 398 | { |
universe@821 | 399 | print_check_msg "$dep_checked_file_tools" "checking for file_tools... " |
universe@753 | 400 | # dependency file-tools |
universe@753 | 401 | while true |
universe@753 | 402 | do |
universe@753 | 403 | cat >> $TEMP_DIR/make.mk << __EOF__ |
universe@821 | 404 | # Dependency: file_tools |
universe@754 | 405 | MKDIR=/bin/mkdir -p |
universe@754 | 406 | RMFILE=/bin/rm -f |
universe@754 | 407 | RMDIR=/bin/rm -f -R |
universe@754 | 408 | COPYFILE=/bin/cp -f |
universe@754 | 409 | COPYALL=/bin/cp -f -R |
universe@754 | 410 | SYMLINK=/bin/ln -s |
universe@753 | 411 | __EOF__ |
universe@796 | 412 | print_check_msg "$dep_checked_file_tools" "yes\n" |
universe@796 | 413 | dep_checked_file_tools=1 |
universe@753 | 414 | return 1 |
universe@753 | 415 | done |
universe@753 | 416 | |
universe@796 | 417 | print_check_msg "$dep_checked_file_tools" "no\n" |
universe@796 | 418 | dep_checked_file_tools=1 |
universe@753 | 419 | return 0 |
universe@753 | 420 | } |
universe@753 | 421 | dependency_error_doxygen() |
universe@753 | 422 | { |
universe@796 | 423 | print_check_msg "$dep_checked_doxygen" "checking for doxygen... " |
universe@753 | 424 | # dependency doxygen |
universe@753 | 425 | while true |
universe@753 | 426 | do |
universe@753 | 427 | if test -n "$DOXYGEN" > /dev/null ; then |
universe@753 | 428 | : |
universe@753 | 429 | else |
universe@753 | 430 | break |
universe@753 | 431 | fi |
universe@796 | 432 | print_check_msg "$dep_checked_doxygen" "yes\n" |
universe@796 | 433 | dep_checked_doxygen=1 |
universe@753 | 434 | return 1 |
universe@753 | 435 | done |
universe@753 | 436 | |
universe@796 | 437 | print_check_msg "$dep_checked_doxygen" "no\n" |
universe@796 | 438 | dep_checked_doxygen=1 |
universe@753 | 439 | return 0 |
universe@753 | 440 | } |
universe@753 | 441 | |
universe@753 | 442 | # start collecting dependency information |
universe@753 | 443 | echo > "$TEMP_DIR/flags.mk" |
universe@753 | 444 | |
universe@753 | 445 | DEPENDENCIES_FAILED= |
universe@753 | 446 | ERROR=0 |
universe@753 | 447 | # unnamed dependencies |
universe@753 | 448 | TEMP_CFLAGS= |
universe@753 | 449 | TEMP_CXXFLAGS= |
universe@753 | 450 | TEMP_LDFLAGS= |
universe@753 | 451 | while true |
universe@753 | 452 | do |
universe@753 | 453 | while true |
universe@753 | 454 | do |
universe@753 | 455 | |
universe@753 | 456 | cat >> "$TEMP_DIR/make.mk" << __EOF__ |
universe@753 | 457 | # library version |
universe@759 | 458 | VERSION=3.1.0 |
universe@825 | 459 | LIBVERSION=5.0.0 |
universe@825 | 460 | LIBVERSION_MAJOR=5 |
universe@753 | 461 | |
universe@753 | 462 | # build directory structure !! do not change or override !! |
universe@754 | 463 | build_dir=${src_dir}/build |
universe@754 | 464 | docs_dir=${src_dir}/build/docs |
universe@754 | 465 | dist_dir=${src_dir}/dist |
universe@753 | 466 | __EOF__ |
universe@753 | 467 | break |
universe@753 | 468 | done |
universe@753 | 469 | break |
universe@753 | 470 | done |
olaf@842 | 471 | while true |
olaf@842 | 472 | do |
olaf@842 | 473 | if notisplatform "solaris"; then |
olaf@842 | 474 | break |
olaf@842 | 475 | fi |
olaf@842 | 476 | while true |
olaf@842 | 477 | do |
olaf@842 | 478 | |
olaf@842 | 479 | TEMP_LDFLAGS="$TEMP_LDFLAGS -lm" |
olaf@842 | 480 | break |
olaf@842 | 481 | done |
olaf@842 | 482 | break |
olaf@842 | 483 | done |
universe@753 | 484 | |
universe@753 | 485 | # add general dependency flags to flags.mk |
universe@753 | 486 | echo "# general flags" >> "$TEMP_DIR/flags.mk" |
universe@815 | 487 | if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
universe@753 | 488 | echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
universe@753 | 489 | fi |
universe@815 | 490 | if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
universe@753 | 491 | echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
universe@753 | 492 | fi |
universe@753 | 493 | if [ -n "${TEMP_LDFLAGS}" ]; then |
universe@753 | 494 | echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
universe@753 | 495 | fi |
universe@753 | 496 | |
universe@753 | 497 | # |
universe@753 | 498 | # OPTION VALUES |
universe@753 | 499 | # |
universe@753 | 500 | checkopt_with_docs_all() |
universe@753 | 501 | { |
universe@753 | 502 | VERR=0 |
universe@753 | 503 | if dependency_error_pandoc ; then |
universe@753 | 504 | VERR=1 |
universe@753 | 505 | fi |
universe@753 | 506 | if dependency_error_doxygen ; then |
universe@753 | 507 | VERR=1 |
universe@753 | 508 | fi |
universe@753 | 509 | if [ $VERR -ne 0 ]; then |
universe@753 | 510 | return 1 |
universe@753 | 511 | fi |
universe@753 | 512 | cat >> "$TEMP_DIR/make.mk" << __EOF__ |
universe@753 | 513 | # Documentation |
universe@753 | 514 | WITH_DOCS_API=yes |
universe@753 | 515 | WITH_DOCS_HTML=yes |
universe@753 | 516 | __EOF__ |
universe@753 | 517 | return 0 |
universe@753 | 518 | } |
universe@753 | 519 | checkopt_with_docs_html() |
universe@753 | 520 | { |
universe@753 | 521 | VERR=0 |
universe@753 | 522 | if dependency_error_pandoc ; then |
universe@753 | 523 | VERR=1 |
universe@753 | 524 | fi |
universe@753 | 525 | if [ $VERR -ne 0 ]; then |
universe@753 | 526 | return 1 |
universe@753 | 527 | fi |
universe@753 | 528 | cat >> "$TEMP_DIR/make.mk" << __EOF__ |
universe@753 | 529 | # Documentation |
universe@753 | 530 | WITH_DOCS_HTML=yes |
universe@753 | 531 | __EOF__ |
universe@753 | 532 | return 0 |
universe@753 | 533 | } |
universe@753 | 534 | checkopt_with_docs_api() |
universe@753 | 535 | { |
universe@753 | 536 | VERR=0 |
universe@753 | 537 | if dependency_error_doxygen ; then |
universe@753 | 538 | VERR=1 |
universe@753 | 539 | fi |
universe@753 | 540 | if [ $VERR -ne 0 ]; then |
universe@753 | 541 | return 1 |
universe@753 | 542 | fi |
universe@753 | 543 | cat >> "$TEMP_DIR/make.mk" << __EOF__ |
universe@753 | 544 | # Documentation |
universe@753 | 545 | WITH_DOCS_API=yes |
universe@753 | 546 | __EOF__ |
universe@753 | 547 | return 0 |
universe@753 | 548 | } |
universe@753 | 549 | checkopt_with_docs_none() |
universe@753 | 550 | { |
universe@753 | 551 | VERR=0 |
universe@753 | 552 | if [ $VERR -ne 0 ]; then |
universe@753 | 553 | return 1 |
universe@753 | 554 | fi |
universe@753 | 555 | return 0 |
universe@753 | 556 | } |
universe@753 | 557 | |
universe@753 | 558 | # |
universe@753 | 559 | # TARGETS |
universe@753 | 560 | # |
universe@753 | 561 | |
universe@753 | 562 | echo >> "$TEMP_DIR/flags.mk" |
universe@753 | 563 | echo "configuring global target" |
universe@753 | 564 | echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" |
universe@753 | 565 | TEMP_CFLAGS= |
universe@753 | 566 | TEMP_CXXFLAGS= |
universe@753 | 567 | TEMP_LDFLAGS= |
universe@753 | 568 | |
universe@753 | 569 | if dependency_error_c; then |
universe@753 | 570 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED c " |
universe@753 | 571 | ERROR=1 |
universe@753 | 572 | fi |
universe@753 | 573 | if dependency_error_file_tools; then |
universe@753 | 574 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED file_tools " |
universe@753 | 575 | ERROR=1 |
universe@753 | 576 | fi |
universe@753 | 577 | |
universe@753 | 578 | # Features |
universe@772 | 579 | if [ -n "$FEATURE_COVERAGE" ]; then |
universe@772 | 580 | # check dependency |
universe@772 | 581 | if dependency_error_coverage ; then |
universe@772 | 582 | # "auto" features can fail and are just disabled in this case |
universe@772 | 583 | if [ "$FEATURE_COVERAGE" = "auto" ]; then |
universe@772 | 584 | DISABLE_FEATURE_COVERAGE=1 |
universe@772 | 585 | else |
universe@772 | 586 | DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED coverage " |
universe@772 | 587 | ERROR=1 |
universe@772 | 588 | fi |
universe@772 | 589 | fi |
universe@772 | 590 | if [ -n "$DISABLE_FEATURE_COVERAGE" ]; then |
universe@772 | 591 | unset FEATURE_COVERAGE |
universe@772 | 592 | fi |
universe@772 | 593 | fi |
universe@753 | 594 | |
universe@753 | 595 | # Option: --with-docs |
universe@753 | 596 | if [ -z "$OPT_WITH_DOCS" ]; then |
universe@753 | 597 | echo "auto-detecting option 'with-docs'" |
universe@753 | 598 | SAVED_ERROR="$ERROR" |
universe@753 | 599 | SAVED_DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED" |
universe@753 | 600 | ERROR=1 |
universe@753 | 601 | while true |
universe@753 | 602 | do |
universe@753 | 603 | if checkopt_with_docs_all ; then |
universe@753 | 604 | echo " with-docs: all" >> "$TEMP_DIR/options" |
universe@753 | 605 | ERROR=0 |
universe@753 | 606 | break |
universe@753 | 607 | fi |
universe@753 | 608 | if checkopt_with_docs_html ; then |
universe@753 | 609 | echo " with-docs: html" >> "$TEMP_DIR/options" |
universe@753 | 610 | ERROR=0 |
universe@753 | 611 | break |
universe@753 | 612 | fi |
universe@753 | 613 | if checkopt_with_docs_api ; then |
universe@753 | 614 | echo " with-docs: api" >> "$TEMP_DIR/options" |
universe@753 | 615 | ERROR=0 |
universe@753 | 616 | break |
universe@753 | 617 | fi |
universe@753 | 618 | if checkopt_with_docs_none ; then |
universe@753 | 619 | echo " with-docs: none" >> "$TEMP_DIR/options" |
universe@753 | 620 | ERROR=0 |
universe@753 | 621 | break |
universe@753 | 622 | fi |
universe@753 | 623 | break |
universe@753 | 624 | done |
universe@753 | 625 | if [ $ERROR -ne 0 ]; then |
universe@753 | 626 | SAVED_ERROR=1 |
universe@753 | 627 | SAVED_DEPENDENCIES_FAILED="option 'with-docs' $SAVED_DEPENDENCIES_FAILED" |
universe@753 | 628 | fi |
universe@753 | 629 | ERROR="$SAVED_ERROR" |
universe@753 | 630 | DEPENDENCIES_FAILED="$SAVED_DEPENDENCIES_FAILED" |
universe@753 | 631 | else |
universe@753 | 632 | echo "checking option with-docs = $OPT_WITH_DOCS" |
universe@753 | 633 | if false; then |
universe@753 | 634 | false |
universe@753 | 635 | elif [ "$OPT_WITH_DOCS" = "all" ]; then |
universe@753 | 636 | echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options |
universe@753 | 637 | if checkopt_with_docs_all ; then |
universe@753 | 638 | : |
universe@753 | 639 | else |
universe@753 | 640 | ERROR=1 |
universe@753 | 641 | DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" |
universe@753 | 642 | fi |
universe@753 | 643 | elif [ "$OPT_WITH_DOCS" = "html" ]; then |
universe@753 | 644 | echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options |
universe@753 | 645 | if checkopt_with_docs_html ; then |
universe@753 | 646 | : |
universe@753 | 647 | else |
universe@753 | 648 | ERROR=1 |
universe@753 | 649 | DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" |
universe@753 | 650 | fi |
universe@753 | 651 | elif [ "$OPT_WITH_DOCS" = "api" ]; then |
universe@753 | 652 | echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options |
universe@753 | 653 | if checkopt_with_docs_api ; then |
universe@753 | 654 | : |
universe@753 | 655 | else |
universe@753 | 656 | ERROR=1 |
universe@753 | 657 | DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" |
universe@753 | 658 | fi |
universe@753 | 659 | elif [ "$OPT_WITH_DOCS" = "none" ]; then |
universe@753 | 660 | echo " with-docs: $OPT_WITH_DOCS" >> $TEMP_DIR/options |
universe@753 | 661 | if checkopt_with_docs_none ; then |
universe@753 | 662 | : |
universe@753 | 663 | else |
universe@753 | 664 | ERROR=1 |
universe@753 | 665 | DEPENDENCIES_FAILED="option 'with-docs' $DEPENDENCIES_FAILED" |
universe@753 | 666 | fi |
universe@753 | 667 | fi |
universe@753 | 668 | fi |
universe@753 | 669 | |
universe@815 | 670 | if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
universe@753 | 671 | echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
universe@753 | 672 | fi |
universe@815 | 673 | if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then |
universe@753 | 674 | echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" |
universe@753 | 675 | fi |
universe@753 | 676 | if [ "$BUILD_TYPE" = "debug" ]; then |
universe@753 | 677 | if [ -n "$lang_c" ]; then |
universe@753 | 678 | echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
universe@753 | 679 | fi |
universe@753 | 680 | if [ -n "$lang_cpp" ]; then |
universe@753 | 681 | echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
universe@753 | 682 | fi |
universe@753 | 683 | fi |
universe@753 | 684 | if [ "$BUILD_TYPE" = "release" ]; then |
universe@753 | 685 | if [ -n "$lang_c" ]; then |
universe@753 | 686 | echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" |
universe@753 | 687 | fi |
universe@753 | 688 | if [ -n "$lang_cpp" ]; then |
universe@753 | 689 | echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" |
universe@753 | 690 | fi |
universe@753 | 691 | fi |
universe@753 | 692 | if [ -n "${TEMP_LDFLAGS}" ]; then |
universe@753 | 693 | echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" |
universe@753 | 694 | fi |
universe@753 | 695 | |
universe@753 | 696 | |
universe@753 | 697 | # final result |
universe@753 | 698 | if [ $ERROR -ne 0 ]; then |
universe@753 | 699 | echo |
universe@753 | 700 | echo "Error: Unresolved dependencies" |
universe@753 | 701 | echo "$DEPENDENCIES_FAILED" |
universe@753 | 702 | abort_configure |
universe@753 | 703 | fi |
universe@753 | 704 | |
universe@753 | 705 | echo "configure finished" |
universe@753 | 706 | echo |
universe@753 | 707 | echo "Build Config:" |
universe@753 | 708 | echo " PREFIX: $prefix" |
universe@753 | 709 | echo " TOOLCHAIN: $TOOLCHAIN_NAME" |
universe@753 | 710 | echo "Options:" |
universe@753 | 711 | cat "$TEMP_DIR/options" |
universe@772 | 712 | echo "Features:" |
universe@772 | 713 | if [ -n "$FEATURE_COVERAGE" ]; then |
universe@772 | 714 | echo " coverage: on" |
universe@772 | 715 | else |
universe@772 | 716 | echo " coverage: off" |
universe@772 | 717 | fi |
universe@753 | 718 | echo |
universe@753 | 719 | |
universe@753 | 720 | # generate the config.mk file |
universe@753 | 721 | cat > "$TEMP_DIR/config.mk" << __EOF__ |
universe@753 | 722 | # |
universe@753 | 723 | # config.mk generated by configure |
universe@753 | 724 | # |
universe@753 | 725 | |
universe@753 | 726 | __EOF__ |
universe@753 | 727 | write_toolchain_defaults "$TEMP_DIR/toolchain.mk" |
universe@753 | 728 | cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk |
universe@753 | 729 | rm -Rf "$TEMP_DIR" |