3 # osdef.sh -- copy osdef.h.in to osdef.h while removing declarations
4 # found in the system header files. Caution: weird sed magic going on here.
5 # Warnings are printed if sed did not survive.
7 # (C) Michael Schroeder, Juergen Weigert
9 # osdef.h.in has been split into osdef1.h.in and osdef2.h.in, because some
10 # sed's could not handle the amount of commands (is 50 commands the limit?).
14 if test -z "$CC"; then
17 if test -z "$srcdir"; then
25 # define select select_declared_wrong
27 #define tgetstr tgetstr_declared_wrong
28 #include "auto/config.h"
29 #include "os_unix.h" /* bring in most header files, more follow below */
30 #include "os_unixx.h" /* bring in header files for os_unix.c */
33 # include <termcap.h> /* only for term.c */
37 # include <fcntl.h> /* only used in a few files */
40 #ifdef HAVE_SYS_STATFS_H
41 # include <sys/types.h>
42 # include <sys/statfs.h> /* only for memfile.c */
46 # include <X11/Intrinsic.h>
50 # Mac uses precompiled headers, but we need real headers here.
52 Darwin
) $CC -I.
-I$srcdir -E -no-cpp-precomp osdef0.c
>osdef0.cc
;;
53 *) $CC -I.
-I$srcdir -E osdef0.c
>osdef0.cc
;;
56 # insert a space in front of each line, so that a function name at the
57 # start of the line is matched with "[)*, ]\1[ (]"
58 sed < osdef0.cc
-e '/\(..*\)/s// \1/' > osdef0.ccc
60 sed < $srcdir/osdef1.h.
in -n -e '/^extern/s@.*[)* ][)* ]*\([a-zA-Z_][a-zA-Z0-9_]*\) __ARGS.*@/[)*, ][(]*\1[)]*[ (]/i\\\
61 \\/\\[^a-zA-Z_\\]\1 __ARGS\\/d@p' > osdef11.
sed
63 sed < $srcdir/osdef2.h.
in -n -e '/^extern/s@.*[)* ][)* ]*\([a-zA-Z_][a-zA-Z0-9_]*\) __ARGS.*@/[)*, ][(]*\1[)]*[ (]/i\\\
64 \\/\\[^a-zA-Z_\\]\1 __ARGS\\/d@p' > osdef21.
sed
66 cat << EOF > osdef2.sed
70 * osdef.h is automagically created from osdef?.h.in by osdef.sh -- DO NOT EDIT
75 cat osdef0.ccc |
sed -n -f osdef11.
sed >> osdef2.
sed
76 sed -f osdef2.
sed < $srcdir/osdef1.h.
in > auto
/osdef.h
78 cat osdef0.ccc |
sed -n -f osdef21.
sed > osdef2.
sed
79 sed -f osdef2.
sed < $srcdir/osdef2.h.
in >> auto
/osdef.h
81 rm osdef0.c osdef0.cc osdef0.ccc osdef11.
sed osdef21.
sed osdef2.
sed
83 if test -f core
*; then
85 echo " Sorry, your sed is broken. Call the system administrator."
86 echo " Meanwhile, you may try to compile Vim with an empty osdef.h file."
87 echo " If you compiler complains about missing prototypes, move the needed"
88 echo " ones from osdef1.h.in and osdef2.h.in to osdef.h."
91 cat $srcdir/osdef1.h.
in $srcdir/osdef2.h.
in >osdefX.h.
in
92 if eval test "`diff auto/osdef.h osdefX.h.in | wc -l`" -eq 4; then
93 echo " Hmm, sed is very pessimistic about your system header files."
94 echo " But it did not dump core -- strange! Let's continue carefully..."
95 echo " If this fails, you may want to remove offending lines from osdef.h"
96 echo " or try with an empty osdef.h file, if your compiler can do without"
97 echo " function declarations."