Home | History | Annotate | Line # | Download | only in dspgen
do_subst.awk revision 1.1
      1  1.1  uch # $NetBSD: do_subst.awk,v 1.1 2001/02/09 18:34:10 uch Exp $
      2  1.1  uch #
      3  1.1  uch # Copyright (c) 1999, 2000 Christopher G. Demetriou.  All rights reserved.
      4  1.1  uch #
      5  1.1  uch # Redistribution and use in source and binary forms, with or without
      6  1.1  uch # modification, are permitted provided that the following conditions
      7  1.1  uch # are met:
      8  1.1  uch # 1. Redistributions of source code must retain the above copyright
      9  1.1  uch #    notice, this list of conditions and the following disclaimer.
     10  1.1  uch # 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  uch #    notice, this list of conditions and the following disclaimer in the
     12  1.1  uch #    documentation and/or other materials provided with the distribution.
     13  1.1  uch # 3. All advertising materials mentioning features or use of this software
     14  1.1  uch #    must display the following acknowledgement:
     15  1.1  uch #      This product includes software developed by Christopher G. Demetriou
     16  1.1  uch #      for the NetBSD Project.
     17  1.1  uch # 4. The name of the author may not be used to endorse or promote products
     18  1.1  uch #    derived from this software without specific prior written permission
     19  1.1  uch #
     20  1.1  uch # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1  uch # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1  uch # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1  uch # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1  uch # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.1  uch # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.1  uch # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.1  uch # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.1  uch # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.1  uch # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.1  uch 
     31  1.1  uch function setup_md_files (arch, srclist) {
     32  1.1  uch 	srclist=""
     33  1.1  uch 	asm_tmpl="dspgen/asm_build." arch
     34  1.1  uch 	prop_tmpl="dspgen/property." arch
     35  1.1  uch 	env="SRCFILE_LIST_" arch
     36  1.1  uch 
     37  1.1  uch 	sz = split(ENVIRON[env], a, "[ \t\n]+");
     38  1.1  uch 	for (i = 1; i <= sz; i++) {
     39  1.1  uch 		if (a[i] == "") {
     40  1.1  uch 			continue
     41  1.1  uch 		}
     42  1.1  uch 		if (srclist != "") {
     43  1.1  uch 			srclist=srclist "\n"
     44  1.1  uch 		}
     45  1.1  uch 		srclist=srclist "# Begin Source File\n"
     46  1.1  uch 		srclist=srclist "\n"
     47  1.1  uch 		srclist=srclist "SOURCE=.\\" a[i] "\n"
     48  1.1  uch 		base = index (a[i], ".asm")
     49  1.1  uch 		if (base != 0) {
     50  1.1  uch 		  basename = substr (a[i], 0, base - 1)
     51  1.1  uch 		  while (getline < asm_tmpl > 0) {
     52  1.1  uch 		    gsub ("%%% ASM_BASENAME %%%", basename)
     53  1.1  uch 		    srclist=srclist $0 "\n"
     54  1.1  uch 		  }
     55  1.1  uch 		  close (asm_tmpl)
     56  1.1  uch 		} else {
     57  1.1  uch 		  while (getline < prop_tmpl > 0)
     58  1.1  uch 		    srclist=srclist $0 "\n"
     59  1.1  uch 		    close (prop_tmpl)
     60  1.1  uch 		}
     61  1.1  uch 		srclist=srclist "# End Source File"
     62  1.1  uch 	}
     63  1.1  uch 	return srclist
     64  1.1  uch }
     65  1.1  uch 
     66  1.1  uch BEGIN {
     67  1.1  uch 	NAME=ENVIRON["NAME"]
     68  1.1  uch 
     69  1.1  uch 	SRCFILES=""
     70  1.1  uch 	sz = split(ENVIRON["SRCFILE_LIST"], a, "[ \t\n]+");
     71  1.1  uch 	for (i = 1; i <= sz; i++) {
     72  1.1  uch 		if (a[i] == "") {
     73  1.1  uch 			continue
     74  1.1  uch 		}
     75  1.1  uch 		if (SRCFILES != "") {
     76  1.1  uch 			SRCFILES=SRCFILES "\n"
     77  1.1  uch 		}
     78  1.1  uch 		SRCFILES=SRCFILES "# Begin Source File\n"
     79  1.1  uch 		SRCFILES=SRCFILES "\n"
     80  1.1  uch 		SRCFILES=SRCFILES "SOURCE=.\\" a[i] "\n"
     81  1.1  uch 		SRCFILES=SRCFILES "# End Source File"
     82  1.1  uch 	}
     83  1.1  uch 
     84  1.1  uch 	SRCFILES_ARM = setup_md_files("ARM", SRCFILES_ARM)
     85  1.1  uch 	SRCFILES_SH3 = setup_md_files("SH3", SRCFILES_SH3)
     86  1.1  uch 	SRCFILES_MIPS = setup_md_files("MIPS", SRCFILES_MIPS)
     87  1.1  uch 
     88  1.1  uch 	CPPDEFS=""
     89  1.1  uch 	sz = split(ENVIRON["STD_CPPDEF_LIST"], a, "[ \t\n]+");
     90  1.1  uch 	for (i = 1; i <= sz; i++) {
     91  1.1  uch 		if (a[i] == "") {
     92  1.1  uch 			continue
     93  1.1  uch 		}
     94  1.1  uch 		if (CPPDEFS != "") {
     95  1.1  uch 			CPPDEFS=CPPDEFS " "
     96  1.1  uch 		}
     97  1.1  uch 		CPPDEFS=CPPDEFS "/D \"" a[i] "\""
     98  1.1  uch 	}
     99  1.1  uch 	sz = split(ENVIRON["CPPDEF_LIST"], a, "[ \t\n]+");
    100  1.1  uch 	for (i = 1; i <= sz; i++) {
    101  1.1  uch 		if (a[i] == "") {
    102  1.1  uch 			continue
    103  1.1  uch 		}
    104  1.1  uch 		if (CPPDEFS != "") {
    105  1.1  uch 			CPPDEFS=CPPDEFS " "
    106  1.1  uch 		}
    107  1.1  uch 		CPPDEFS=CPPDEFS "/D \"" a[i] "\""
    108  1.1  uch 	}
    109  1.1  uch 
    110  1.1  uch 	INCDIRS=""
    111  1.1  uch 	sz = split(ENVIRON["STD_INCDIR_LIST"], a, "[ \t\n]+");
    112  1.1  uch 	for (i = 1; i <= sz; i++) {
    113  1.1  uch 		if (a[i] == "") {
    114  1.1  uch 			continue
    115  1.1  uch 		}
    116  1.1  uch 		if (INCDIRS != "") {
    117  1.1  uch 			INCDIRS=INCDIRS " "
    118  1.1  uch 		}
    119  1.1  uch 		INCDIRS=INCDIRS "/I \"" a[i] "\""
    120  1.1  uch 	}
    121  1.1  uch 	sz = split(ENVIRON["INCDIR_LIST"], a, "[ \t\n]+");
    122  1.1  uch 	for (i = 1; i <= sz; i++) {
    123  1.1  uch 		if (a[i] == "") {
    124  1.1  uch 			continue
    125  1.1  uch 		}
    126  1.1  uch 		if (INCDIRS != "") {
    127  1.1  uch 			INCDIRS=INCDIRS " "
    128  1.1  uch 		}
    129  1.1  uch 		INCDIRS=INCDIRS "/I \"" a[i] "\""
    130  1.1  uch 	}
    131  1.1  uch 	sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
    132  1.1  uch 	for (i = 1; i <= sz; i++) {
    133  1.1  uch 		if (a[i] == "") {
    134  1.1  uch 			continue
    135  1.1  uch 		}
    136  1.1  uch 		if (INCDIRS != "") {
    137  1.1  uch 			INCDIRS=INCDIRS " "
    138  1.1  uch 		}
    139  1.1  uch 		INCDIRS=INCDIRS "/I \"..\\" a[i] "\""
    140  1.1  uch         }
    141  1.1  uch 
    142  1.1  uch 	LIBRARIES=""
    143  1.1  uch 	sz = split(ENVIRON["STD_LIBRARY_LIST"], a, "[ \t\n]+");
    144  1.1  uch 	for (i = 1; i <= sz; i++) {
    145  1.1  uch 		if (a[i] == "") {
    146  1.1  uch 			continue
    147  1.1  uch 		}
    148  1.1  uch 		if (LIBRARIES != "") {
    149  1.1  uch 			LIBRARIES=LIBRARIES " "
    150  1.1  uch 		}
    151  1.1  uch 		LIBRARIES=LIBRARIES a[i] ".lib"
    152  1.1  uch 	}
    153  1.1  uch 	sz = split(ENVIRON["LIBRARY_LIST"], a, "[ \t\n]+");
    154  1.1  uch 	for (i = 1; i <= sz; i++) {
    155  1.1  uch 		if (a[i] == "") {
    156  1.1  uch 			continue
    157  1.1  uch 		}
    158  1.1  uch 		if (LIBRARIES != "") {
    159  1.1  uch 			LIBRARIES=LIBRARIES " "
    160  1.1  uch 		}
    161  1.1  uch 		LIBRARIES=LIBRARIES a[i] ".lib"
    162  1.1  uch         }
    163  1.1  uch 	sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
    164  1.1  uch 	for (i = 1; i <= sz; i++) {
    165  1.1  uch 		if (a[i] == "") {
    166  1.1  uch 			continue
    167  1.1  uch 		}
    168  1.1  uch 		if (LIBRARIES != "") {
    169  1.1  uch 			LIBRARIES=LIBRARIES " "
    170  1.1  uch 		}
    171  1.1  uch 		LIBRARIES=LIBRARIES a[i] ".lib"
    172  1.1  uch 	}
    173  1.1  uch 
    174  1.1  uch 	sz = split(ENVIRON["LIBDEP_LIST"], a, "[ \t\n]+");
    175  1.1  uch 	DEBUG_LIBPATH=""
    176  1.1  uch 	RELEASE_LIBPATH=""
    177  1.1  uch 	for (i = 1; i <= sz; i++) {
    178  1.1  uch 		if (a[i] == "") {
    179  1.1  uch 			continue
    180  1.1  uch 		}
    181  1.1  uch 		if (i > 1) {
    182  1.1  uch 			DEBUG_LIBPATH=DEBUG_LIBPATH " "
    183  1.1  uch 			RELEASE_LIBPATH=RELEASE_LIBPATH " "
    184  1.1  uch 		}
    185  1.1  uch 		DEBUG_LIBPATH=DEBUG_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSDbg\""
    186  1.1  uch 		RELEASE_LIBPATH=RELEASE_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSRel\""
    187  1.1  uch 	}
    188  1.1  uch }
    189  1.1  uch {
    190  1.1  uch 	gsub("%%% SRCFILES %%%", SRCFILES)
    191  1.1  uch 	gsub("%%% SRCFILES_ARM %%%", SRCFILES_ARM)
    192  1.1  uch 	gsub("%%% SRCFILES_SH3 %%%", SRCFILES_SH3)
    193  1.1  uch 	gsub("%%% SRCFILES_SH4 %%%", SRCFILES_SH4)
    194  1.1  uch 	gsub("%%% SRCFILES_MIPS %%%", SRCFILES_MIPS)
    195  1.1  uch 	gsub("%%% CPPDEFS %%%", CPPDEFS)
    196  1.1  uch 	gsub("%%% INCDIRS %%%", INCDIRS)
    197  1.1  uch 	gsub("%%% LIBRARIES %%%", LIBRARIES)
    198  1.1  uch 	gsub("%%% DEBUG_LIBPATH %%%", DEBUG_LIBPATH)
    199  1.1  uch 	gsub("%%% RELEASE_LIBPATH %%%", RELEASE_LIBPATH)
    200  1.1  uch 	gsub("%%% NAME %%%", NAME)
    201  1.1  uch 	print $0
    202  1.1  uch }
    203