improve of cmpl.
[bush.git] / builtins / cmpl.sh
blobf8a05a0d9ca7d3971590950e1108aea414dc1abf
2 . ../tools/build-srcpkg/shlib/incfile.shlib
4 . ../tools/build-srcpkg/shlib/cmplib.shlib
6 #. ../build/cmplib.shlib
8 BAKDIR="../../dvar-n-doc/$(date +%Y-%m)"
10 cmd_opt "$@"
13 # =======================================================================
16 INC_PATHS="-I. -I.. -I../src -I../include -I../lib "
17 # INC_PATHS="-I. -I./src -I./include -I./lib -I./builtins"
18 DST_LIST="builtins"
20 OBJDIR_FMT='${OUTDIR}/obj/builtins/'
22 # make[1]: Leaving directory '/mnt/hgfs/workspace/tmp/srcpkg/bush/builtins'
24 SRC_LIST="
25 builtins.c
26 alias.c
27 bind.c
28 break.c
29 builtin.c
30 caller.c
31 cd.c
32 colon.c
33 command.c
34 common.c
35 declare.c
36 echo.c
37 enable.c
38 eval.c
39 evalfile.c
40 evalstring.c
41 exec.c
42 exit.c
43 fc.c
44 fg_bg.c
45 hash.c
46 help.c
47 history.c
48 inlib.c
49 jobs.c
50 kill.c
51 let.c
52 mapfile.c
53 pushd.c
54 read.c
55 reserved.c
56 return.c
57 set.c
58 setattr.c
59 shift.c
60 source.c
61 suspend.c
62 test.c
63 times.c
64 trap.c
65 type.c
66 ulimit.c
67 umask.c
68 wait.c
69 getopts.c
70 shopt.c
71 printf.c
72 getopt.c
73 bushgetopt.c
74 complete.c
76 OBJ_LIST="
79 cmpl_def ()
81 OBJDIR="$(eval echo ${OBJDIR_FMT})"
83 # cd builtins
84 for srcfile in $SRC_LIST; do
85 deffile=${srcfile##*/}
86 deffile="${deffile//\.c/\.def}"
88 [[ ! -f $deffile ]] && continue;
90 if [[ $deffile -nt $srcfile
91 || ! -f $srcfile ]]; then
92 echo def file $deffile build to $srcfile ...
93 mkdir -p $(dirname $srcfile)
94 ./mkbuiltins -D . $deffile
95 [[ $? != 0 ]] && echo "compile(mkbuiltins) ($deffile) failed." && exit -1
97 done
98 # cd -
101 remove_def_c ()
103 OBJDIR="$(eval echo ${OBJDIR_FMT})"
105 for srcfile in $SRC_LIST; do
106 deffile=${srcfile##*/}
107 deffile="${srcfile//\.c/\.def}"
109 [[ ! -f $deffile ]] && continue;
111 echo "append deffile ($deffile) $srcfile"
112 if [[ -f $srcfile ]]; then
113 DEF_C_LIST+=" $srcfile"
115 done
116 rm $DEF_C_LIST -f
119 # mkdir -p .obj/builtins/`dirname alias`
120 # rm -f
121 # ./mkbuiltins -D . alias.def
122 # gcc -c ${CFLAGS} alias.c -o .obj/builtins/alias.o || ( rm -f alias.c ; exit 1 )
123 # rm -f ${SRC_FILE}
125 gcc -DHAVE_CONFIG_H -DSHELL -I. -I.. -I.. -I../src -I../include -I../lib -I. -rdynamic -g -O2 -Wno-parentheses -Wno-format-security mkbuiltins.c -ldl -o mkbuiltins
127 # gcc -DHAVE_CONFIG_H -DSHELL -I. -I.. -I.. -I../src -I../include -I../lib -I. -g -O2 -Wno-parentheses -Wno-format-security mkbuiltins.c
128 # gcc -rdynamic -g -O2 -Wno-parentheses -Wno-format-security -o mkbuiltins mkbuiltins.o
130 ./mkbuiltins -externfile builtext.h -structfile builtins.c -noproduction -D . *.def
132 if [[ $flag_clean != 1 ]]; then
133 build_init
134 update_param
135 # srclist
136 # dirbuild "$@"
137 cmpl_def
138 compile
139 staticlib
140 else
141 build_clean
142 remove_def_c
143 dirbuild "$@"