mk-2nd.awk revision 166124
1166124Srafan# $Id: mk-2nd.awk,v 1.19 2005/01/22 16:30:04 tom Exp $ 250276Speter############################################################################## 3166124Srafan# Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. # 450276Speter# # 550276Speter# Permission is hereby granted, free of charge, to any person obtaining a # 650276Speter# copy of this software and associated documentation files (the "Software"), # 750276Speter# to deal in the Software without restriction, including without limitation # 850276Speter# the rights to use, copy, modify, merge, publish, distribute, distribute # 950276Speter# with modifications, sublicense, and/or sell copies of the Software, and to # 1050276Speter# permit persons to whom the Software is furnished to do so, subject to the # 1150276Speter# following conditions: # 1250276Speter# # 1350276Speter# The above copyright notice and this permission notice shall be included in # 1450276Speter# all copies or substantial portions of the Software. # 1550276Speter# # 1650276Speter# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 1750276Speter# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 1850276Speter# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 1950276Speter# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 2050276Speter# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 2150276Speter# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 2250276Speter# DEALINGS IN THE SOFTWARE. # 2350276Speter# # 2450276Speter# Except as contained in this notice, the name(s) of the above copyright # 2550276Speter# holders shall not be used in advertising or otherwise to promote the sale, # 2650276Speter# use or other dealings in this Software without prior written # 2750276Speter# authorization. # 2850276Speter############################################################################## 2950276Speter# 30166124Srafan# Author: Thomas E. Dickey 3150276Speter# 3250276Speter# Generate compile-rules for the modules that we are using in libraries or 3350276Speter# programs. We are listing them explicitly because we have turned off the 3450276Speter# suffix rules (to force compilation with the appropriate flags). We could use 3550276Speter# make-recursion but that would result in makefiles that are useless for 3650276Speter# development. 3750276Speter# 3850276Speter# Variables: 39166124Srafan# model directory into which objects are compiled. 4050276Speter# MODEL (uppercase version of "model"; toupper is not portable) 4150276Speter# echo (yes iff we will show the $(CC) lines) 4250276Speter# subset ("none", "base", "base+ext_funcs" or "termlib") 43166124Srafan# crenames ("yes" or "no", flag to control whether -c & -o options are used) 44166124Srafan# cxxrenames ("yes" or "no", flag to control whether -c & -o options are used) 45166124Srafan# traces ("all" or "DEBUG", to control whether tracing is compiled in) 46166124Srafan# srcdir is expanded when "configure --srcdir" was used 4750276Speter# 4850276Speter# Fields in src/modules: 4950276Speter# $1 = module name 5050276Speter# $2 = progs|lib|c++ 5150276Speter# $3 = source-directory 5250276Speter# 5350276Speter# Fields in src/modules past $3 are dependencies 5450276Speter# 5550276SpeterBEGIN { 5650276Speter found = 0 5750276Speter using = 0 5850276Speter } 5950276Speter /^@/ { 6050276Speter using = 0 6150276Speter if (subset == "none") { 6250276Speter using = 1 6350276Speter } else if (index(subset,$2) > 0) { 6450276Speter if (using == 0) { 6550276Speter if (found == 0) { 6650276Speter print "" 6750276Speter print "# generated by mk-2nd.awk" 68166124Srafan printf "# model: %s\n", model 69166124Srafan printf "# MODEL: %s\n", MODEL 70166124Srafan printf "# echo: %s\n", echo 71166124Srafan printf "# subset: %s\n", subset 72166124Srafan printf "# crenames: %s\n", crenames 73166124Srafan printf "# cxxrenames: %s\n", cxxrenames 74166124Srafan printf "# traces: %s\n", traces 75166124Srafan printf "# srcdir: %s\n", srcdir 7650276Speter } 7750276Speter using = 1 7850276Speter } 7950276Speter } 8050276Speter } 8162449Speter /^[@#]/ { 8262449Speter next 8362449Speter } 8462449Speter $1 ~ /trace/ { 8562449Speter if (traces != "all" && traces != MODEL && $1 != "lib_trace") 8662449Speter next 8762449Speter } 8862449Speter { 8950276Speter if ($0 != "" \ 9050276Speter && using != 0) { 9150276Speter found = 1 9250276Speter if ( $1 != "" ) { 9350276Speter print "" 9450276Speter if ( $2 == "c++" ) { 9550276Speter compile="CXX" 9650276Speter suffix=".cc" 97166124Srafan use_c_o=cxxrenames 9850276Speter } else { 9950276Speter compile="CC" 10050276Speter suffix=".c" 101166124Srafan use_c_o=crenames 10250276Speter } 103166124Srafan printf "../%s/%s$o :\t%s/%s%s", model, $1, $3, $1, suffix 10450276Speter for (n = 4; n <= NF; n++) printf " \\\n\t\t\t%s", $n 10550276Speter print "" 10650276Speter if ( echo == "yes" ) 10750276Speter atsign="" 10850276Speter else { 10950276Speter atsign="@" 11050276Speter printf "\t@echo 'compiling %s (%s)'\n", $1, model 11150276Speter } 112166124Srafan printf "\t%s", atsign; 113166124Srafan if ( use_c_o != "yes" ) { 114166124Srafan printf "cd ../%s; ", model; 115166124Srafan } 116166124Srafan # The choice here is between 117166124Srafan # base+ext_funcs and 118166124Srafan # termlib+ext_tinfo 119166124Srafan # but they may appear in the same value. 120166124Srafan if ( subset ~ /base/ ) { 121166124Srafan mycflags="" 122166124Srafan } else if ( subset ~ /termlib/ ) { 123166124Srafan mycflags=" -DUSE_TERMLIB" 124166124Srafan } 125166124Srafan printf "$(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s)%s -c ", compile, MODEL, mycflags 12650276Speter if ( $3 == "." || srcdir == "." ) { 12750276Speter dir = $3 "/" 12850276Speter sub("^\\$\\(srcdir\\)/","",dir); 12950276Speter sub("^\\./","",dir); 130166124Srafan printf "../%s/%s%s%s", name, dir, $1, suffix 131166124Srafan } else { 132166124Srafan printf "%s/%s%s", $3, $1, suffix 133166124Srafan } 134166124Srafan if ( use_c_o == "yes" ) { 135166124Srafan printf " -o ../%s/%s$o", model, $1 136166124Srafan } 13750276Speter } else { 13850276Speter printf "%s", $1 13950276Speter for (n = 2; n <= NF; n++) printf " %s", $n 14050276Speter } 14150276Speter print "" 14250276Speter } 14350276Speter } 14450276SpeterEND { 14550276Speter print "" 14650276Speter } 147