1 #!/bin/sh 2 # mmap-win32 configure script 3 # 4 # Parts copied from FFmpeg's configure 5 # 6 7 set_all(){ 8 value=$1 9 shift 10 for var in $*; do 11 eval $var=$value 12 done 13 } 14 15 enable(){ 16 set_all yes $* 17 } 18 19 disable(){ 20 set_all no $* 21 } 22 23 enabled(){ 24 eval test "x\$$1" = "xyes" 25 } 26 27 disabled(){ 28 eval test "x\$$1" = "xno" 29 } 30 31 show_help(){ 32 echo "Usage: configure [options]" 33 echo "Options: [defaults in brackets after descriptions]" 34 echo "All \"enable\" options have \"disable\" counterparts" 35 echo 36 echo " --help print this message" 37 echo " --prefix=PREFIX install in PREFIX [$PREFIX]" 38 echo " --libdir=DIR install libs in DIR [$PREFIX/lib]" 39 echo " --incdir=DIR install includes in DIR [$PREFIX/include]" 40 echo " --enable-static build static libraries [yes]" 41 echo " --enable-msvc create msvc-compatible import lib [auto]" 42 echo 43 echo " --cc=CC use C compiler CC [$cc_default]" 44 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]" 45 exit 1 46 } 47 48 die_unknown(){ 49 echo "Unknown option \"$1\"." 50 echo "See $0 --help for available options." 51 exit 1 52 } 53 54 PREFIX="/mingw" 55 libdir="${PREFIX}/lib" 56 incdir="${PREFIX}/include/sys" 57 ar="ar" 58 cc_default="gcc" 59 ranlib="ranlib" 60 strip="strip" 61 62 DEFAULT="msvc 63 " 64 65 DEFAULT_YES="static 66 stripping 67 " 68 69 CMDLINE_SELECT="$DEFAULT 70 $DEFAULT_NO 71 $DEFAULT_YES 72 " 73 74 enable $DEFAULT_YES 75 disable $DEFAULT_NO 76 77 for opt do 78 optval="${opt#*=}" 79 case "$opt" in 80 --help) 81 show_help 82 ;; 83 --prefix=*) 84 PREFIX="$optval" 85 ;; 86 --libdir=*) 87 libdir="$optval" 88 ;; 89 --incdir=*) 90 incdir="$optval" 91 ;; 92 --cc=*) 93 cc="$optval" 94 ;; 95 --cross-prefix=*) 96 cross_prefix="$optval" 97 ;; 98 --enable-?*|--disable-?*) 99 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` 100 echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt 101 $action $option 102 ;; 103 *) 104 die_unknown $opt 105 ;; 106 esac 107 done 108 109 ar="${cross_prefix}${ar}" 110 cc_default="${cross_prefix}${cc_default}" 111 ranlib="${cross_prefix}${ranlib}" 112 strip="${cross_prefix}${strip}" 113 114 if ! test -z $cc; then 115 cc_default="${cc}" 116 fi 117 cc="${cc_default}" 118 119 disabled static && { 120 echo "At least one library type must be set."; 121 exit 1; 122 } 123 124 if enabled msvc; then 125 lib /? > /dev/null 2>&1 /dev/null || { 126 echo "MSVC's lib command not found." 127 echo "Make sure MSVC is installed and its bin folder is in your \$PATH." 128 exit 1 129 } 130 fi 131 132 if ! enabled stripping; then 133 strip="echo ignoring strip" 134 fi 135 136 enabled msvc && libcmd="lib" || libcmd="echo ignoring lib" 137 138 echo "# Automatically generated by configure" > config.mak 139 echo "PREFIX=$PREFIX" >> config.mak 140 echo "libdir=$libdir" >> config.mak 141 echo "incdir=$incdir" >> config.mak 142 echo "AR=$ar" >> config.mak 143 echo "CC=$cc" >> config.mak 144 echo "RANLIB=$ranlib" >> config.mak 145 echo "STRIP=$strip" >> config.mak 146 echo "BUILD_STATIC=$static" >> config.mak 147 echo "BUILD_MSVC=$msvc" >> config.mak 148 echo "LIBCMD=$libcmd" >> config.mak 149 150 echo "prefix: $PREFIX" 151 echo "libdir: $libdir" 152 echo "incdir: $incdir" 153 echo "ar: $ar" 154 echo "cc: $cc" 155 echo "ranlib: $ranlib" 156 echo "strip: $strip" 157 echo "static: $static" 158