OSDN Git Service

updated cproto.sh for PMA
[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         pm2.c
26 '
27
28 test -f prototypes.h && mv -f prototypes.h prototypes.h.bak
29
30 # below makes cproto regard `RETSIGTYPE' as the variable type.
31 cat <<END >prototypes.h
32 typedef void RETSIGTYPE;
33 END
34
35 exec 5>&1 > prototypes.h.tmp
36
37 cat <<END
38 /* This file was generated by cproto. */
39 #if PROTOTYPES /* defined in config.h */
40 #define P_(s) s
41 #else
42 #define P_(s) ()
43 #endif
44
45 END
46
47 cproto $CPROTO_FLAGS $CPPFLAGS $SOURCES |
48         sed -e '/^int main /d' -e 's/dummy__/interrupt/'
49
50 cat <<END
51
52 /* util.c */
53 #if !HAVE_MEMMOVE
54 void *memmove P_((void *dst, const void *src, size_t cnt));
55 #endif
56 #if !HAVE_STRDUP
57 char *strdup P_((const char *buf));
58 #endif
59 #if !HAVE_MEMSET
60 char *memset P_((char *s, int c, size_t n));
61 #endif
62 #if !HAVE_STRCASECMP
63 int strcasecmp P_((const char *p1, const char *p2));
64 #endif
65 #if defined HAVE_DECL_BASENAME && !HAVE_DECL_BASENAME
66 char *basename P_((char *s));
67 #endif
68
69 /* vsnprintf.c */
70 #if !HAVE_VSNPRINTF
71 int vsnprintf P_((char *str, size_t n, const char *fmt, va_list ap));
72 int snprintf P_((char *str, size_t n, char const *fmt, ...));
73 #endif
74
75 #undef P_
76 END
77
78 exec 1>&5
79 if test -f prototypes.h.bak && cmp -s prototypes.h.tmp prototypes.h.bak; then
80   mv -f prototypes.h.bak prototypes.h
81 else
82   mv -f prototypes.h.tmp prototypes.h
83 fi