cosmetics in Jambase
[k8jam.git] / 0build_common.sh
blob633553123438a1294bf63590a2c749e2988e0953
1 #!/bin/sh
4 # $1: file w/o extension
5 # $2: src path (optional)
6 docc() {
7 ptmp="$2"
8 echo "Cc $1.c"
9 if [ "z$ptmp" = "z" ]; then
10 ptmp="src"
12 ${CC} -c -o ${BUILDPATH}/obj/$1.o ${CFLAGS} -Isrc -I${BUILDPATH} $ptmp/$1.c
16 # $1: file w/o extension
17 # $2: dst path (optional)
18 # $3: liblist
19 dolink() {
20 fname="$1"
21 ptmp="$2"
22 shift
23 echo "Link ${fname}"
24 if [ "z$ptmp" = "z" ]; then
25 ptmp="${BUILDPATH}"
26 else
27 shift
29 ${LINK} ${LINKFLAGS} -o $ptmp/${fname}${EXESFX} ${BUILDPATH}/obj/${fname}.o $* ${LINKLIBS}
30 if [ "z$WINE" != "z" ]; then
31 chmod 711 $ptmp/${fname}${EXESFX}
36 donativecc() {
37 OCC="$CC"
38 CC=gcc
39 docc $*
40 CC="$OCC"
44 donativelink() {
45 OLINK="$LINK"
46 OLINKFLAGS="$LINKFLAGS"
47 OLINKLIBS="$LINKLIBS"
48 LINK=gcc
49 LINKFLAGS=-s
50 LINKLIBS=""
51 dolink $*
52 LINK="$OLINK"
53 LINKFLAGS="$OLINKFLAGS"
54 LINKLIBS="$OLINKLIBS"
58 have_yacc="tan"
59 yacc -h >/dev/null 2>&1
60 if test "$?" = "127"; then
61 echo "WARNING: YACC/Bison not found!"
62 have_yacc="ona"
64 #have_yacc="ona"
67 srclist="\
68 builtins
69 command
70 compile
71 execcmd
72 filent
73 fileunix
74 pathsys
75 expand
76 hash
77 headers
78 hcache
79 lists
80 make
81 make1
82 matchglob
83 newstr
84 option
85 parse
86 progress
87 hsregexp
88 rules
89 scan
90 search
91 timestamp
92 variable
93 hdrmacro
94 kstrings"
96 echo "building K8Jam..."
98 mkdir -p ${BUILDPATH} 2>/dev/null
99 rm -rf ${BUILDPATH}/* 2>/dev/null
100 mkdir -p ${BUILDPATH}/obj 2>/dev/null
102 mkdir -p ${DESTPATH} 2>/dev/null
103 rm -rf ${DESTPATH}/* 2>/dev/null
105 if [ "$have_yacc" = "tan" ]; then
106 echo "Yacc jamgram"
107 tools/yyacc ${BUILDPATH}/jamgram.y ${BUILDPATH}/jamgramtab.h src/jamgram.yy
108 yacc -d ${BUILDPATH}/jamgram.y
109 mv -f y.tab.c ${BUILDPATH}/jamgram.c
110 mv -f y.tab.h ${BUILDPATH}/jamgram.h
111 else
112 echo "Using pregenerated jamgram"
113 cp src/jamgram_poorman/* ${BUILDPATH}/
115 docc "jamgram" ${BUILDPATH}
117 donativecc "unigen"
118 donativelink "unigen"
119 echo "unigen"
120 ${BUILDPATH}/unigen${EXESFX} ${BUILDPATH}/hsregexp_unicode_mapping.c unidata/UnicodeData.txt
122 libobj="${BUILDPATH}/obj/jamgram.o"
123 for srcf in ${srclist}; do
124 docc "${srcf}"
125 libobj="${libobj} ${BUILDPATH}/obj/${srcf}.o"
126 done
128 echo "Ar libjam.a"
129 ${AR} ${BUILDPATH}/obj/libjam.a ${libobj}
131 echo "Ranlib libjam.a"
132 ${RANLIB} ${BUILDPATH}/obj/libjam.a
133 rm -f ${libobj}
135 docc "jam"
137 donativecc "mkjambase"
138 donativelink "mkjambase"
139 echo "preparing Jambase"
140 ${BUILDPATH}/mkjambase${EXESFX} ${BUILDPATH}/jambase.c defaults/Jambase
141 docc "jambase" ${BUILDPATH}
143 dolink "jam" ${DESTPATH} ${BUILDPATH}/obj/jambase.o ${BUILDPATH}/obj/libjam.a
145 #rm ${BUILDPATH}/obj/* 2>/dev/null
147 echo "K8Jam built"