Home | History | Annotate | Line # | Download | only in dspgen
do_subst.sh revision 1.1
      1 # $NetBSD: do_subst.sh,v 1.1 2000/01/12 02:33:54 cgd Exp $
      2 #
      3 # Copyright (c) 1999, 2000 Christopher G. Demetriou.  All rights reserved.
      4 #
      5 # Redistribution and use in source and binary forms, with or without
      6 # modification, are permitted provided that the following conditions
      7 # are met:
      8 # 1. Redistributions of source code must retain the above copyright
      9 #    notice, this list of conditions and the following disclaimer.
     10 # 2. Redistributions in binary form must reproduce the above copyright
     11 #    notice, this list of conditions and the following disclaimer in the
     12 #    documentation and/or other materials provided with the distribution.
     13 # 3. All advertising materials mentioning features or use of this software
     14 #    must display the following acknowledgement:
     15 #      This product includes software developed by Christopher G. Demetriou
     16 #      for the NetBSD Project.
     17 # 4. The name of the author may not be used to endorse or promote products
     18 #    derived from this software without specific prior written permission
     19 #
     20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30 
     31 if [ "X$1" = "X--show-libdeps" ]; then
     32 	if ! expr "X$TYPE" : 'Xconsole_program.*' > /dev/null 2>&1 &&
     33 	   ! expr "X$TYPE" : 'Xapplication.*' > /dev/null 2>&1; then
     34 		exit
     35 	fi
     36 	( for lib in $LIBDEP_LIST; do
     37 		echo $lib
     38 	done ) | sort
     39 	exit
     40 fi
     41 
     42 AWK=awk
     43 if [ `uname` = SunOS ]; then
     44 	AWK=nawk
     45 fi
     46 
     47 STD_CPPDEF_LIST=''
     48 STD_INCDIR_LIST=''
     49 STD_LIBRARY_LIST=''
     50 
     51 export NAME
     52 export SRCFILE_LIST
     53 export CPPDEF_LIST STD_CPPDEF_LIST
     54 export INCDIR_LIST STD_INCDIR_LIST 
     55 export LIBDEP_LIST
     56 export LIBRARY_LIST STD_LIBRARY_LIST
     57 
     58 ${AWK} '
     59 BEGIN {
     60 	NAME=ENVIRON["NAME"]
     61 
     62 	SRCFILES=""
     63 	sz = split(ENVIRON["SRCFILE_LIST"], a);
     64 	for (i = 1; i <= sz; i++) {
     65 		if (SRCFILES != "") {
     66 			SRCFILES=SRCFILES "\n"
     67 		}
     68 		SRCFILES=SRCFILES "# Begin Source File\n"
     69 		SRCFILES=SRCFILES "\n"
     70 		SRCFILES=SRCFILES "SOURCE=.\\" a[i] "\n"
     71 		SRCFILES=SRCFILES "# End Source File"
     72 	}
     73 
     74 	CPPDEFS=""
     75 	sz = split(ENVIRON["STD_CPPDEF_LIST"], a);
     76 	for (i = 1; i <= sz; i++) {
     77 		if (CPPDEFS != "") {
     78 			CPPDEFS=CPPDEFS " "
     79 		}
     80 		CPPDEFS=CPPDEFS "/D \"" a[i] "\""
     81 	}
     82 	sz = split(ENVIRON["CPPDEF_LIST"], a);
     83 	for (i = 1; i <= sz; i++) {
     84 		if (CPPDEFS != "") {
     85 			CPPDEFS=CPPDEFS " "
     86 		}
     87 		CPPDEFS=CPPDEFS "/D \"" a[i] "\""
     88 	}
     89 
     90 	INCDIRS=""
     91 	sz = split(ENVIRON["STD_INCDIR_LIST"], a);
     92 	for (i = 1; i <= sz; i++) {
     93 		if (INCDIRS != "") {
     94 			INCDIRS=INCDIRS " "
     95 		}
     96 		INCDIRS=INCDIRS "/I \"" a[i] "\""
     97 	}
     98 	sz = split(ENVIRON["INCDIR_LIST"], a);
     99 	for (i = 1; i <= sz; i++) {
    100 		if (INCDIRS != "") {
    101 			INCDIRS=INCDIRS " "
    102 		}
    103 		INCDIRS=INCDIRS "/I \"" a[i] "\""
    104 	}
    105 	sz = split(ENVIRON["LIBDEP_LIST"], a);
    106 	for (i = 1; i <= sz; i++) {
    107 		if (INCDIRS != "") {
    108 			INCDIRS=INCDIRS " "
    109 		}
    110 		INCDIRS=INCDIRS "/I \"..\\" a[i] "\""
    111         }
    112 
    113 	LIBRARIES=""
    114 	sz = split(ENVIRON["STD_LIBRARY_LIST"], a);
    115 	for (i = 1; i <= sz; i++) {
    116 		if (LIBRARIES != "") {
    117 			LIBRARIES=LIBRARIES " "
    118 		}
    119 		LIBRARIES=LIBRARIES a[i] ".lib"
    120 	}
    121 	sz = split(ENVIRON["LIBRARY_LIST"], a);
    122 	for (i = 1; i <= sz; i++) {
    123 		if (LIBRARIES != "") {
    124 			LIBRARIES=LIBRARIES " "
    125 		}
    126 		LIBRARIES=LIBRARIES a[i] ".lib"
    127         }
    128 	sz = split(ENVIRON["LIBDEP_LIST"], a);
    129 	for (i = 1; i <= sz; i++) {
    130 		if (LIBRARIES != "") {
    131 			LIBRARIES=LIBRARIES " "
    132 		}
    133 		LIBRARIES=LIBRARIES a[i] ".lib"
    134 	}
    135 
    136 	sz = split(ENVIRON["LIBDEP_LIST"], a);
    137 	DEBUG_LIBPATH=""
    138 	RELEASE_LIBPATH=""
    139 	for (i = 1; i <= sz; i++) {
    140 		if (i > 1) {
    141 			DEBUG_LIBPATH=DEBUG_LIBPATH " "
    142 			RELEASE_LIBPATH=RELEASE_LIBPATH " "
    143 		}
    144 		DEBUG_LIBPATH=DEBUG_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSDbg\""
    145 		RELEASE_LIBPATH=RELEASE_LIBPATH "/libpath:\"..\\" a[i] "\\WMIPSRel\""
    146 	}
    147 }
    148 {
    149 	gsub("%%% NAME %%%", NAME)
    150 	gsub("%%% SRCFILES %%%", SRCFILES)
    151 	gsub("%%% CPPDEFS %%%", CPPDEFS)
    152 	gsub("%%% INCDIRS %%%", INCDIRS)
    153 	gsub("%%% LIBRARIES %%%", LIBRARIES)
    154 	gsub("%%% DEBUG_LIBPATH %%%", DEBUG_LIBPATH)
    155 	gsub("%%% RELEASE_LIBPATH %%%", RELEASE_LIBPATH)
    156 	print $0
    157 }
    158 ' ../dspgen/${TYPE}.tmpl | awk ' { printf "%s\r\n", $0 }' > ${NAME}.dsp
    159