3 # Copyright (c) 1992, 1993
4 # The Regents of the University of California. All rights reserved.
6 # This code is derived from software contributed to Berkeley by
7 # Christos Zoulas of Cornell University.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
17 # 3. Neither the name of the University nor the names of its contributors
18 # may be used to endorse or promote products derived from this software
19 # without specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 # @(#)makelist 5.3 (Berkeley) 6/4/93
34 # $NetBSD: makelist,v 1.11 2005/10/22 16:45:03 christos Exp $
35 # $DragonFly: src/lib/libedit/makelist,v 1.6 2008/11/12 21:44:59 swildner Exp $
37 # makelist.sh: Automatically generate header files...
40 USAGE
="Usage: $0 -h|-e|-fc|-fh|-bc|-bh|-m <filenames>"
55 # generate foo.h file from foo.c
58 set - `echo $FILES | sed -e 's/\\./_/g'`
59 hdr
="_h_`basename $1`"
62 printf("/* Automatically generated file, do not edit */\n");
63 printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'");
66 pr = substr($2, 1, 2);
67 if (pr == "vi" || pr == "em" || pr == "ed") {
68 name = substr($2, 1, length($2) - 3);
70 # XXX: need a space between name and prototype so that -fc and -fh
71 # parsing is much easier
73 printf("protected el_action_t\t%s (EditLine *, int);\n", name);
77 printf("#endif /* %s */\n", "'$hdr'");
81 # generate help.c from various .c files
86 printf("/* Automatically generated file, do not edit */\n");
87 printf("#include \"sys.h\"\n#include \"el.h\"\n");
88 printf("private const struct el_bindings_t el_func_help[] = {\n");
89 low = "abcdefghijklmnopqrstuvwxyz_";
90 high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
91 for (i = 1; i <= length(low); i++)
92 tr[substr(low, i, 1)] = substr(high, i, 1);
95 pr = substr($2, 1, 2);
96 if (pr == "vi" || pr == "em" || pr == "ed") {
97 name = substr($2, 1, length($2) - 3);
100 for (i = 1; i <= length(name); i++) {
101 s = substr(name, i, 1);
108 printf(" { %-30.30s %-30.30s\n","\"" fname "\",", uname ",");
115 for (i = 2; i < NF; i++)
117 printf("%s\" },\n", $i);
123 printf("\nprotected const el_bindings_t* help__get(void)");
124 printf("{ return el_func_help; }\n");
128 # generate help.h from various .c files
133 printf("/* Automatically generated file, do not edit */\n");
134 printf("#ifndef _h_help_c\n#define _h_help_c\n");
135 printf("protected const el_bindings_t *help__get(void);\n");
136 printf("#endif /* _h_help_c */\n");
140 # generate fcns.h from various .h files
143 cat $FILES |
$AWK '/el_action_t/ { print $3 }' | \
144 sort |
tr '[:lower:]' '[:upper:]' |
$AWK '
146 printf("/* Automatically generated file, do not edit */\n");
147 printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n");
151 printf("#define\t%-30.30s\t%3d\n", $1, count++);
154 printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
156 printf("typedef el_action_t (*el_func_t)(EditLine *, int);");
157 printf("\nprotected const el_func_t* func__get(void);\n");
158 printf("#endif /* _h_fcns_c */\n");
162 # generate fcns.c from various .h files
165 cat $FILES |
$AWK '/el_action_t/ { print $3 }' |
sort |
$AWK '
167 printf("/* Automatically generated file, do not edit */\n");
168 printf("#include \"sys.h\"\n#include \"el.h\"\n");
169 printf("private const el_func_t el_func[] = {");
185 printf("%-26.26s ", s);
189 printf("\nprotected const el_func_t* func__get(void) { return el_func; }\n");
193 # generate editline.c from various .c files
196 echo "$FILES" |
tr ' ' '\012' |
$AWK '
198 printf("/* Automatically generated file, do not edit */\n");
199 printf("#define protected static\n");
200 printf("#define SCCSID\n");
203 printf("#include \"%s\"\n", $1);
207 # generate man page fragment from various .c files
212 printf(".\\\" Section automatically generated with makelist\n");
213 printf(".Bl -tag -width 4n\n");
216 pr = substr($2, 1, 2);
217 if (pr == "vi" || pr == "em" || pr == "ed") {
218 name = substr($2, 1, length($2) - 3);
220 for (i = 1; i <= length(name); i++) {
221 s = substr(name, i, 1);
227 printf(".It Ic %s\n", fname);
233 for (i = 2; i < NF; i++)
241 printf(".\\\" End of section automatically generated with makelist\n");