improve of cmpl.
[bush.git] / build / shlib / pre_build.shlib
blob01277a91ff03c0c071c02d4060643e419666faea
2 ###################################################################################
3 # generate signames, and compile
4 ###################################################################################
7 banner_info ()
9         echo
10         echo "    ***********************************************************"
11         echo "    *                                                         *"
12         echo "    * `${VERSPROG} -l` *"
13         echo "    *                                                         *"
14         echo "    ***********************************************************"
15         echo
18 version_update ()
20         local cmpl_ver=
21         local inc_build=y
22         
23         if [ -r ${OUTDIR}/ver.build ]; then
24                 cmpl_ver=`cat ${OUTDIR}/ver.build`
25         fi
26         if [ -z "$cmpl_ver" ]; then
27                 cmpl_ver=0
28         fi
30         # increment the build version if that's what's required
32         if [ -n "$inc_build" ]; then
33                 cmpl_ver=`expr 1 + $cmpl_ver`
34         fi
35         
36         if [ -n "$inc_build" ]; then
37                 # Make sure we can write to ${OUTDIR}/ver.build
38                 if [ -f ${OUTDIR}/ver.build ] && [ ! -w ${OUTDIR}/ver.build ]; then
39                         echo "$PROGNAME: cannot write to ${OUTDIR}/ver.build, not incrementing build version" >&2
40                 else
41                         echo "$cmpl_ver" > ${OUTDIR}/ver.build
42                 fi
43         fi
46 step_hostutils_prev_init ()
48         # gen_version_h
49 #       /bin/sh tools/mkversion.sh -b -S . -s release -d 5.1 -o ${GENCODE_DIR}/inc/newversion.h \
50 #               && mv ${GENCODE_DIR}/inc/newversion.h ${GENCODE_DIR}/inc/version.h
51         echo " ver2h ============================>"
52         
53         ftpchk doc/VERSION ${GENCODE_DIR}/inc/version.h
54         if test ! -f build/version.h.in -a $? = 0 ; then
55                 echo " [AUTOGEN] doc/VERSION => version.h"
56                 ver2h
57         fi
58         version_update
60         ftpchk ${OUTDIR}/config.imi ${GENCODE_DIR}/inc/config.h
61         if test ! -f build/config.h.in -a -f ${OUTDIR}/config.imi -a $? = 0 ; then
62                 echo " [AUTOGEN] config.imi => config.h"
63                 cfg2h
64         fi
66         tmpl2file
69 step_hostutils_post_init ()
71         local flag=0
73         # gen_version_h
74         VERSPROG=$OUTDIR/bushversion
75         $OUTDIR/bushversion -l
77         ftpchk support/bushbug.sh ${OUTDIR}/bushbug
78         if [[ $? == 0 ]]; then
79                 echo " [AUTOGEN] bushbug"
80                 PatchLevel="`${VERSPROG} -p`"
81                 sed -e "s%!PATCHLEVEL%${PatchLevel}%" \
82                                  support/bushbug.sh > ${OUTDIR}/bushbug
83                 chmod a+rx ${OUTDIR}/bushbug
84         fi
86         # mkbuiltins
87         for file in `ls -1 builtins/*.def`; do
88                 test "$file" -nt "${GENCODE_DIR}/inc/builtext.h" -o "$file" -nt "${GENCODE_DIR}/src/builtins.c" && 
89                         flag=1 && echo "file $file is modified." && break
90         done
91         if test ! -f "${GENCODE_DIR}/inc/builtext.h" -o ! -f "${GENCODE_DIR}/src/builtins.c" -o flag = 1 ; then
92                 echo " [AUTOGEN] builtins/*.def => ${GENCODE_DIR}/{src/builtins.c,inc/builtext.h}"
93                 $OUTDIR/mkbuiltins -externfile ${GENCODE_DIR}/inc/builtext.h -structfile ${GENCODE_DIR}/src/builtins.c -noproduction -D . builtins/*.def
94                 flag=0
95         fi
97         # mksignames
98         $OUTDIR/mksignames ${GENCODE_DIR}/inc/lsignames.h
99         if cmp -s ${GENCODE_DIR}/inc/lsignames.h ${GENCODE_DIR}/inc/signames.h ; then
100                 :;
101         else
102                 echo " [AUTOGEN] ${GENCODE_DIR}/inc/signames.h"
103                 rm -f ${GENCODE_DIR}/inc/signames.h ;
104                 cp ${GENCODE_DIR}/inc/lsignames.h ${GENCODE_DIR}/inc/signames.h ;
105         fi
107         # g_mksyntax
108         if test ! -f "${GENCODE_DIR}/inc/pipesize.h" ; then
109                 echo " [AUTOGEN] ${GENCODE_DIR}/src/syntax.c"
110                 $OUTDIR/mksyntax${EXEEXT} -o ${GENCODE_DIR}/src/syntax.c
111         fi
113         # gen_pathnames_h
114         prefix="/usr/local"
115         datarootdir="${prefix}/share"
116         datadir="${datarootdir}"
117         DEBUGGER_START_FILE="${datadir}/bushdb/bushdb-main.inc"
118         
119         #
120         # src/pathnames.h
121         #
122         ftpchk src/pathnames.h.in ${GENCODE_DIR}/inc/pathnames.h
123         if test $? = 0 ; then
124                 echo " [AUTOGEN] ${GENCODE_DIR}/inc/pathnames.h"
125                 sed -e 's|@DEBUGGER_START_FILE\@|${DEBUGGER_START_FILE}|g' src/pathnames.h.in > ${GENCODE_DIR}/inc/pathnames.tmp
126                 if test -f ${GENCODE_DIR}/inc/pathnames.h; then
127                         cmp -s ${GENCODE_DIR}/inc/pathnames.tmp ${GENCODE_DIR}/inc/pathnames.h || mv ${GENCODE_DIR}/inc/pathnames.tmp ${GENCODE_DIR}/inc/pathnames.h;
128                 else
129                         mv ${GENCODE_DIR}/inc/pathnames.tmp ${GENCODE_DIR}/inc/pathnames.h;
130                 fi
131                 rm -f ${GENCODE_DIR}/inc/pathnames.tmp
132         fi
133         
134         # gen_pipesize_h
135         if test ! -f "${GENCODE_DIR}/inc/pipesize.h" ; then
136                 echo " [AUTOGEN] ${GENCODE_DIR}/inc/pipesize.h"
137                 /bin/sh builtins/psize.sh > ${GENCODE_DIR}/inc/tmp_pipesize.h
138                 cmp -s ${GENCODE_DIR}/inc/tmp_pipesize.h ${GENCODE_DIR}/inc/pipesize.h || mv ${GENCODE_DIR}/inc/tmp_pipesize.h ${GENCODE_DIR}/inc/pipesize.h
139                 rm -f ${GENCODE_DIR}/inc/tmp_pipesize.h
140         fi
142         # banner_info
143         banner_info