sgl
annotate configure @ 30:6242b03e7191
merged with win32 branch
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 28 Jun 2011 13:52:02 +0300 |
parents | 12ce0cef7ebf |
children | 3d6ee9fb9ac1 |
rev | line source |
---|---|
nuclear@2 | 1 #!/bin/sh |
nuclear@2 | 2 |
nuclear@28 | 3 prefix=/usr/local |
nuclear@28 | 4 ignore= |
nuclear@7 | 5 cfgfile=src/config.h |
nuclear@7 | 6 modfile=src/modules.c |
nuclear@19 | 7 logfile=config.log |
nuclear@19 | 8 echobin=`which echo` |
nuclear@19 | 9 |
nuclear@19 | 10 rm -f $logfile |
nuclear@19 | 11 message() |
nuclear@19 | 12 { |
nuclear@19 | 13 $echobin $* | tee -a $logfile |
nuclear@19 | 14 } |
nuclear@7 | 15 |
nuclear@9 | 16 extract() |
nuclear@9 | 17 { |
nuclear@12 | 18 grep "$2:" $1 | sed "s/^.*$2: *\(.*\)\*\//\1/" |
nuclear@9 | 19 } |
nuclear@9 | 20 |
nuclear@7 | 21 get_depline() |
nuclear@2 | 22 { |
nuclear@9 | 23 extract $1 link-with |
nuclear@9 | 24 } |
nuclear@9 | 25 |
nuclear@9 | 26 get_framework() |
nuclear@9 | 27 { |
nuclear@9 | 28 extract $1 mac-framework |
nuclear@2 | 29 } |
nuclear@2 | 30 |
nuclear@7 | 31 get_usedef() |
nuclear@7 | 32 { |
nuclear@7 | 33 grep '#ifdef *USE_WSYS_MODULE' $1 | sed 's/^.*\(USE_WSYS_MODULE_.*\)/\1/' |
nuclear@7 | 34 } |
nuclear@2 | 35 |
nuclear@7 | 36 try_link() |
nuclear@7 | 37 { |
nuclear@7 | 38 srcfile=/tmp/sgl-trylink.c |
nuclear@7 | 39 aout=/tmp/sgl-a.out |
nuclear@7 | 40 |
nuclear@19 | 41 echo >>$logfile |
nuclear@19 | 42 echo "trying command line: cc -o $aout $srcfile $*" >>$logfile |
nuclear@19 | 43 |
nuclear@7 | 44 echo 'int main(void) { return 0; }' >$srcfile |
nuclear@19 | 45 eval cc -o $aout $srcfile $1 >>$logfile 2>>$logfile |
nuclear@13 | 46 res=$? |
nuclear@13 | 47 |
nuclear@13 | 48 rm -f $srcfile $aout |
nuclear@13 | 49 return $res |
nuclear@7 | 50 } |
nuclear@7 | 51 |
nuclear@28 | 52 message "configuring SimplyGL ..." |
nuclear@28 | 53 |
nuclear@28 | 54 for arg; do |
nuclear@28 | 55 case "$arg" in |
nuclear@28 | 56 --prefix=*) |
nuclear@28 | 57 value=`echo $arg | awk -F= '{print $2}'` |
nuclear@28 | 58 prefix=${value:-$prefix} |
nuclear@28 | 59 ;; |
nuclear@28 | 60 |
nuclear@28 | 61 --without-*) |
nuclear@28 | 62 value=`echo $arg | awk -F- '{print $4}'` |
nuclear@28 | 63 ignore="$ignore $value" |
nuclear@28 | 64 message "without: $value" |
nuclear@28 | 65 ;; |
nuclear@28 | 66 esac |
nuclear@28 | 67 done |
nuclear@28 | 68 |
nuclear@7 | 69 # write beginning of config.h |
nuclear@7 | 70 echo '#ifndef CONFIG_H_' >$cfgfile |
nuclear@7 | 71 echo '#define CONFIG_H_' >>$cfgfile |
nuclear@7 | 72 echo >>$cfgfile |
nuclear@7 | 73 |
nuclear@7 | 74 # write beginning of modules.c |
nuclear@7 | 75 echo "/* this file is generated by $0, do not edit */" >$modfile |
nuclear@7 | 76 echo >>$modfile |
nuclear@9 | 77 echo '#define REGISTER_MODULE(name) \' >>$modfile |
nuclear@9 | 78 echo ' do { void sgl_register_##name(); sgl_register_##name(); } while(0)' >>$modfile |
nuclear@9 | 79 echo >>$modfile |
nuclear@7 | 80 echo 'void sgl_modules_init(void)' >>$modfile |
nuclear@7 | 81 echo '{' >>$modfile |
nuclear@7 | 82 |
nuclear@7 | 83 |
nuclear@7 | 84 # start scanning for modules |
nuclear@19 | 85 message 'Looking for usable window system modules ...' |
nuclear@7 | 86 |
nuclear@7 | 87 # collect all src/wsys_whatever.c files |
nuclear@13 | 88 all_files=`ls src/wsys_*.c src/wsys_*.m 2>/dev/null` |
nuclear@7 | 89 |
nuclear@7 | 90 for m in $all_files; do |
nuclear@7 | 91 # extract USE_WSYS_MODULE_* define |
nuclear@7 | 92 def=`get_usedef $m` |
nuclear@7 | 93 |
nuclear@7 | 94 # extract link-with line |
nuclear@9 | 95 if [ `uname -s` = Darwin ]; then |
nuclear@9 | 96 dep=`get_framework $m` |
nuclear@9 | 97 if [ -z "$dep" ]; then |
nuclear@9 | 98 dep=`get_depline $m` |
nuclear@9 | 99 fi |
nuclear@9 | 100 else |
nuclear@9 | 101 dep=`get_depline $m` |
nuclear@13 | 102 if [ -z "$dep" ]; then |
nuclear@13 | 103 dep=`get_framework $m` |
nuclear@13 | 104 fi |
nuclear@9 | 105 fi |
nuclear@9 | 106 |
nuclear@15 | 107 name=`echo $m | sort | sed 's/src\/wsys_//' | sed 's/\.c//' | sed 's/\.m//'` |
nuclear@19 | 108 message -n "-> trying module $name (needs: $dep) ... " |
nuclear@7 | 109 |
nuclear@28 | 110 if echo $ignore | grep $name >/dev/null; then |
nuclear@28 | 111 message ignored |
nuclear@28 | 112 |
nuclear@28 | 113 elif try_link "$dep"; then |
nuclear@19 | 114 message ok |
nuclear@7 | 115 |
nuclear@7 | 116 libs="$libs $dep" |
nuclear@7 | 117 |
nuclear@7 | 118 # emmit the USE_ define in config.h |
nuclear@7 | 119 echo "#define $def" >>$cfgfile |
nuclear@7 | 120 echo >>$cfgfile |
nuclear@7 | 121 |
nuclear@7 | 122 # make the registration call in modules.c |
nuclear@9 | 123 echo " REGISTER_MODULE($name);" >>$modfile |
nuclear@7 | 124 else |
nuclear@19 | 125 message failed |
nuclear@7 | 126 fi |
nuclear@7 | 127 done |
nuclear@28 | 128 |
nuclear@28 | 129 message "Will link with: $libs" |
nuclear@7 | 130 |
nuclear@7 | 131 # wrap up the modules.c file |
nuclear@7 | 132 echo '}' >>$modfile |
nuclear@7 | 133 |
nuclear@7 | 134 # wrap up the config.h file |
nuclear@7 | 135 echo '#endif /* CONFIG_H_ */' >>$cfgfile |
nuclear@7 | 136 |
nuclear@7 | 137 # generate makefile |
nuclear@19 | 138 message Generating makefile ... |
nuclear@7 | 139 |
nuclear@28 | 140 message "install prefix: $prefix" |
nuclear@28 | 141 echo "PREFIX = $prefix" >Makefile |
nuclear@7 | 142 echo "wsys_libs = $libs" >>Makefile |
nuclear@2 | 143 cat Makefile.in >>Makefile |
nuclear@7 | 144 |
nuclear@19 | 145 message 'Configuration complete. Run make (or gmake) to compile.' |