build-scripts/makedep.sh
author Holmes Futrell <hfutrell@umail.ucsb.edu>
Tue, 29 Jul 2008 17:23:50 +0000
branchgsoc2008_iphone
changeset 2407 6c31bbd56c49
parent 2247 93994f65c74c
permissions -rwxr-xr-x
keyinfotable.h contains information which SDL_uikitkeyboard uses to convert between unichar characters that it reads from the text field (which acts as the keyboard's target) to SDL_scancodes and key modifiers which are sent to SDL's keyboard system.
slouken@1361
     1
#!/bin/sh
slouken@1361
     2
#
slouken@1361
     3
# Generate dependencies from a list of source files
slouken@1361
     4
slouken@1361
     5
# Check to make sure our environment variables are set
slouken@1634
     6
if test x"$INCLUDE" = x -o x"$SOURCES" = x -o x"$output" = x; then
slouken@1634
     7
    echo "SOURCES, INCLUDE, and output needs to be set"
slouken@1361
     8
    exit 1
slouken@1361
     9
fi
slouken@1361
    10
cache_prefix=".#$$"
slouken@1361
    11
slouken@1361
    12
generate_var()
slouken@1361
    13
{
slouken@1361
    14
    echo $1 | sed -e 's|^.*/||' -e 's|\.|_|g'
slouken@1361
    15
}
slouken@1361
    16
slouken@1361
    17
search_deps()
slouken@1361
    18
{
slouken@1361
    19
    base=`echo $1 | sed 's|/[^/]*$||'`
slouken@1361
    20
    grep '#include "' <$1 | sed -e 's|.*"\([^"]*\)".*|\1|' | \
slouken@1361
    21
    while read file
slouken@1361
    22
    do cache=${cache_prefix}_`generate_var $file`
slouken@1361
    23
       if test -f $cache; then
slouken@1391
    24
          : # We already ahve this cached
slouken@1391
    25
       else
slouken@1391
    26
           : >$cache
slouken@1391
    27
           for path in $base `echo $INCLUDE | sed 's|-I||g'`
slouken@1391
    28
           do dep="$path/$file"
slouken@1391
    29
              if test -f "$dep"; then
slouken@1391
    30
                 echo "	$dep \\" >>$cache
slouken@1391
    31
                 search_deps $dep >>$cache
slouken@1391
    32
                 break
slouken@1391
    33
              fi
slouken@1391
    34
           done
slouken@1361
    35
       fi
slouken@1391
    36
       cat $cache
slouken@1361
    37
    done
slouken@1361
    38
}
slouken@1361
    39
slouken@1361
    40
:>${output}.new
slouken@1361
    41
for src in $SOURCES
slouken@1361
    42
do  echo "Generating dependencies for $src"
slouken@1361
    43
    ext=`echo $src | sed 's|.*\.\(.*\)|\1|'`
slouken@2204
    44
    if test x"$ext" = x"rc"; then
slouken@2204
    45
        obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.o|g"`
slouken@2204
    46
    else
slouken@2204
    47
        obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"`
slouken@2204
    48
    fi
slouken@1634
    49
    echo "\$(objects)/$obj: $src \\" >>${output}.new
slouken@1388
    50
    search_deps $src | sort | uniq >>${output}.new
slouken@1361
    51
    case $ext in
slouken@1416
    52
        c) cat >>${output}.new <<__EOF__
slouken@1416
    53
slouken@1521
    54
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
slouken@1416
    55
slouken@1416
    56
__EOF__
slouken@1416
    57
        ;;
slouken@1416
    58
        cc) cat >>${output}.new <<__EOF__
slouken@1416
    59
slouken@1521
    60
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
slouken@1416
    61
slouken@1416
    62
__EOF__
slouken@1416
    63
        ;;
slouken@1416
    64
        m) cat >>${output}.new <<__EOF__
slouken@1416
    65
slouken@1521
    66
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
slouken@1416
    67
slouken@1416
    68
__EOF__
slouken@1416
    69
        ;;
slouken@1459
    70
        S) cat >>${output}.new <<__EOF__
slouken@1459
    71
slouken@1521
    72
	\$(LIBTOOL)  --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src  -o \$@
slouken@1459
    73
slouken@1459
    74
__EOF__
slouken@1459
    75
        ;;
slouken@2204
    76
        rc) cat >>${output}.new <<__EOF__
slouken@2204
    77
slouken@2204
    78
	\$(WINDRES) $src \$@
slouken@2204
    79
slouken@2204
    80
__EOF__
slouken@2204
    81
        ;;
slouken@1361
    82
        *)   echo "Unknown file extension: $ext";;
slouken@1361
    83
    esac
slouken@1361
    84
    echo "" >>${output}.new
slouken@1361
    85
done
slouken@1361
    86
mv ${output}.new ${output}
slouken@1493
    87
rm -f ${cache_prefix}*