OpenCores
URL https://opencores.org/ocsvn/vtach/vtach/trunk

Subversion Repositories vtach

[/] [vtach/] [trunk/] [asm/] [soloinc.awk] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
#!/usr/bin/gawk
2
#/**********************************************************************
3
#axasm Copyright 2006, 2007, 2008, 2009
4
#by Al Williams (alw@al-williams.com).
5
#
6
#
7
#This file is part of axasm.
8
#
9
#axasm is free software: you can redistribute it and/or modify it
10
#under the terms of the GNU General Public Licenses as published
11
#by the Free Software Foundation, either version 3 of the License, or
12
#(at your option) any later version.
13
#
14
#axasm is distributed in the hope that it will be useful, but
15
#WITHOUT ANY WARRANTY: without even the implied warranty of
16
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
#GNU General Public License for more details.
18
#
19
#You should have received a copy of the GNU General Public License
20
#along with axasm (see LICENSE.TXT).
21
#If not, see http://www.gnu.org/licenses/.
22
#
23
#If a non-GPL license is desired, contact the author.
24
#
25
#This is the assembler include file expander
26
#
27
#***********************************************************************/
28
# find the path
29
function pathto(file,    i, t, junk)
30
{
31
    if (index(file, "/") != 0)
32
        return file
33
 
34
    for (i = 1; i <= ndirs; i++) {
35
        t = (pathlist[i] "/" file)
36
        if ((getline junk < t) > 0) {
37
            # found it
38
            close(t)
39
            return t
40
        }
41
    }
42
    return ""
43
}
44
 
45
BEGIN {
46
    path = ENVIRON["AWKPATH"]
47
    ndirs = split(path, pathlist, ":")
48
    for (i = 1; i <= ndirs; i++) {
49
        if (pathlist[i] == "")
50
            pathlist[i] = "."
51
    }
52
 
53
 
54
# keep a stack of files
55
    stackptr = 0
56
    oldsp=-1
57
    input[stackptr] = ARGV[1] # ARGV[1] is first file
58
    linect[stackptr]=1;
59
    for (; stackptr >= 0; stackptr--) {
60
        if (oldsp!=stackptr) {
61
            print "#line " linect[stackptr] " \"" input[stackptr] "\"";
62
            oldsp=stackptr;
63
        }
64
# copy file while handling includes
65
        while ((getline < input[stackptr]) > 0) {
66
            if (tolower($1) != "##include") {
67
                print
68
                continue
69
            }
70
            fpath = pathto($2)
71
            if (fpath == "") {
72
                printf("include:%s:%d: cannot find %s\n", \
73
                    input[stackptr], FNR, $2) > "/dev/stderr"
74
                continue
75
            }
76
 
77
                processed[fpath] = input[stackptr]
78
                input[++stackptr] = fpath
79
                linect[stackptr]=1;
80
        }
81
        close(input[stackptr])
82
    }
83
}
84
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.