# mktab.sh, 13 Aug 03
#
# Extract data from various files (generated by ngram)
# needed for C construct frequency tables

source ../config.files

#GEN_DATA=1

if [ $GEN_DATA == 1 ]; then
   gzcat $PP_DIR/*$C_DIRECT_SUFF | awk -f numincl.awk > $LOC_DIA_DIR/all.incl.cnt
   gzcat $PP_DIR/*$H_DIRECT_SUFF | awk -f numincl.awk > $LOC_DIA_DIR/all.h.incl.cnt
   fi
awk -v D_FILE="stdhdrh.d" -f $EXTRTWOCOLS < $LOC_DIA_DIR/all.h.incl.cnt > $LOC_TAB_DIR/stdhdrh.h
echo "END_DOT_H" >> $LOC_TAB_DIR/stdhdrh.h
awk -v D_FILE="stdhdrh.d" -f $EXTRTWOCOLS < $LOC_DIA_DIR/all.incl.cnt > $LOC_TAB_DIR/stdhdrh.c
cat $LOC_TAB_DIR/stdhdrh.h $LOC_TAB_DIR/stdhdrh.c | $MERGETWOCOL | $SORTLASTCOL | $MKTWOCOL > $GLOB_TAB_DIR/stdhdrh

gzcat $PP_DIR/*$C_DIRECT_SUFF | awk -f undef.awk | awk -f undeftab.awk | $SORTLASTCOL > $GLOB_TAB_DIR/undef_seq
gzcat $PP_DIR/*$C_BODY_SUFF | awk -f hash.awk  | awk -f hashtab.awk | $SORTLASTCOL > $GLOB_TAB_DIR/hashhash
gzcat $PP_DIR/*$C_BODY_SUFF | awk -f defbody.awk | awk -f commondef.awk > $GLOB_TAB_DIR/def_rep_list
gzcat $PP_DIR/*$C_DIRECT_SUFF | awk -f includehdr.awk > $GLOB_TAB_DIR/include_hdr

echo "ppiswcntrl"
if [ $GEN_DATA == 1 ]; then
   ppcntrl.sh
   fi
awk -v KEY_TOK="#IF" -f $PPISWCNTRL < $PPALLCNTRL_LINES > $GLOB_TAB_DIR/ppif_cntrl
awk -v KEY_TOK="#ELIF" -f $PPISWCNTRL < $PPALLCNTRL_LINES > $GLOB_TAB_DIR/ppelif_cntrl

awk -f defined.awk < $PPALLCNTRL_LINES > $GLOB_TAB_DIR/defined

awk -f directopid.awk < $H_CNT_FILE > $LOC_TAB_DIR/direct_name.h
echo "END_DOT_H" >> $LOC_TAB_DIR/direct_name.h
awk -f directopid.awk < $C_CNT_FILE > $LOC_TAB_DIR/direct_name.c
cat $LOC_TAB_DIR/direct_name.h $LOC_TAB_DIR/direct_name.c | $MERGETWOCOL  | $SORTLASTCOL | $MKTWOCOL > $GLOB_TAB_DIR/direct_name

#rm $TEMP_FILE
