sgl
changeset 9:5efd62ff354a
- configure now also heeds mac-framework: options in modules
- cleaned up the generated module.c a bit
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Sat, 14 May 2011 08:58:49 +0300 |
parents | 0b07dd867b2f |
children | 1532e43bf858 |
files | configure src/wsys_x11.c |
diffstat | 2 files changed, 25 insertions(+), 6 deletions(-) [+] |
line diff
1.1 --- a/configure Sat May 14 08:33:41 2011 +0300 1.2 +++ b/configure Sat May 14 08:58:49 2011 +0300 1.3 @@ -3,9 +3,19 @@ 1.4 cfgfile=src/config.h 1.5 modfile=src/modules.c 1.6 1.7 +extract() 1.8 +{ 1.9 + grep "$2:" $1 | sed "s/^.*$2: \?\(.*\) \?\*\//\1/" 1.10 +} 1.11 + 1.12 get_depline() 1.13 { 1.14 - grep 'link-with:' $1 | sed 's/^.*link-with: \?\(.*\) \?\*\//\1/' 1.15 + extract $1 link-with 1.16 +} 1.17 + 1.18 +get_framework() 1.19 +{ 1.20 + extract $1 mac-framework 1.21 } 1.22 1.23 get_usedef() 1.24 @@ -30,6 +40,9 @@ 1.25 # write beginning of modules.c 1.26 echo "/* this file is generated by $0, do not edit */" >$modfile 1.27 echo >>$modfile 1.28 +echo '#define REGISTER_MODULE(name) \' >>$modfile 1.29 +echo ' do { void sgl_register_##name(); sgl_register_##name(); } while(0)' >>$modfile 1.30 +echo >>$modfile 1.31 echo 'void sgl_modules_init(void)' >>$modfile 1.32 echo '{' >>$modfile 1.33 1.34 @@ -45,7 +58,15 @@ 1.35 def=`get_usedef $m` 1.36 1.37 # extract link-with line 1.38 - dep=`get_depline $m` 1.39 + if [ `uname -s` = Darwin ]; then 1.40 + dep=`get_framework $m` 1.41 + if [ -z "$dep" ]; then 1.42 + dep=`get_depline $m` 1.43 + fi 1.44 + else 1.45 + dep=`get_depline $m` 1.46 + fi 1.47 + 1.48 name=`echo $m | sort | sed 's/src\/wsys_//' | sed 's/\.c//'` 1.49 echo -n "-> trying module $name (needs: $dep) ... " 1.50 1.51 @@ -59,9 +80,7 @@ 1.52 echo >>$cfgfile 1.53 1.54 # make the registration call in modules.c 1.55 - echo " void sgl_register_$name();" >>$modfile 1.56 - echo " sgl_register_$name();" >>$modfile 1.57 - echo >>$modfile 1.58 + echo " REGISTER_MODULE($name);" >>$modfile 1.59 else 1.60 echo failed 1.61 fi