sgl

annotate configure @ 37:b3374e30361c

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