1#!/bin/sh
2
3#
4# build.sh - build openstep 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] [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_sparc=no
44
45if test x"$1" = "xi386" -o x"$2" = "xi386" -o x"$3" = "xi386" -o x"$4" = "xi386"; then
46  build_i386=yes
47fi
48
49if test x"$1" = "xm68k" -o x"$2" = "xm68k" -o x"$3" = "xm68k" -o x"$4" = "xm68k"; then
50  build_m68k=yes
51fi
52
53if test x"$1" = "xsparc" -o x"$2" = "xsparc" -o x"$3" = "xsparc" -o x"$4" = "xsparc"; then
54  build_sparc=yes
55fi
56
57if test x"$build_i386" = "xno" -a x"$build_m68k" = "xno" -a x"$build_sparc" = "xno"; then
58  echo "At least one platform needs to be selected for the build"
59  echo "Usage: build.sh [i386] [m68k] [sparc]"
60  exit 1
61fi
62
63makedone=no
64single_build=no
65
66mkdir bins
67
68if test x"$build_i386" = "xyes"; then
69  CFLAGS="-arch i386" ./configure -v --host=i386-next-openstep --prefix=/usr/local --disable-nls --without-resid --with-xaw3d --enable-native-tools ac_cv_c_bigendian=no
70  make
71  makedone=yes
72  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 ]
73  then
74    echo Error: One (or more) i386 binaries missing
75    exit 1
76  fi
77  if test x"$build_m68k" = "xyes" -o x"$build_hppa" = "xyes" -o x"$build_sparc" = "xyes"; then
78    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
79    do
80      strip src/$i
81      mv src/$i bins/$i.i386
82    done
83  else
84    single_build=yes
85  fi
86fi
87
88if test x"$build_m68k" = "xyes"; then
89  if test x"$makedone" = "xyes"; then
90    make clean
91  fi
92  CFLAGS="-arch m68k" ./configure -v --host=m68k-next-openstep --prefix=/usr/local -disable-nls --without-resid --with-xaw3d --enable-native-tools ac_cv_c_bigendian=yes
93  make
94  makedone=yes
95  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 ]
96  then
97    echo Error: One (or more) m68k binaries missing
98    exit 1
99  fi
100  if test x"$build_i386" = "xyes" -o x"$build_hppa" = "xyes" -o x"$build_sparc" = "xyes"; then
101    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
102    do
103      strip src/$i
104      mv src/$i bins/$i.m68k
105    done
106  else
107    single_build=yes
108  fi
109fi
110
111if test x"$build_sparc" = "xyes"; then
112  if test x"$makedone" = "xyes"; then
113    make clean
114  fi
115  CFLAGS="-arch sparc" ./configure -v --host=sparc-next-openstep --prefix=/usr/local -disable-nls --without-resid --with-xaw3d --enable-native-tools ac_cv_c_bigendian=yes
116  make
117  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 ]
118  then
119    echo Error: One (or more) sparc binaries missing
120    exit 1
121  fi
122  if test x"$build_i386" = "xyes" -o x"$build_m68k" = "xyes" -o x"$build_hppa" = "xyes"; then
123    for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
124    do
125      strip src/$i
126      mv src/$i bins/$i.sparc
127    done
128  else
129    single_build=yes
130  fi
131fi
132
133if test x"$single_build" = "xno"; then
134
135  for i in x128 x64 xscpu64 x64dtv xcbm2 xcbm5x0 xpet xplus4 xvic c1541 cartconv petcat vsid
136  do
137    binaries=""
138
139    if test x"$build_i386" = "xyes"; then
140        binaries="bins/$i.i386"
141    fi
142
143    if test x"$build_m68k" = "xyes"; then
144        binaries="$binaries bins/$i.m68k"
145    fi
146
147    if test x"$build_sparc" = "xyes"; then
148        binaries="$binaries bins/$i.sparc"
149    fi
150
151    lipo $binaries -output src/$i -create
152
153  done
154fi
155echo "now do a 'gnumake -e prefix=$curdir/VICE-$VICEVERSION/usr/local  VICEDIR=$curdir/VICE-$VICEVERSION/usr/local/lib/vice install'"
156echo "and then a 'make bindistzip' to build the package."
157