OSDN Git Service

should use header->method instead of permission for timestamp archiving
[lha/lha.git] / src / 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         -DNEED_INCREMENTAL_INDICATOR=1
18 '
19 # `interrupt' is the reserved word for cproto.
20
21 SOURCES='append.c bitio.c crcio.c dhuf.c extract.c header.c
22         huf.c indicator.c larc.c lhadd.c lharc.c lhext.c
23         lhlist.c maketbl.c maketree.c patmatch.c
24         shuf.c slide.c util.c
25 '
26
27 test -f prototypes.h && mv -f prototypes.h prototypes.h.bak
28
29 # below makes cproto regard `RETSIGTYPE' as the variable type.
30 cat <<END >prototypes.h
31 typedef void RETSIGTYPE;
32 END
33
34 exec 5>&1 > prototypes.h.tmp
35
36 cat <<END
37 /* This file was generated by cproto. */
38 #if PROTOTYPES /* defined in config.h */
39 #define P_(s) s
40 #else
41 #define P_(s) ()
42 #endif
43
44 END
45
46 cproto $CPROTO_FLAGS $CPPFLAGS $SOURCES |
47         sed -e '/^int main /d' -e 's/dummy__/interrupt/'
48
49 cat <<END
50
51 /* util.c */
52 #if !HAVE_MEMMOVE
53 void *memmove P_((void *dst, const void *src, size_t cnt));
54 #endif
55 #if !HAVE_STRDUP
56 char *strdup P_((const char *buf));
57 #endif
58 #if !HAVE_MEMSET
59 char *memset P_((char *s, int c, size_t n));
60 #endif
61 #if !HAVE_STRCASECMP
62 int strcasecmp P_((const char *p1, const char *p2));
63 #endif
64 #if defined HAVE_DECL_BASENAME && !HAVE_DECL_BASENAME
65 char *basename P_((char *s));
66 #endif
67
68 /* vsnprintf.c */
69 #if !HAVE_VSNPRINTF
70 int vsnprintf P_((char *str, size_t n, const char *fmt, va_list ap));
71 int snprintf P_((char *str, size_t n, char const *fmt, ...));
72 #endif
73
74 #undef P_
75 END
76
77 exec 1>&5
78 if test -f prototypes.h.bak && cmp -s prototypes.h.tmp prototypes.h.bak; then
79   mv -f prototypes.h.bak prototypes.h
80 else
81   mv -f prototypes.h.tmp prototypes.h
82 fi