File: compile.sh

package info (click to toggle)
splix 2.0.0-2.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,912 kB
  • ctags: 653
  • sloc: cpp: 4,514; makefile: 332; sh: 86; ansic: 42
file content (70 lines) | stat: -rwxr-xr-x 1,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
#
#       compile.sh                      (C) 2007, Aurélien Croc (AP²C)
#
#  Generate the DRV file to compile it by ppdc.
#  This script adds a new command "#import "file"" in the DRV file which imports
#  the content of the file where the command is located. To finish, it calls 
#  ppdc to compile the file and generate the PPD drivers.
#
# $Id: compile.sh 105 2007-11-16 02:20:18Z ap2c $
# 

#
# Function parseFile
#
parseFile() {
    while read LINE; do
        if [ -n "`echo "$LINE" | grep '^[ \t]*#import[ \t]*"[a-zA-Z0-9\.\-]*"'`" ]; then
            FILE=`echo "$LINE" | sed -re 's/[ \t]*#import[ \t]"([a-zA-Z0-9\.\-]*)"/\1/'`
            parseFile $FILE $2
        else
            echo "$LINE" >> $2
        fi;
    done < $1
}


#
# Main script
#
if [ $2 == "debug" ]; then
    TMPFILE="output.drv"
    DRIVER=$1
    shift 1

    echo "" > $TMPFILE
    parseFile $DRIVER $TMPFILE


elif [ $2 == "lang" ]; then
    if [ -z $TMP ]; then
        TMP="/tmp"
    fi;
    TMPFILE=`mktemp $TMP/driver.drv.XXXXXXXX` || exit 1
    DRIVER=$1

    echo "" > $TMPFILE
    parseFile $DRIVER $TMPFILE

    ppdpo -o $3 $TMPFILE
    unlink $TMPFILE


else
    if [ -z $TMP ]; then
        TMP="/tmp"
    fi;
    TMPFILE=`mktemp $TMP/driver.drv.XXXXXXXX` || exit 1
    DRIVER=$1
    shift 1

    echo "" > $TMPFILE
    parseFile $DRIVER $TMPFILE

    ppdc $@ $TMPFILE
    unlink $TMPFILE
fi;


# vim: set expandtab tabstop=4 shiftwidth=4 smarttab tw=80 enc=utf8: