3 # $NetBSD: makelist,v 1.18 2012/03/21 05:34:54 matt Exp $
5 # Copyright (c) 1992, 1993
6 # The Regents of the University of California. All rights reserved.
8 # This code is derived from software contributed to Berkeley by
9 # Christos Zoulas of Cornell University.
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
14 # 1. Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # 2. Redistributions in binary form must reproduce the above copyright
17 # notice, this list of conditions and the following disclaimer in the
18 # documentation and/or other materials provided with the distribution.
19 # 3. Neither the name of the University nor the names of its contributors
20 # may be used to endorse or promote products derived from this software
21 # without specific prior written permission.
23 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 # @(#)makelist 5.3 (Berkeley) 6/4/93
37 # makelist.sh: Automatically generate header files...
40 USAGE="Usage: $0 -n|-h|-e|-fc|-fh|-bc|-bh|-m <filenames>"
55 # generate foo.h file from foo.c
67 set - `echo $FILES | sed -e 's/\\./_/g'`
68 hdr="_h_`basename $1`"
71 printf("/* Automatically generated file, do not edit */\n");
72 printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'");
75 pr = substr($2, 1, 2);
76 if (pr == "vi" || pr == "em" || pr == "ed") {
77 name = substr($2, 1, length($2) - 3);
79 # XXX: need a space between name and prototype so that -fc and -fh
80 # parsing is much easier
82 printf("protected el_action_t\t%s (EditLine *, wint_t);\n",
87 printf("#endif /* %s */\n", "'$hdr'");
91 # generate help.c from various .c files
96 printf("/* Automatically generated file, do not edit */\n");
97 printf("#include \"config.h\"\n#include \"el.h\"\n");
98 printf("#include \"help.h\"\n");
99 printf("private const struct el_bindings_t el_func_help[] = {\n");
100 low = "abcdefghijklmnopqrstuvwxyz_";
101 high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
102 for (i = 1; i <= length(low); i++)
103 tr[substr(low, i, 1)] = substr(high, i, 1);
106 pr = substr($2, 1, 2);
107 if (pr == "vi" || pr == "em" || pr == "ed") {
108 name = substr($2, 1, length($2) - 3);
111 for (i = 1; i <= length(name); i++) {
112 s = substr(name, i, 1);
119 printf(" { %-30.30s %-30.30s\n","STR(\"" fname "\"),", uname ",");
126 for (i = 2; i < NF; i++)
128 printf("%s\") },\n", $i);
134 printf("\nprotected const el_bindings_t* help__get(void)");
135 printf("{ return el_func_help; }\n");
139 # generate help.h from various .c files
144 printf("/* Automatically generated file, do not edit */\n");
145 printf("#ifndef _h_help_c\n#define _h_help_c\n");
146 printf("protected const el_bindings_t *help__get(void);\n");
147 printf("#endif /* _h_help_c */\n");
151 # generate fcns.h from various .h files
154 cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
155 sort | tr '[:lower:]' '[:upper:]' | $AWK '
157 printf("/* Automatically generated file, do not edit */\n");
158 printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n");
162 printf("#define\t%-30.30s\t%3d\n", $1, count++);
165 printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
167 printf("typedef el_action_t (*el_func_t)(EditLine *, wint_t);");
168 printf("\nprotected const el_func_t* func__get(void);\n");
169 printf("#endif /* _h_fcns_c */\n");
173 # generate fcns.c from various .h files
176 cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK '
178 printf("/* Automatically generated file, do not edit */\n");
179 printf("#include \"config.h\"\n#include \"el.h\"\n");
180 printf("#include \"common.h\"\n");
181 printf("#include \"emacs.h\"\n");
182 printf("#include \"vi.h\"\n");
183 printf("private const el_func_t el_func[] = {");
199 printf("%-26.26s ", s);
203 printf("\nprotected const el_func_t* func__get(void) { return el_func; }\n");
207 # generate editline.c from various .c files
210 echo "$FILES" | tr ' ' '\012' | $AWK '
212 printf("/* Automatically generated file, do not edit */\n");
213 printf("#define protected static\n");
214 printf("#define SCCSID\n");
217 printf("#include \"%s\"\n", $1);
221 # generate man page fragment from various .c files
226 printf(".\\\" Section automatically generated with makelist\n");
227 printf(".Bl -tag -width 4n\n");
230 pr = substr($2, 1, 2);
231 if (pr == "vi" || pr == "em" || pr == "ed") {
232 name = substr($2, 1, length($2) - 3);
234 for (i = 1; i <= length(name); i++) {
235 s = substr(name, i, 1);
241 printf(".It Ic %s\n", fname);
247 for (i = 2; i < NF; i++)
255 printf(".\\\" End of section automatically generated with makelist\n");