| 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 " --bindir=DIR install binaries in DIR [$PREFIX/bin]" |
| 39 | echo " --libdir=DIR install libs in DIR [$PREFIX/lib]" |
| 40 | echo " --incdir=DIR install includes in DIR [$PREFIX/include]" |
| 41 | echo " --enable-static build static libraries [yes]" |
| 42 | echo " --enable-shared build shared libraries [no]" |
| 43 | echo " --enable-msvc create msvc-compatible import lib [auto]" |
| 44 | echo |
| 45 | echo " --cc=CC use C compiler CC [$cc_default]" |
| 46 | echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]" |
| 47 | exit 1 |
| 48 | } |
| 49 | |
| 50 | die_unknown(){ |
| 51 | echo "Unknown option \"$1\"." |
| 52 | echo "See $0 --help for available options." |
| 53 | exit 1 |
| 54 | } |
| 55 | |
| 56 | PREFIX="/mingw" |
| 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 | DEFAULT_NO="shared |
| 70 | " |
| 71 | |
| 72 | CMDLINE_SELECT="$DEFAULT |
| 73 | $DEFAULT_NO |
| 74 | $DEFAULT_YES |
| 75 | " |
| 76 | |
| 77 | enable $DEFAULT_YES |
| 78 | disable $DEFAULT_NO |
| 79 | |
| 80 | for opt do |
| 81 | optval="${opt#*=}" |
| 82 | case "$opt" in |
| 83 | --help) |
| 84 | show_help |
| 85 | ;; |
| 86 | --prefix=*) |
| 87 | PREFIX="$optval" |
| 88 | ;; |
| 89 | --bindir=*) |
| 90 | bindir="$optval" |
| 91 | ;; |
| 92 | --libdir=*) |
| 93 | libdir="$optval" |
| 94 | ;; |
| 95 | --incdir=*) |
| 96 | incdir="$optval" |
| 97 | ;; |
| 98 | --cc=*) |
| 99 | cc="$optval" |
| 100 | ;; |
| 101 | --cross-prefix=*) |
| 102 | cross_prefix="$optval" |
| 103 | ;; |
| 104 | --enable-?*|--disable-?*) |
| 105 | eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` |
| 106 | echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt |
| 107 | $action $option |
| 108 | ;; |
| 109 | *) |
| 110 | die_unknown $opt |
| 111 | ;; |
| 112 | esac |
| 113 | done |
| 114 | |
| 115 | bindir="${PREFIX}/bin" |
| 116 | libdir="${PREFIX}/lib" |
| 117 | incdir="${PREFIX}/include/sys" |
| 118 | ar="${cross_prefix}${ar}" |
| 119 | cc_default="${cross_prefix}${cc_default}" |
| 120 | ranlib="${cross_prefix}${ranlib}" |
| 121 | strip="${cross_prefix}${strip}" |
| 122 | |
| 123 | if ! test -z $cc; then |
| 124 | cc_default="${cc}" |
| 125 | fi |
| 126 | cc="${cc_default}" |
| 127 | |
| 128 | disabled static && disabled shared && { |
| 129 | echo "At least one library type must be set."; |
| 130 | exit 1; |
| 131 | } |
| 132 | |
| 133 | if enabled msvc; then |
| 134 | lib /? > /dev/null 2>&1 /dev/null || { |
| 135 | echo "MSVC's lib command not found." |
| 136 | echo "Make sure MSVC is installed and its bin folder is in your \$PATH." |
| 137 | exit 1 |
| 138 | } |
| 139 | fi |
| 140 | |
| 141 | if ! enabled stripping; then |
| 142 | strip="echo ignoring strip" |
| 143 | fi |
| 144 | |
| 145 | enabled msvc && libcmd="lib" || libcmd="echo ignoring lib" |
| 146 | |
| 147 | echo "# Automatically generated by configure" > config.mak |
| 148 | echo "PREFIX=$PREFIX" >> config.mak |
| 149 | echo "bindir=$bindir" >> config.mak |
| 150 | echo "libdir=$libdir" >> config.mak |
| 151 | echo "incdir=$incdir" >> config.mak |
| 152 | echo "AR=$ar" >> config.mak |
| 153 | echo "CC=$cc" >> config.mak |
| 154 | echo "RANLIB=$ranlib" >> config.mak |
| 155 | echo "STRIP=$strip" >> config.mak |
| 156 | echo "BUILD_STATIC=$static" >> config.mak |
| 157 | echo "BUILD_SHARED=$shared" >> config.mak |
| 158 | echo "BUILD_MSVC=$msvc" >> config.mak |
| 159 | echo "LIBCMD=$libcmd" >> config.mak |
| 160 | |
| 161 | echo "prefix: $PREFIX" |
| 162 | echo "bindir: $bindir" |
| 163 | echo "libdir: $libdir" |
| 164 | echo "incdir: $incdir" |
| 165 | echo "ar: $ar" |
| 166 | echo "cc: $cc" |
| 167 | echo "ranlib: $ranlib" |
| 168 | echo "strip: $strip" |
| 169 | echo "static: $static" |
| 170 | echo "shared: $shared" |