]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/mk-test.awk
ncurses 6.2 - patch 20210306
[ncurses.git] / test / mk-test.awk
1 # $Id: mk-test.awk,v 1.23 2020/02/02 23:34:34 tom Exp $
2 ##############################################################################
3 # Copyright 2019,2020 Thomas E. Dickey                                       #
4 # Copyright 2006-2017,2018 Free Software Foundation, Inc.                    #
5 #                                                                            #
6 # Permission is hereby granted, free of charge, to any person obtaining a    #
7 # copy of this software and associated documentation files (the "Software"), #
8 # to deal in the Software without restriction, including without limitation  #
9 # the rights to use, copy, modify, merge, publish, distribute, distribute    #
10 # with modifications, sublicense, and/or sell copies of the Software, and to #
11 # permit persons to whom the Software is furnished to do so, subject to the  #
12 # following conditions:                                                      #
13 #                                                                            #
14 # The above copyright notice and this permission notice shall be included in #
15 # all copies or substantial portions of the Software.                        #
16 #                                                                            #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23 # DEALINGS IN THE SOFTWARE.                                                  #
24 #                                                                            #
25 # Except as contained in this notice, the name(s) of the above copyright     #
26 # holders shall not be used in advertising or otherwise to promote the sale, #
27 # use or other dealings in this Software without prior written               #
28 # authorization.                                                             #
29 ##############################################################################
30 #
31 # Author: Thomas E. Dickey
32 #
33 # generate Makefile for ncurses tests.
34 BEGIN   {
35                 first = 1;
36                 count = 0;
37         }
38 /^#/    {
39                 next;
40         }
41 /^$/    {
42                 next;
43         }
44         {
45                 if (first) {
46                         print "# generated by mk-test.awk\n";
47                         first = 0;
48                 }
49                 progs[count] = $1;
50                 flags[count] = $2;
51                 using[count] = $3;
52                 files[count] = "";
53                 for (n = 4; n <= NF; ++n) {
54                         files[count] = sprintf("%s $(MODEL)/%s$o", files[count], $n);
55                 }
56                 count = count + 1;
57         }
58 END     {
59         for (n = 0; n < count; ++n) {
60                 if (n == 0) {
61                         printf "TESTS\t= ";
62                 } else {
63                         printf "\t  ";
64                 }
65                 printf "$(destdir)%s$x", progs[n];
66                 if (n < count - 1) {
67                         printf " \\";
68                 }
69                 print "";
70         }
71         print   "SCRIPTS = \\"
72         print   "       $(srcdir)/savescreen.sh \\"
73         print   "       $(srcdir)/tput-colorcube \\"
74         print   "       $(srcdir)/tput-initc \\"
75         print   "       $(srcdir)/tracemunch"
76         print   "DATAFILES = \\"
77         print   "       $(srcdir)/*.x* \\"
78         print   "       $(srcdir)/*.dat"
79         print   ""
80         print   "all: $(TESTS)"
81         print   ""
82         print   "sources:"
83         print   ""
84         print   "check:"
85         print   "       @ echo The test-programs are interactive"
86         print   "tags:"
87         print   "       $(CTAGS) *.[ch]"
88         print   ""
89         print   "# no libraries here"
90         print   "libs \\"
91         print   "install.libs \\"
92         print   "uninstall.libs:"
93         print   ""
94         if (INSTALL == "yes") {
95                 print   "# we might install the test-programs"
96                 print   "install \\"
97                 print   "install.test: $(BINDIR) $(DATADIR) $(TESTS)"
98
99                 print   "       @$(SHELL) -c 'for src in $(TESTS); do \\"
100                 print   "       dst=`echo $$src | $(TRANSFORM)`; \\"
101                 print   "       echo \"installing $$src -> $(BINDIR)/$$dst\"; \\"
102                 print   "       $(INSTALL_PROG) $$src $(BINDIR)/$$dst; \\"
103                 print   "       done'"
104
105                 print   "       @$(SHELL) -c 'for src in $(SCRIPTS); do \\"
106                 print   "       dst=`echo $$src | sed -e 's,^.*/,,' | $(TRANSFORM)`; \\"
107                 print   "       echo \"installing $$src -> $(BINDIR)/$$dst\"; \\"
108                 print   "       $(INSTALL_SCRIPT) $$src $(BINDIR)/$$dst; \\"
109                 print   "       done'"
110
111                 print   "       @$(SHELL) -c 'for src in $(DATAFILES); do \\"
112                 print   "       dst=`echo $$src | sed -e 's,^.*/,,'`; \\"
113                 print   "       echo \"installing $$src -> $(DATADIR)/$$dst\"; \\"
114                 print   "       $(INSTALL_DATA) $$src $(DATADIR)/$$dst; \\"
115                 print   "       done'"
116                 print   ""
117                 print   "uninstall \\"
118                 print   "uninstall.test:"
119
120                 print   "       @$(SHELL) -c 'for src in $(TESTS); do \\"
121                 print   "       dst=`echo $$src | $(TRANSFORM)`; \\"
122                 print   "       rm -f $(BINDIR)/$$dst; \\"
123                 print   "       done'"
124
125                 print   "       @$(SHELL) -c 'for src in $(SCRIPTS); do \\"
126                 print   "       dst=`echo $$src | sed -e 's,^.*/,,' | $(TRANSFORM)`; \\"
127                 print   "       rm -f $(BINDIR)/$$dst; \\"
128                 print   "       done'"
129
130                 print   "       @$(SHELL) -c 'for src in $(DATAFILES); do \\"
131                 print   "       dst=`echo $$src | sed -e 's,^.*/,,'`; \\"
132                 print   "       rm -f $(DATADIR)/$$dst; \\"
133                 print   "       done'"
134         } else {
135                 print   "install \\"
136                 print   "install.test \\"
137                 print   "uninstall \\"
138                 print   "uninstall.test:"
139         }
140         print   ""
141         print   "mostlyclean ::"
142         print   "       -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace"
143         print   ""
144         print   "clean :: mostlyclean"
145         print   "       -$(SHELL) -c \"if test -n '$x' ; then $(MAKE) clean x=''; fi\""
146         print   "       -rm -rf *$o screendump *.lis $(TESTS) .libs *.dSYM"
147         print   ""
148         print   "distclean :: clean"
149         print   "       -rm -f Makefile ncurses_cfg.h config.status config.log"
150         print   ""
151         print   "realclean :: distclean"
152         print   ""
153         print   "lint:"
154         print   "       $(SHELL) -c 'for N in $(TESTS); do echo LINT:$$N; $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/$$N.c $(LINT_LIBS); done'"
155         print   "$(BINDIR) $(DATADIR) :"
156         print   "       mkdir -p $@"
157
158
159         if (ECHO_LINK != "") {
160                 ECHO_LINK="@ echo linking $@ ... ;"
161         }
162         for (n = 0; n < count; ++n) {
163                 print "";
164                 printf "$(destdir)%s$x:%s %s\n", progs[n], files[n], using[n];
165                 printf "\t%s$(LINK) -o $@%s %s\n", ECHO_LINK, files[n], flags[n];
166         }
167
168         }