improve of cmpl.
[bush.git] / cmpl.cmd.sh
blob7fe8fdbfb338d18b1ae59ac79d71abb2fdadfaf8
2 . tools/build-srcpkg/shlib/incfile.shlib
4 inc tools/build-srcpkg/shlib/cmplib.shlib
6 # inc tools/build-srcpkg/build.shlib
8 SRCBAK_DIR="../../dvar-n-doc/$(date +%Y-%m)"
10 cmd_opt "$@"
12 scriptversion=v0.1.0-231025
14 version="cmpl.sh $scriptversion
16 Copyright 2020 Free Software Foundation, Inc.
17 There is NO warranty. You may redistribute this software
18 under the terms of the GNU General Public License.
19 For more information about these matters, see the files named COPYING."
21 usage="Usage: $prog [OPTION]
23 It's a file of compile.
24 https://repo.or.cz/devutils.git
26 Options:
27 -f force to re-compile again even if code is compiled before.
28 -v version info.
29 -h help info.
31 sub-cmd:
32 clean clean output files.
33 bak clean and backup a tarball in the upper dir.
35 --help display help info in detail.
36 --version display version information in detail.
38 Simple example:
39 $ $prog -f
40 $ $prog
41 $ $prog clean
42 $ $prog bak
44 Email bug reports or enhancement requests to skeletone@126.com .
48 # ***********************************************************
49 # * *
50 # * GNU bush, version 5.1.0(1)-release (i686-pc-linux-gnu) *
51 # * *
52 # ***********************************************************
55 ###################################################################################
56 # generate signames, and compile
57 ###################################################################################
59 EXEEXT=
61 # g_bushversion
62 gen_version_h ()
65 # version.h
68 /bin/sh ./support/mkversion.sh -b -S . -s release -d 5.1 -o src/newversion.h \
69 && mv src/newversion.h src/version.h
71 MACRO_DEF=" -DPROGRAM=\"bush\" -DCONF_HOSTTYPE=\"i686\" -DCONF_OSTYPE=\"linux-gnu\" -DCONF_MACHTYPE=\"i686-pc-linux-gnu\" -DCONF_VENDOR=\"pc\" -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"bush\" -DSHELL -DHAVE_CONFIG_H "
72 #MACRO_DEF=" -DPROGRAM='\"bush\"' -DCONF_HOSTTYPE='\"i686\"' -DCONF_OSTYPE='\"linux-gnu\"' -DCONF_MACHTYPE='\"i686-pc-linux-gnu\"' -DCONF_VENDOR='\"pc\"' -DLOCALEDIR='\"/usr/local/share/locale\"' -DPACKAGE='\"bush\"' -DSHELL -DHAVE_CONFIG_H "
73 INC_PATHS=" -I. -I. -I./include -I./src -I./lib "
74 MISC_CFLAGS="-g -O2 -Wno-parentheses -Wno-format-security"
76 update_param
78 echo "gcc ${CFLAGS} -DBUILDTOOL -c -o buildversion.o ./src/version.c"
79 gcc ${CFLAGS} -DBUILDTOOL -c -o buildversion.o ./src/version.c
80 echo "gcc ${CFLAGS} -o bushversion ./support/bushversion.c buildversion.o "
81 gcc ${CFLAGS} -o bushversion ./support/bushversion.c buildversion.o
83 VERSPROG=./bushversion
85 ./bushversion -l
87 PatchLevel="`${VERSPROG} -p`"
88 sed -e "s%!PATCHLEVEL%${PatchLevel}%" \
89 support/bushbug.sh > bushbug
90 chmod a+rx bushbug
93 # g_gen_y_tab_c
94 gen_gmr_y_tab_c ()
97 # gen y.tab.c/h by bison
99 YACC="bison"
100 if [[ ! -f src/lxrgmr/y.tab.c || src/lxrgmr/parse.y -nt src/lxrgmr/y.tab.c ]]; then
101 ${YACC} -d src/lxrgmr/parse.y -o src/lxrgmr/y.tab.c
105 g_mkbuiltins ()
108 # mkbultins & gen builtins.c
109 # this step is putted in builtins/cmpl.sh
111 if false; then
112 gcc -c -DHAVE_CONFIG_H -DSHELL -I. -I.. -I.. -I../src -I../include -I../lib -I. -g -O2 -Wno-parentheses -Wno-format-security mkbuiltins.c
113 gcc -rdynamic -g -O2 -Wno-parentheses -Wno-format-security -rdynamic -g -O2 -Wno-parentheses -Wno-format-security -o mkbuiltins mkbuiltins.o -ldl
114 ./mkbuiltins -externfile builtext.h -structfile builtins.c \
115 -noproduction -D . ./alias.def ./bind.def ./break.def ./builtin.def ./caller.def ./cd.def ./colon.def ./command.def ./declare.def ./echo.def ./enable.def ./eval.def ./getopts.def ./exec.def ./exit.def ./fc.def ./fg_bg.def ./hash.def ./help.def ./history.def ./jobs.def ./kill.def ./let.def ./read.def ./return.def ./set.def ./setattr.def ./shift.def ./source.def ./suspend.def ./test.def ./times.def ./trap.def ./type.def ./ulimit.def ./umask.def ./wait.def ./reserved.def ./pushd.def ./shopt.def ./printf.def ./complete.def ./mapfile.def
119 g_mksignames ()
122 # mksignames & gen signames.h
125 MACRO_DEF=" -DPROGRAM=\"bush\" -DCONF_HOSTTYPE=\"i686\" -DCONF_OSTYPE=\"linux-gnu\" -DCONF_MACHTYPE=\"i686-pc-linux-gnu\" -DCONF_VENDOR=\"pc\" -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"bush\" -DSHELL -DHAVE_CONFIG_H "
126 INC_PATHS=" -I. -I. -I./include -I./src -I./lib "
127 MISC_CFLAGS="-g -O2 -Wno-parentheses -Wno-format-security"
129 update_param
131 rm -f mksignames.o
132 echo gcc ${CFLAGS} -DBUILDTOOL -c ./support/mksignames.c
133 gcc ${CFLAGS} -DBUILDTOOL -c ./support/mksignames.c
135 rm -f buildsignames.o
136 echo gcc ${CFLAGS} -DBUILDTOOL -c ./support/mksignames.c -o buildsignames.o
137 gcc ${CFLAGS} -DBUILDTOOL -c ./support/signames.c -o buildsignames.o
139 rm -f mksignames
140 echo gcc ${CFLAGS} -rdynamic -o mksignames mksignames.o buildsignames.o
141 gcc ${CFLAGS} -rdynamic -o mksignames mksignames.o buildsignames.o
144 rm -f src/lsignames.h
145 ./mksignames src/lsignames.h
146 if cmp -s src/lsignames.h src/signames.h ; then
148 else
149 rm -f src/signames.h ;
150 cp src/lsignames.h src/signames.h ;
154 g_mksyntax ()
157 # mksyntax
159 rm -f mksyntax
160 echo gcc ${CFLAGS} -DBUILDTOOL -rdynamic -o mksyntax mksyntax.c
161 gcc ${CFLAGS} -DBUILDTOOL -rdynamic -o mksyntax mksyntax.c
163 ./mksyntax${EXEEXT} -o src/syntax.c
166 gen_pathnames_h ()
168 prefix="/usr/local"
169 datarootdir="${prefix}/share"
170 datadir="${datarootdir}"
171 DEBUGGER_START_FILE="${datadir}/bushdb/bushdb-main.inc"
174 # src/pathnames.h
176 sed -e 's|@DEBUGGER_START_FILE\@|${DEBUGGER_START_FILE}|g' src/pathnames.h.in > pathnames.tmp
177 if test -f src/pathnames.h; then
178 cmp -s pathnames.tmp src/pathnames.h || mv pathnames.tmp src/pathnames.h;
179 else
180 mv pathnames.tmp src/pathnames.h;
182 rm pathnames.tmp
185 gen_pipesize_h ()
188 # build psize.aux for pipesize.h
191 # INC_PATHS="-I. -I.. -I.. -I../src -I../include -I../lib -I."
192 INC_PATHS="-I. -I../ -I../src -I../include -I../lib -I../builtins"
193 DST_LIST="builtins"
195 update_param
197 cd builtins
198 rm psize.aux pipesize.h -f
199 echo gcc ${CFLAGS} -o psize.aux ./psize.c
200 gcc ${CFLAGS} -o psize.aux ./psize.c
201 echo get pipe size ...
202 /bin/sh ./psize.sh > pipesize.h
203 cd -
206 banner_info ()
208 echo
209 echo " ***********************************************************"
210 echo " * *"
211 echo " * `${VERSPROG} -l` *"
212 echo " * *"
213 echo " ***********************************************************"
214 echo
217 misc_build ()
219 gen_version_h
220 gen_gmr_y_tab_c
222 g_mkbuiltins
223 g_mksignames
224 g_mksyntax
226 gen_pathnames_h
227 gen_pipesize_h
229 banner_info
232 g_misc_build ()
234 g_bushversion
235 g_gen_y_tab_c
237 g_mkbuiltins
238 g_mksignames
239 g_mksyntax
241 g_gen_pathnames_h
242 g_gen_pipesize_h
244 g_build_banner_info
248 ###################################################################################
249 # compile dir of 'src'.
250 ###################################################################################
252 src_param_init ()
254 OBJ_FILE="output/obj/src/lxrgmr/y.tab.o"
255 SRC_FILE="src/lxrgmr/y.tab.c"
257 MACRO_DEF=" -DPROGRAM=\"bush\" -DCONF_HOSTTYPE=\"i686\" -DCONF_OSTYPE=\"linux-gnu\" -DCONF_MACHTYPE=\"i686-pc-linux-gnu\" -DCONF_VENDOR=\"pc\" -DLOCALEDIR=\"/usr/local/share/locale\" -DPACKAGE=\"bush\" -DSHELL -DHAVE_CONFIG_H "
258 INC_PATHS=" -I. -I. -I./include -I./src -I./lib "
259 MISC_CFLAGS=" -g -O2 -Wno-parentheses -Wno-format-security"
260 MISC_LDFLAGS=" -rdynamic -g -O2 -Wno-parentheses -Wno-format-security "
261 #"-g -O2 -Wno-parentheses -Wno-format-security"
262 #"-rdynamic -g -O2 -Wno-parentheses -Wno-format-security"
264 INC_LIBS=" -ltermcap -ldl "
266 DST_LIST="bush"
269 # subdir built into a .a static lib, and append its name to STATIC_LIBS
270 # pay attenssion on the sequence of subdir, it generate different sequence of
271 # -lxxx parameter.
273 SUB_SRCDIR_LIST="
274 builtins
275 lib/glob
276 lib/sh
277 lib/readline
278 lib/tilde
279 lib/malloc
282 # lib/intl
283 # lib/termcap
284 # lib/tilde
286 SRC_LIST="
287 src/shell.c
288 src/runner/eval.c
289 src/lxrgmr/y.tab.c
290 src/general.c
291 src/lxrgmr/make_cmd.c
292 src/runner/print_cmd.c
293 src/lxrgmr/dispose_cmd.c
294 src/runner/execute_cmd.c
295 src/var/variables.c
296 src/lxrgmr/copy_cmd.c
297 src/error.c
298 src/runner/expr.c
299 src/flags.c
300 src/jobs.c
301 src/lxrgmr/subst.c
302 src/hashcmd.c
303 src/hashlib.c
304 src/mailcheck.c
305 src/trap.c
306 src/input/input.c
307 src/runner/unwind_prot.c
308 src/impl/pathexp.c
309 src/sig.c
310 src/test.c
311 src/version.c
312 src/impl/alias.c
313 src/var/array.c
314 src/var/arrayfunc.c
315 src/var/assoc.c
316 src/lxrgmr/braces.c
317 src/bracecomp.c
318 src/bushhist.c
319 src/input/bushline.c
320 src/list.c
321 src/impl/stringlib.c
322 src/locale.c
323 src/impl/findcmd.c
324 src/redir.c
325 src/pcomplete.c
326 src/pcomplib.c
327 src/syntax.c
328 src/xmalloc.c
330 OBJ_LIST="
334 if [[ $flag_clean != 1 ]]; then
335 dbgout_opt+=",inc_info"
336 #misc_build
337 # g_misc_build
338 src_param_init
339 build_init
340 update_param
341 # srclist
343 echo oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
345 dirbuild "$@"
346 compile
347 link
348 # link > link.txt 2>&1
349 else
350 build_clean
351 dirbuild "$@"