~ chicken-core (master) /configure
Trap1#!/bin/sh2#3# configuration script for the CHICKEN build process4#5# Copyright (c) 2024, The CHICKEN Team6# All rights reserved.7#8# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following9# conditions are met:10#11# Redistributions of source code must retain the above copyright notice, this list of conditions and the following12# disclaimer.13# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following14# disclaimer in the documentation and/or other materials provided with the distribution.15# Neither the name of the author nor the names of its contributors may be used to endorse or promote16# products derived from this software without specific prior written permission.17#18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS19# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY20# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR21# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR23# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR25# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE26# POSSIBILITY OF SUCH DAMAGE.2728prefix=/usr/local29debug=30static=31host=32target=33tprefix=34pprefix=35psuffix=36srcdir=37vardir=38linker=39platform=40chicken=41pobjs=42mkcmd="make"4344usage () {45 echo "usage: configure [--help] [--prefix DIRECTORY] [--platform PLATFORM | list] [--chicken PROGRAMNAME] [--debugbuild] [--staticbuild] [--disable-shared] [--host HOSTSYSTEM] [--target TARGETSYSTEM] [--program-prefix PREFIX] [--program-suffix SUFFIX] [--target-prefix DIRECTORY] [--srcdir DIRECTORY] [--vardir DIRECTORY] [--c-compiler PROGRAMNAME] [--linker PROGRAMNAME] [--profile-objects OBJECTLIST]"46 echo47 echo "consult the README file for more information."48 exit "$1"49}5051while [ -n "$1" ]; do52 arg="$1"53 shift54 case "$arg" in55 -h|-help|--help)56 usage 0;;57 --chicken=*)58 chicken=${arg#--chicken=};;59 --chicken)60 test -z "$1" && usage 1 >&261 chicken="$1"62 shift;;63 --prefix=*)64 prefix=${arg#--prefix=};;65 --prefix)66 test -z "$1" && usage 1 >&267 prefix="$1"68 shift;;69 --platform=*)70 platform=${arg#--platform=};;71 --platform)72 test -z "$1" && usage 1 >&273 platform="$1"74 shift;;75 --debugbuild)76 debug=1;;77 --staticbuild|--disable-shared)78 static=1;;79 --host=*)80 host=${arg#--host=};;81 --host)82 test -z "$1" && usage 1 >&283 host="$1"84 shift;;85 --target=*)86 target=${arg#--target=};;87 --target)88 test -z "$1" && usage 1 >&289 target="$1"90 shift;;91 --program-prefix=*)92 pprefix=${arg#--program-prefix=};;93 --program-prefix)94 test -z "$1" && usage 1 >&295 pprefix="$1"96 shift;;97 --program-suffix=*)98 psuffix=${arg#--program-suffix=};;99 --program-suffix)100 test -z "$1" && usage 1101 psuffix="$1"102 shift;;103 --target-prefix=*)104 tprefix=${arg#--target-prefix=};;105 --target-prefix)106 test -z "$1" && usage 1107 tprefix="$1"108 shift;;109 --srcdir=*)110 srcdir=${arg#--srcdir=};;111 --srcdir)112 test -z "$1" && usage 1 >&2113 srcdir="$1"114 shift;;115 --vardir=*)116 vardir=${arg#--vardir=};;117 --vardir)118 test -z "$1" && usage 1 >&2119 vardir="$1"120 shift;;121 --profile-objects=*)122 pobjs=${arg#--profile-objects=};;123 --profile-objects)124 test -z "$1" && usage 1 >&2125 pobjs="$1"126 shift;;127 --c-compiler=*)128 CC=${arg#--c-compiler=};;129 --c-compiler)130 test -z "$1" && usage 1 >&2131 CC="$1"132 shift;;133 --linker=*)134 linker=${arg#--linker=};;135 --linker)136 test -z "$1" && usage 1 >&2137 linker="$1"138 shift;;139 *)140 usage 1 >&2;;141 esac142done143144if [ "$platform" = list ]; then145 echo "available platforms:"146 echo147 for mf in Makefile.*; do148 echo " ${mf#Makefile.}"149 done150 echo151 exit152fi153154if [ -z "$platform" ]; then155 printf 'detecting platform ... '156157 # Detect the PLATFORM with uname.158 # Based on Chibi Scheme auto-detector159 # Heavily revamped by John Cowan160 # Moved into configure script by Felix Winkelmann161 # Copyright (c) 2009-2018 Alex Shinn, John Cowan162 # BSD license at <https://github.com/ashinn/chibi-scheme/blob/master/COPYING>163164 # Now we can use uname tests165 uname_s=$(uname)166 uname_o=$(uname -o 2>/dev/null)167168 case "$uname_s" in169 Darwin)170 platform=macosx;;171 *BSD)172 platform=bsd;;173 DragonFly)174 platform=bsd;;175 Windows_NT)176 platform=mingw177 case "$prefix" in178 /usr/local)179 prefix="C:/Program files/CHICKEN";;180 [a-zA-Z]:*)181 ;;182 *)183 echo "on Windows, the prefix must contain a drive letter" >&2184 exit 1;;185 esac;;186 SunOS)187 platform=solaris;;188 BeOS)189 platform=haiku;;190 Haiku)191 platform=haiku;;192 GNU)193 platform=hurd;;194 AIX)195 platform=aix;;196 *)197 case "$uname_o" in198 Cygwin)199 platform=cygwin;;200 Android)201 platform=android;;202 GNU/Linux)203 platform=linux;;204 Linux)205 platform=linux;;206 *)207 echo208 echo "unable to figure out platform" >&2209 exit 1;;210 esac;;211 esac212 echo "$platform"213fi214215cccmd="gcc"216if [ "$platform" = "bsd" ]; then217 cccmd="cc"218 if command -v gmake >/dev/null; then219 mkcmd="gmake"220 else221 echo "GNU make is required but does not seem to be available" >&2222 exit 1223 fi224fi225226echo "installation prefix: $prefix"227test -n "$chicken" && echo "bootstrap chicken: $chicken"228229test -n "$CC" && cccmd="$CC"230231printf "testing C compiler (%s) ... " "$cccmd"232tmpc="$(mktemp).c"233cat > "$tmpc" <<EOF234int main() {return 0;}235EOF236if command -v $cccmd >/dev/null; then237 if $cccmd "$tmpc" $CFLAGS -o "${tmpc}.out"; then238 rm -f "$tmpc"239 if "${tmpc}.out"; then240 echo works241 rm -f "${tmpc}.out"242 else243 rm -f "${tmpc}.out"244 echo245 echo "$cccmd does not seem to produce working executables" >&2246 exit 1247 fi248 else249 rm -f "$tmpc" "${tmpc}.out"250 echo251 echo "$cccmd does not seem to work" >&2252 exit 1253 fi254else255 echo256 echo "cannot find $cccmd" >&2257 exit 1258fi259260echo "# GENERATED BY configure" > config.make261echo "PLATFORM ?= $platform" >> config.make262echo "PREFIX ?= $prefix" >> config.make263test -n "$debug" && echo "DEBUGBUILD ?= 1" >> config.make264test -n "$static" && echo "STATICBUILD ?= 1" >> config.make265test -n "$CC" && echo "C_COMPILER ?= $cccmd" >> config.make266test -n "$linker" && echo "LINKER ?= $linker" >> config.make267test -n "$CFLAGS" && echo "C_COMPILER_OPTIMIZATION_OPTIONS ?= $CFLAGS" >> config.make268test -n "$host" && echo "HOSTSYSTEM ?= $host" >> config.make269test -n "$target" && echo "TARGETSYSTEM ?= $target" >> config.make270test -n "$pprefix" && echo "PROGRAM_PREFIX ?= $pprefix" >> config.make271test -n "$psuffix" && echo "PROGRAM_SUFFIX ?= $psuffix" >> config.make272test -n "$tprefix" && echo "TARGET_PREFIX ?= $tprefix" >> config.make273test -n "$srcdir" && echo "SRCDIR ?= $srcdir" >> config.make274test -n "$vardir" && echo "VARDIR ?= $vardir" >> config.make275test -n "$chicken" && echo "CHICKEN ?= $chicken" >> config.make276test -n "$pobjs" && echo "PROFILE_OBJECTS ?= $pobjs" >> config.make277278echo279echo "now run ${mkcmd} to build the system"280echo