1#!/bin/sh
2
3#
4# build.sh - build nextstep port of VICE
5#
6# Written by
7#  Marco van den Heuvel <blackystardust68@yahoo.com>
8#
9# This file is part of VICE, the Versatile Commodore Emulator.
10# See README for copyright notice.
11#
12#  This program is free software; you can redistribute it and/or modify
13#  it under the terms of the GNU General Public License as published by
14#  the Free Software Foundation; either version 2 of the License, or
15#  (at your option) any later version.
16#
17#  This program is distributed in the hope that it will be useful,
18#  but WITHOUT ANY WARRANTY; without even the implied warranty of
19#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20#  GNU General Public License for more details.
21#
22#  You should have received a copy of the GNU General Public License
23#  along with this program; if not, write to the Free Software
24#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25#  02111-1307  USA.
26#
27# Usage:     build.sh [i386] [m68k] [hppa] [sparc]
28#
29
30# see if we are in the top of the tree
31if [ ! -f configure.proto ]; then
32  cd ../..
33  if [ ! -f configure.proto ]; then
34    echo "please run this script from the base of the VICE directory"
35    exit 1
36  fi
37fi
38
39curdir=`pwd`
40
41build_i386=no
42build_m68k=no
43build_hppa=no
44build_sparc=no
45
46if test x"$1" = "xi386" -o x"$2" = "xi386" -o x"$3" = "xi386" -o x"$4" = "xi386"; then
47  build_i386=yes
48fi
49
50if test x"$1" = "xm68k" -o x"$2" = "xm68k" -o x"$3" = "xm68k" -o x"$4" = "xm68k"; then
51  build_m68k=yes
52fi
53
54if test x"$1" = "xhppa" -o x"$2" = "xhppa" -o x"$3" = "xhppa" -o x"$4" = "xhppa"; then
55  build_hppa=yes
56fi
57
58if test x"$1" = "xsparc" -o x"$2" = "xsparc" -o x"$3" = "xsparc" -o x"$4" = "xsparc"; then
59  build_sparc=yes
60fi
61
62if test x"$build_i386" = "xno" -a x"$build_m68k" = "xno" -a x"$build_hppa" = "xno" -a x"$build_sparc" = "xno"; then
63  echo "At least one platform needs to be selected for the build"
64  echo "Usage: build.sh [i386] [m68k] [hppa] [sparc]"
65  exit 1
66fi
67
68makedone=no
69single_build=no
70
71rm -f -r bins
72mkdir bins
73
74if test x"$build_i386" = "xyes"; then
75  CFLAGS="-arch i386" ./configure -v --enable-native-tools --host=i386-next-nextstep --prefix=/usr/local -disable-nls --without-resid --with-xaw3d --disable-rs232 ac_cv_c_bigendian=no
76  make
77  makedone=yes
78  if [ ! -e src/x64 -o ! -e src/xscpu64 -o ! -e src/x64dtv -o ! -e src/x128 -o ! -e src/xvic -o ! -e src/xpet -o ! -e src/xplus4 -o ! -e src/xcbm2 -o ! -e src/xcbm5x0 -o ! -e src/c1541 -o ! -e src/petcat -o ! -e src/cartconv -o ! -e src/vsid ]
79  then
80    echo Error: One \(or more\) i386 binaries missing
81    exit 1
82  fi
83  if test x"$build_m68k" = "xyes" -o x"$build_hppa" = "xyes" -o x"$build_sparc" = "xyes"; then
84    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
85    do
86      strip src/$i
87      mv src/$i bins/$i.i386
88    done
89  else
90    single_build=yes
91  fi
92fi
93
94if test x"$build_m68k" = "xyes"; then
95  if test x"$makedone" = "xyes"; then
96    make clean
97  fi
98  CFLAGS="-arch m68k" ./configure -v --enable-native-tools --host=m68k-next-nextstep --prefix=/usr/local -disable-nls --without-resid --with-xaw3d --disable-rs232 ac_cv_c_bigendian=yes
99  make
100  makedone=yes
101  if [ ! -e src/x64 -o ! -e src/xscpu64 -o ! -e src/x64dtv -o ! -e src/x128 -o ! -e src/xvic -o ! -e src/xpet -o ! -e src/xplus4 -o ! -e src/xcbm2 -o ! -e src/xcbm5x0 -o ! -e src/c1541 -o ! -e src/petcat -o ! -e src/cartconv -o ! -e src/vsid ]
102  then
103    echo Error: One \(or more\) m68k binaries missing
104    exit 1
105  fi
106  if test x"$build_i386" = "xyes" -o x"$build_hppa" = "xyes" -o x"$build_sparc" = "xyes"; then
107    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
108    do
109      strip src/$i
110      mv src/$i bins/$i.m68k
111    done
112  else
113    single_build=yes
114  fi
115fi
116
117if test x"$build_hppa" = "xyes"; then
118  if test x"$makedone" = "xyes"; then
119    make clean
120  fi
121  CFLAGS="-arch hppa" ./configure -v --enable-native-tools --host=hppa-next-nextstep --prefix=/usr/local -disable-nls --without-resid --with-xaw3d --disable-rs232 ac_cv_c_bigendian=yes
122  make
123  makedone=yes
124  if [ ! -e src/x64 -o ! -e src/xscpu64 -o ! -e src/x64dtv -o ! -e src/x128 -o ! -e src/xvic -o ! -e src/xpet -o ! -e src/xplus4 -o ! -e src/xcbm2 -o ! -e src/xcbm5x0 -o ! -e src/c1541 -o ! -e src/petcat -o ! -e src/cartconv -o ! -e src/vsid ]
125  then
126    echo Error: One \(or more\) hppa binaries missing
127    exit 1
128  fi
129  if test x"$build_i386" = "xyes" -o x"$build_m68k" = "xyes" -o x"$build_sparc" = "xyes"; then
130    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
131    do
132      strip src/$i
133      mv src/$i bins/$i.hppa
134    done
135  else
136    single_build=yes
137  fi
138fi
139
140if test x"$build_sparc" = "xyes"; then
141  if test x"$makedone" = "xyes"; then
142    make clean
143  fi
144  CFLAGS="-arch sparc" ./configure -v --enable-native-tools --host=sparc-next-nextstep --prefix=/usr/local -disable-nls --without-resid --with-xaw3d --disable-rs232 ac_cv_c_bigendian=yes
145  make
146  if [ ! -e src/x64 -o ! -e src/xscpu64 -o ! -e src/x64dtv -o ! -e src/x128 -o ! -e src/xvic -o ! -e src/xpet -o ! -e src/xplus4 -o ! -e src/xcbm2 -o ! -e src/xcbm5x0 -o ! -e src/c1541 -o ! -e src/petcat -o ! -e src/cartconv -o ! -e src/vsid ]
147  then
148    echo Error: One \(or more\) sparc binaries missing
149    exit 1
150  fi
151  if test x"$build_i386" = "xyes" -o x"$build_m68k" = "xyes" -o x"$build_hppa" = "xyes"; then
152    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
153    do
154      strip src/$i
155      mv src/$i bins/$i.sparc
156    done
157  else
158    single_build=yes
159  fi
160fi
161
162if test x"$single_build" = "xno"; then
163
164  for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
165  do
166    binaries=""
167
168    if test x"$build_i386" = "xyes"; then
169        binaries="bins/$i.i386"
170    fi
171
172    if test x"$build_m68k" = "xyes"; then
173        binaries="$binaries bins/$i.m68k"
174    fi
175
176    if test x"$build_hppa" = "xyes"; then
177        binaries="$binaries bins/$i.hppa"
178    fi
179
180    if test x"$build_sparc" = "xyes"; then
181        binaries="$binaries bins/$i.sparc"
182    fi
183
184    lipo $binaries -output src/$i -create
185
186  done
187fi
188echo "now do a 'gnumake -e prefix=$curdir/VICE-$VICEVERSION/usr/local  VICEDIR=$curdir/VICE-$VICEVERSION/usr/local/lib/vice install'"
189echo "and then a 'make bindistzip' to build the package."
190