blob: a194a5d4ee7fb322d18c5ac2a8a847d0460756da [file] [log] [blame]
micky3879b9f5e72025-07-08 18:04:53 -04001# $Id: mk-test.awk,v 1.30 2021/12/19 16:54:36 tom Exp $
Steve Kondikae271bc2015-11-15 02:50:53 +01002##############################################################################
micky3879b9f5e72025-07-08 18:04:53 -04003# Copyright 2019-2020,2021 Thomas E. Dickey #
4# Copyright 2006-2017,2018 Free Software Foundation, Inc. #
Steve Kondikae271bc2015-11-15 02:50:53 +01005# #
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.
34BEGIN {
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 }
58END {
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 }
micky3879b9f5e72025-07-08 18:04:53 -040071 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"
Steve Kondikae271bc2015-11-15 02:50:53 +010079 print ""
micky3879b9f5e72025-07-08 18:04:53 -040080 print "all:: $(TESTS)"
Steve Kondikae271bc2015-11-15 02:50:53 +010081 print ""
82 print "sources:"
83 print ""
micky3879b9f5e72025-07-08 18:04:53 -040084 print "check::"
85 print " @ echo The test-programs are interactive"
Steve Kondikae271bc2015-11-15 02:50:53 +010086 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"
micky3879b9f5e72025-07-08 18:04:53 -040096 print "$(PACKAGE) :"
97 print " @echo \"creating $(PACKAGE) script\""
98 print " @$(SHELL) -c '\\"
99 print " L=$(real_bindir); \\"
100 print " rm -f $@; \\"
101 print " echo \"#!$(SHELL)\" > $@;\\"
102 print " echo \"PATH=\\\"$$L\\\":\\$$PATH\" >>$@;\\"
103 print " echo \"export PATH\" >>$@;\\"
104 print " echo \"if test \\$$# != 0; then\" >>$@;\\"
105 print " echo \" exec \\\"\\$$@\\\"\" >>$@;\\"
106 print " echo \"elif test -t 1; then\" >>$@;\\"
107 print " echo \" cd \\\"$$L\\\" || exit\" >>$@;\\"
108 print " echo \" ls -l | \\$${PAGER:-less}\" >>$@;\\"
109 print " echo \"fi\" >>$@;\\"
110 print " echo \"echo \\\"usage: $@ [program]\\\"\" >>$@'"
111 print ""
Steve Kondikae271bc2015-11-15 02:50:53 +0100112 print "install \\"
micky3879b9f5e72025-07-08 18:04:53 -0400113 print "install.test: $(PACKAGE) $(BINDIR) $(REAL_BINDIR) $(DATADIR) $(TESTS)"
114
115 print " @echo \"installing $(PACKAGE) -> $(BINDIR)/\""
116 print " @$(INSTALL_SCRIPT) $(PACKAGE) $(BINDIR)"
117
118 print " @$(SHELL) -c 'for src in $(TESTS); do \\"
Steve Kondikae271bc2015-11-15 02:50:53 +0100119 print " dst=`echo $$src | $(TRANSFORM)`; \\"
micky3879b9f5e72025-07-08 18:04:53 -0400120 print " echo \"installing $$src -> $(REAL_BINDIR)/$$dst\"; \\"
121 print " $(INSTALL_PROG) $$src $(REAL_BINDIR)/$$dst; \\"
122 print " done'"
123
124 print " @$(SHELL) -c 'for src in $(SCRIPTS); do \\"
125 print " dst=`echo $$src | sed -e 's,^.*/,,' | $(TRANSFORM)`; \\"
126 print " echo \"installing $$src -> $(REAL_BINDIR)/$$dst\"; \\"
127 print " $(INSTALL_SCRIPT) $$src $(REAL_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 " echo \"installing $$src -> $(DATADIR)/$$dst\"; \\"
133 print " $(INSTALL_DATA) $$src $(DATADIR)/$$dst; \\"
Steve Kondikae271bc2015-11-15 02:50:53 +0100134 print " done'"
135 print ""
136 print "uninstall \\"
137 print "uninstall.test:"
micky3879b9f5e72025-07-08 18:04:53 -0400138
139 print " -rm -f $(BINDIR)/$(PACKAGE)"
140
141 print " @$(SHELL) -c 'for src in $(TESTS); do \\"
Steve Kondikae271bc2015-11-15 02:50:53 +0100142 print " dst=`echo $$src | $(TRANSFORM)`; \\"
micky3879b9f5e72025-07-08 18:04:53 -0400143 print " rm -f $(REAL_BINDIR)/$$dst; \\"
144 print " done'"
145
146 print " @$(SHELL) -c 'for src in $(SCRIPTS); do \\"
147 print " dst=`echo $$src | sed -e 's,^.*/,,' | $(TRANSFORM)`; \\"
148 print " rm -f $(REAL_BINDIR)/$$dst; \\"
149 print " done'"
150
151 print " @$(SHELL) -c 'for src in $(DATAFILES); do \\"
152 print " dst=`echo $$src | sed -e 's,^.*/,,'`; \\"
153 print " rm -f $(DATADIR)/$$dst; \\"
Steve Kondikae271bc2015-11-15 02:50:53 +0100154 print " done'"
155 } else {
156 print "install \\"
157 print "install.test \\"
158 print "uninstall \\"
159 print "uninstall.test:"
160 }
161 print ""
162 print "mostlyclean ::"
163 print " -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace"
164 print ""
165 print "clean :: mostlyclean"
166 print " -$(SHELL) -c \"if test -n '$x' ; then $(MAKE) clean x=''; fi\""
167 print " -rm -rf *$o screendump *.lis $(TESTS) .libs *.dSYM"
micky3879b9f5e72025-07-08 18:04:53 -0400168 print " -rm -f $(PACKAGE)"
Steve Kondikae271bc2015-11-15 02:50:53 +0100169 print ""
170 print "distclean :: clean"
171 print " -rm -f Makefile ncurses_cfg.h config.status config.log"
172 print ""
173 print "realclean :: distclean"
174 print ""
175 print "lint:"
176 print " $(SHELL) -c 'for N in $(TESTS); do echo LINT:$$N; $(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/$$N.c $(LINT_LIBS); done'"
micky3879b9f5e72025-07-08 18:04:53 -0400177 print "$(BINDIR) $(REAL_BINDIR) $(DATADIR) :"
Steve Kondikae271bc2015-11-15 02:50:53 +0100178 print " mkdir -p $@"
179
180
181 if (ECHO_LINK != "") {
182 ECHO_LINK="@ echo linking $@ ... ;"
183 }
184 for (n = 0; n < count; ++n) {
185 print "";
186 printf "$(destdir)%s$x:%s %s\n", progs[n], files[n], using[n];
187 printf "\t%s$(LINK) -o $@%s %s\n", ECHO_LINK, files[n], flags[n];
188 }
189
190 }