small fix to remove false gcc-4.9-prerelease warning
[k8jam.git] / 0build_common.sh
blob1520bb62c03c53b8ecf5340b28316ccb3979eae0
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} -DNDEBUG -std=gnu99 -c -o ${BUILDPATH}/obj/$1.o ${CFLAGS} -Isrc ${ADDITIONAL_INCLUDES} $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 srclist="\
59 bjprng
60 builtins
61 command
62 compile
63 dstrings
64 execcmd
65 filent
66 fileunix
67 pathsys
68 expand
69 hash
70 headers
71 hcache
72 jbunpack
73 lists
74 make
75 make1
76 matchglob
77 newstr
78 option
79 parse
80 progress
81 re9
82 rexp
83 rules
84 scan
85 search
86 timestamp
87 variable
88 hdrmacro"
90 echo "building K8Jam..."
92 mkdir -p ${BUILDPATH} 2>/dev/null
93 rm -rf ${BUILDPATH}/* 2>/dev/null
94 mkdir -p ${BUILDPATH}/obj 2>/dev/null
96 mkdir -p ${DESTPATH} 2>/dev/null
97 rm -rf ${DESTPATH}/* 2>/dev/null
99 donativecc "unigen"
100 donativelink "unigen"
101 echo "unigen"
102 ${BUILDPATH}/unigen${EXESFX} ${BUILDPATH}/re9_unicode_mapping.c unidata/UnicodeData.txt
104 donativecc "lemon"
105 donativelink "lemon"
106 echo "Lemon jamgram"
107 tools/yyacc src/jamgram.lemon src/jamgramtab.h src/jamgram.yy
108 ${BUILDPATH}/lemon${EXESFX} -q src/jamgram.lemon
109 #rm ${BUILDPATH}/lemon${EXESFX}
110 docc "jamgram"
112 libobj="${BUILDPATH}/obj/jamgram.o"
113 for srcf in ${srclist}; do
114 docc "${srcf}"
115 libobj="${libobj} ${BUILDPATH}/obj/${srcf}.o"
116 done
118 echo "Ar libjam.a"
119 ${AR} ${BUILDPATH}/obj/libjam.a ${libobj}
120 if [ "z${RANLIB}" != "z" ]; then
121 echo "Ranlib libjam.a"
122 ${RANLIB} ${BUILDPATH}/obj/libjam.a
124 rm -f ${libobj}
126 docc "jam"
128 donativecc "mkjambase"
129 donativelink "mkjambase"
130 echo "preparing Jambase"
131 ${BUILDPATH}/mkjambase${EXESFX} src/jambase.c defaults/Jambase
132 #rm ${BUILDPATH}/mkjambase${EXESFX}
133 docc "jambase"
135 dolink "jam" ${DESTPATH} ${BUILDPATH}/obj/jambase.o ${BUILDPATH}/obj/libjam.a
137 #rm ${BUILDPATH}/obj/* 2>/dev/null
139 echo "K8Jam built"