this repo has no description
at fixPythonPipStalling 351 lines 8.7 kB view raw
1#!/bin/sh 2# 3# Copyright (c) 2009-2011 Mark Heily <mark@heily.com> 4# 5# Permission to use, copy, modify, and distribute this software for any 6# purpose with or without fee is hereby granted, provided that the above 7# copyright notice and this permission notice appear in all copies. 8# 9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16# 17 18makeconf_version="$Revision: 10 $" 19 20c_exports="program version target api cflags" 21 22make_exports="program version target api distfile basedir \ 23 prefix bindir sbindir libdir includedir mandir \ 24 cflags ldflags ldadd libdepends \ 25 sources objs deps mans headers extra_dist subdirs \ 26 abi_major abi_minor abi_version \ 27 cc cpp ld ln ar install diff" 28 29required_headers= 30optional_headers= 31 32pre_configure_hook() { 33 return 34} 35 36post_configure_hook() { 37 return 38} 39 40export_to_make() { 41 for id in $* 42 do 43 uc_id=`echo $id | $tr '[:lower:]' '[:upper:]'`; 44 eval "echo \"$uc_id=\"\$$id\"\" >> config.mk" 45 done 46} 47 48export_to_c() { 49 for id in $* 50 do 51 uc_id=`echo $id | $tr '[:lower:]' '[:upper:]'`; 52 eval "echo \"#define $uc_id \\\"\$$id\\\"\" >> config.h" 53 done 54} 55 56finalize() { 57 uc_id=`echo \"$1\" | $tr '[:lower:]' '[:upper:]'`; 58 eval "if [ \"\$$1\" = \"\" ] ; then $1=\"$2\" ; fi" 59} 60 61process_argv() { 62 for arg in $* 63 do 64 if [ "$arg" = "--makeconf-version" ] ; then 65 echo $makeconf_version | sed 's/[^0-9.]//g' 66 exit 0 67 fi 68 id=`echo "$arg" | sed 's/=.*//; s/^--//;'` 69 val=`echo "$arg" | sed 's/^.*=//'` 70 if [ "$val" = "" ] ; then val=1 ; fi 71 eval "$id=\"$val\"" 72 done 73} 74 75process_env() { 76 test -n "$CC" && cc="$CC" 77 test -n "$CPP" && cpp="$CPP" 78 test -n "$CPPFLAGS" && cppflags="$CPPFLAGS" 79 test -n "$CFLAGS" && cflags="$CFLAGS" 80 test -n "$LD" && ld="$LD" 81 test -n "$LN" && ld="$LN" 82 test -n "$LDFLAGS" && ldflags="$LDFLAGS" 83 test -n "$AR" && ar="$AR" 84 basedir=`pwd` 85} 86 87check_header() { 88 sym=`echo "have_$1" | sed 's,[./],_,g'` 89 uc_sym=`echo "$sym" | $tr '[:lower:]' '[:upper:]'`; 90 path=$1 91 92 printf "checking for $path.. " 93 if [ -f "/usr/include/$path" ] ; then 94 echo "yes" 95 echo "#define $uc_sym 1" >> config.h 96 eval "$sym=yes" 97 return 0 98 else 99 echo "no" 100 echo "#undef $uc_sym" >> config.h 101 eval "$sym=no" 102 return 1 103 fi 104} 105 106# Determine the path to an executable binary 107check_binary() { 108 id=$1 109 shift 110 111 for path in $* 112 do 113 test -f $path 114 if [ $? = 0 ] ; then 115 eval "$id=\"$path\"" 116 return 117 fi 118 done 119 120 echo "not found" 121 return 122} 123 124check_headers() { 125 for header in $* 126 do 127 check_header "$header" 128 done 129} 130 131check_symbol() { 132 header=$1 133 symbol=$2 134 135 uc_symbol=`echo "HAVE_$symbol" | $tr '[:lower:]' '[:upper:]' | sed 's,[./],_,g'` 136 lc_symbol=`echo "have_$symbol" | $tr '[:upper:]' '[:lower:]' | sed 's,[./],_,g'` 137 138 if [ -f "$header" ] ; then 139 path="$header" 140 elif [ -f "/usr/include/$header" ] ; then 141 path="/usr/include/$header" 142 else 143 echo "*** ERROR: Cannot find <$header>" 144 exit 1 145 fi 146 147 printf "checking $header for $symbol.. " 148 if [ "`grep $symbol $path`" != "" ] ; then 149 eval "$lc_symbol=yes" 150 echo "#define $uc_symbol 1" >> config.h 151 echo "yes" 152 return 0 153 else 154 eval "$lc_symbol=no" 155 echo "no" 156 echo "#undef $uc_symbol" >> config.h 157 return 1 158 fi 159} 160 161check_install() { 162 printf "checking for a BSD-compatible install.. " 163 if [ "`uname -s`" = "SunOS" ] ; then 164 default_install=/usr/ucb/install 165 else 166 default_install=/usr/bin/install 167 fi 168 finalize install "$default_install" 169 echo "$install" 170} 171 172check_target() { 173 printf "checking operating system type.. " 174 default_target=`uname -s | $tr '[:upper:]' '[:lower:]'` 175 default_api="posix" 176 case "$default_target" in 177 sunos) 178 default_target="solaris" 179 ;; 180 "gnu/kfreebsd") 181 default_target="freebsd" 182 ;; 183 mingw*) 184 default_target="windows" 185 default_api="windows" 186 ;; 187 esac 188 finalize target "$default_target" 189 finalize api "$default_api" 190 echo "$api" 191} 192 193check_compiler() { 194 printf "checking for a C compiler.. " 195 check_binary default_cc "$cc" "`which $cc 2>/dev/null`" "/usr/bin/cc" "/usr/bin/gcc" "/usr/sfw/bin/gcc" "`which gcc 2>/dev/null`" 196 finalize cc "$default_cc" 197# test -x "$cc" || err "Unable to locate a C compiler" 198 echo "$cc" 199} 200 201check_linker() { 202 printf "checking for a suitable linker.. " 203 204 # Workaround for "hidden symbol <foo> is referenced by DSO" linker error 205 # seen when compiling libdispatch. 206 # Appears to be a problem with GCC 4.0 and binutils 207 # 208 default_ld="$cc" 209 ldflags="-o $program.so.$abi_major.$abi_minor $ldflags" 210 211 # FIXME: port to solaris 212 if [ "$target" = "linux" ] ; then 213 ldflags="$ldflags -Wl,-export-dynamic -Wl,-soname,$program.so.$abi_major" 214 fi 215 216 if [ "$target" = "solaris" ] ; then 217 ldflags="$ldflags" 218 fi 219 220 finalize ld "$default_ld" 221 echo "$ld" 222} 223 224check_archiver() { 225 printf "checking for a suitable archiver.. " 226 if [ "`uname -s`" = "SunOS" -a "`uname -v | grep Nexenta`" = "" ] ; then 227 default_ar="/usr/sfw/bin/gar" 228 else 229 default_ar="/usr/bin/ar" 230 fi 231 finalize ar "$default_ar" 232 echo "$ar" 233} 234 235err() { 236 echo "*** ERROR *** $*" 237 rm -f config.mk $program.pc config.h 238 exit 1 239} 240 241check_diff() { 242 # TODO: Support non-GNU diff syntax 243 # TODO: Search for the command 244 printf "checking for a suitable diff(1) command.. " 245 finalize diff "diff -ruN -dEbwBp -x .svn -x .o -x config.h -x config.mk" 246 echo "found" 247} 248 249subst_vars() { 250 outfile=$1 251 252 if [ ! -f "${outfile}.in" ] ; then 253 return 254 fi 255 256 echo "Creating $outfile" 257 rm -f $outfile 258 sed -e " 259 s,@@CWD@@,`pwd`,g; 260 s,@@PROGRAM@@,$program,g; 261 s,@@VERSION@@,$version,g; 262 s,@@PREFIX@@,$prefix,g; 263 s,@@LIBDIR@@,$libdir,g; 264 s,@@INCLUDEDIR@@,$includedir,g; 265 s,@@MANDIR@@,$mandir,g; 266 s,@@LIBDEPENDS@@,$libdepends,g; 267 s,@@PKG_SUMMARY@@,$pkg_summary,g; 268 s,@@RPM_DATE@@,`date +'%a %b %d %Y'`,g; 269 s,@@PKG_DESCRIPTION@@,$pkg_description,g; 270 s,@@LICENSE@@,$license,g; 271 s,@@AUTHOR@@,$author,g; 272 " < ${outfile}.in > $outfile 273 chmod 400 $outfile 274} 275 276####################################################################### 277# 278# MAIN() 279# 280####################################################################### 281 282# Workaround for Solaris "Bad string" issue when LOCALE is undefined 283tr="/usr/bin/tr" 284test -f /usr/xpg4/bin/tr && tr="/usr/xpg4/bin/tr" 285 286. ./config.inc 287 288# Initialize the output files 289# 290for output_file in config.mk 291do 292 rm -f $output_file 293 echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" > $output_file 294done 295if [ "$sources" != "" ] ; then 296 rm -f config.h 297 echo "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */" > config.h 298fi 299 300process_argv "$*" 301process_env 302 303check_target 304check_compiler 305check_linker 306check_archiver 307check_install 308check_diff 309 310finalize program "$program" 311finalize version "$version" 312finalize abi_major "$abi_major" 313finalize abi_minor "$abi_minor" 314finalize abi_version "$abi_major.$abi_minor" 315finalize prefix "/usr/local" 316finalize bindir "\\\$(PREFIX)/bin" 317finalize sbindir "\\\$(PREFIX)/sbin" 318finalize libdir "\\\$(PREFIX)/lib" 319finalize includedir "\\\$(PREFIX)/include" 320finalize mandir "\\\$(PREFIX)/share/man" 321finalize cflags "$cflags" 322finalize libdepends "$libdepends" 323finalize ldadd "" 324finalize ldflags "" 325finalize deps "" 326finalize ln "`which ln`" 327finalize distfile "$program-$version.tar.gz" 328 329pre_configure_hook 330 331for header in $required_headers 332do 333 check_header "$header" || err "$header is required, but cannot be found." 334done 335check_headers $optional_headers 336 337post_configure_hook 338 339objs="`echo \"$sources\" | sed 's/\.c/\.o/g'`" 340 341subst_vars "$program.pc" 342subst_vars "$program.la" 343subst_vars "rpm.spec" 344 345if [ "$sources" != "" ] ; then 346 echo "Creating config.h" 347 export_to_c $c_exports 348fi 349 350echo "Creating config.mk" 351export_to_make "$make_exports"