]> ncurses.scripts.mit.edu Git - ncurses.git/blob - mk-2nd.awk
ncurses 4.1
[ncurses.git] / mk-2nd.awk
1 # $Id: mk-2nd.awk,v 1.7 1996/12/01 00:26:51 tom Exp $
2 ################################################################################
3 # Copyright 1996 by Thomas E. Dickey <dickey@clark.net>                        #
4 # All Rights Reserved.                                                         #
5 #                                                                              #
6 # Permission to use, copy, modify, and distribute this software and its        #
7 # documentation for any purpose and without fee is hereby granted, provided    #
8 # that the above copyright notice appear in all copies and that both that      #
9 # copyright notice and this permission notice appear in supporting             #
10 # documentation, and that the name of the above listed copyright holder(s) not #
11 # be used in advertising or publicity pertaining to distribution of the        #
12 # software without specific, written prior permission. THE ABOVE LISTED        #
13 # COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,    #
14 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
15 # SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL,        #
16 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   #
17 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE   #
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR    #
19 # PERFORMANCE OF THIS SOFTWARE.                                                #
20 ################################################################################
21 # Generate compile-rules for the modules that we are using in libraries or
22 # programs.  We are listing them explicitly because we have turned off the
23 # suffix rules (to force compilation with the appropriate flags).  We could use
24 # make-recursion but that would result in makefiles that are useless for
25 # development.
26 #
27 # Variables:
28 #       model
29 #       MODEL (uppercase version of "model"; toupper is not portable)
30 #       echo (yes iff we will show the $(CC) lines)
31 #
32 # Fields in src/modules:
33 #       $1 = module name
34 #       $2 = progs|lib|c++
35 #       $3 = source-directory
36 #
37 # Fields in src/modules past $3 are dependencies
38 #
39 BEGIN   {
40         print  ""
41         print  "# generated by mk-2nd.awk"
42         print  ""
43         }
44         !/^#/ {
45         if ( $1 != "" ) {
46                 print  ""
47                 if ( $2 == "c++" ) {
48                         compile="CXX"
49                         suffix=".cc"
50                 } else {
51                         compile="CC"
52                         suffix=".c"
53                 }
54                 printf "../%s/%s.o :\t%s/%s%s", model, $1, $3, $1, suffix
55                 for (n = 4; n <= NF; n++) printf " \\\n\t\t\t%s", $n
56                 print  ""
57                 if ( echo == "yes" )
58                         atsign=""
59                 else {
60                         atsign="@"
61                         printf "\t@echo 'compiling %s (%s)'\n", $1, model
62                 }
63                 if ( $3 == "." || srcdir == "." )
64                         printf "\t%scd ../%s; $(%s) $(CFLAGS_%s) -c ../%s/%s%s", atsign, model, compile, MODEL, name, $1, suffix
65                 else
66                         printf "\t%scd ../%s; $(%s) $(CFLAGS_%s) -c %s/%s%s", atsign, model, compile, MODEL, $3, $1, suffix
67         } else {
68                 printf "%s", $1
69                 for (n = 2; n <= NF; n++) printf " %s", $n
70         }
71         print  ""
72         }
73 END     {
74         print  ""
75         }