OSDN Git Service

ignore error for ENAMETOOLONG for Cygwin
[lha/olha.git] / cproto.sh
1 #!/bin/sh
2 #
3 # generate function prototypes `prototype.h'.
4 #
5
6 trap "rm -f prototypes.h.tmp prototypes.h.bak" 0 1 2 3 15
7
8 CPROTO_FLAGS='-m -d'
9 CPPFLAGS='-DSTDC_HEADERS=1
10         -DHAVE_STRDUP=1
11         -DHAVE_MEMSET=1
12         -DHAVE_MEMMOVE=1
13         -DHAVE_STRCASECMP=1
14         -DHAVE_BASENAME=1
15         -DMULTIBYTE_FILENAME=1
16         -Dinterrupt=dummy__
17         -D"__asm__(x)=/**/"
18         -DNEED_INCREMENTAL_INDICATOR=1
19 '
20 # `interrupt' is the reserved word for cproto.
21
22 SOURCES="$@"
23
24 test -f prototypes.h && mv -f prototypes.h prototypes.h.bak
25
26 # below makes cproto regard `RETSIGTYPE' as the variable type.
27 cat <<END >prototypes.h
28 typedef void RETSIGTYPE;
29 END
30
31 exec 5>&1 > prototypes.h.tmp
32
33 cat <<END
34 /* This file was generated by cproto. */
35 #if PROTOTYPES /* defined in config.h */
36 #define P_(s) s
37 #else
38 #define P_(s) ()
39 #endif
40
41 END
42
43 cproto $CPROTO_FLAGS $CPPFLAGS $SOURCES |
44         sed -e '/^int main /d' -e 's/dummy__/interrupt/'
45
46 # cat <<END
47
48 # /* util.c */
49 # #if !HAVE_MEMMOVE
50 # void *memmove P_((void *dst, const void *src, size_t cnt));
51 # #endif
52 # #if !HAVE_STRDUP
53 # char *strdup P_((const char *buf));
54 # #endif
55 # #if !HAVE_MEMSET
56 # char *memset P_((char *s, int c, size_t n));
57 # #endif
58 # #if !HAVE_STRCASECMP
59 # int strcasecmp P_((const char *p1, const char *p2));
60 # #endif
61 # #if defined HAVE_DECL_BASENAME && !HAVE_DECL_BASENAME
62 # char *basename P_((char *s));
63 # #endif
64
65 # /* vsnprintf.c */
66 # #if !HAVE_VSNPRINTF
67 # int vsnprintf P_((char *str, size_t n, const char *fmt, va_list ap));
68 # int snprintf P_((char *str, size_t n, char const *fmt, ...));
69 # #endif
70
71 # #undef P_
72 # END
73
74 exec 1>&5
75 if test -f prototypes.h.bak && cmp -s prototypes.h.tmp prototypes.h.bak; then
76   mv -f prototypes.h.bak prototypes.h
77 else
78   mv -f prototypes.h.tmp prototypes.h
79 fi