File: compile.sh

package info (click to toggle)
splix 2.0.0%2Bsvn315-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 4,672 kB
  • sloc: cpp: 4,907; makefile: 434; ansic: 42; sh: 38; python: 8
file content (70 lines) | stat: -rwxr-xr-x 1,486 bytes parent folder | download | duplicates (2)
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 306 2012-02-29 14:59:36Z tillkamppeter $
# 

#
# Function parseFile
#
parseFile() {
    while IFS= 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" = "drv" ]; then
    DRIVER=$1
    OUTFILE=${DRIVER%.in}
    shift 1

    echo "" > $OUTFILE
    parseFile $DRIVER $OUTFILE


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: