|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# Run this script as root to configure, compile and install |
| 5 | +# gnustep-make, gnustep-base, gnustep-corebase, gnustep-gui, |
| 6 | +# opal, and the opal gnustep-back backend |
| 7 | +# with a single command |
| 8 | +# |
| 9 | +# Examples: |
| 10 | +# |
| 11 | +# ./compile-all |
| 12 | +# |
| 13 | +# <uses `--prefix=/usr/GNUstep' as option to configure> |
| 14 | +# |
| 15 | +# ./compile-all /usr/local/GNUstep |
| 16 | +# |
| 17 | +# <uses `--prefix=/usr/local/GNUstep' as option to configure> |
| 18 | +# |
| 19 | + |
| 20 | +CPUS=`nproc` |
| 21 | +SUDO='sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH' |
| 22 | +KERNEL=`uname -s | awk '{print tolower($0)}'` |
| 23 | +scriptsdir="`pwd`/tools-scripts" |
| 24 | + |
| 25 | +if [ "$1" != "" ]; then |
| 26 | + prefix="$1" |
| 27 | +else |
| 28 | + prefix="/usr/GNUstep" |
| 29 | +fi |
| 30 | + |
| 31 | +if [ "$2" != "" ]; then |
| 32 | + compiler="$2" |
| 33 | +fi |
| 34 | + |
| 35 | +if [ "$3" != "" ]; then |
| 36 | + cxxcompiler="$3" |
| 37 | +fi |
| 38 | + |
| 39 | +if [ "$4" != "" ]; then |
| 40 | + linker=$4 |
| 41 | +fi |
| 42 | + |
| 43 | + |
| 44 | +# Check if we are compiling under windows... |
| 45 | +UNAME=`uname | cut -d'-' -f1` |
| 46 | +if [ "$UNAME" != "MINGW32_NT" ] ; then |
| 47 | + if [ ! \( -d $prefix -a -w $prefix \) ] ; then |
| 48 | + if [ ! \( -d $(basename $prefix) -a -w $(basename $prefix) \) ] ; then |
| 49 | + NEEDSROOT="true" |
| 50 | + fi |
| 51 | + fi |
| 52 | +fi |
| 53 | + |
| 54 | +# Get architecture |
| 55 | +ARCH=`uname -m` |
| 56 | + |
| 57 | +# If we are installing into home, then we do not need root... |
| 58 | +if |
| 59 | + echo $prefix | grep "^/home/" |
| 60 | +then |
| 61 | + unset NEEDSROOT |
| 62 | + make_flags="--disable-importing-config-file" |
| 63 | +fi |
| 64 | + |
| 65 | +if gmake -v >/dev/null 2>&1 |
| 66 | +then |
| 67 | + export MAKE="gmake -j${CPUS}" |
| 68 | +else |
| 69 | + export MAKE="make -j${CPUS}" |
| 70 | +fi |
| 71 | + |
| 72 | +if [ "$2" == "" ]; then |
| 73 | + export CC=gcc |
| 74 | +else |
| 75 | + export CC="$compiler" |
| 76 | +fi |
| 77 | + |
| 78 | +if [ "$3" == "" ]; then |
| 79 | + export CXX=g++ |
| 80 | +else |
| 81 | + export CXX=$cxxcompiler |
| 82 | +fi |
| 83 | + |
| 84 | +if [[ "$CC" == gcc* ]]; then |
| 85 | + USING_GCC=true |
| 86 | +else |
| 87 | + USING_GCC=false |
| 88 | +fi |
| 89 | + |
| 90 | +if [ "$4" == "" ]; then |
| 91 | + if ! $USING_GCC; then |
| 92 | + linker=ld.gold |
| 93 | + fi |
| 94 | +else |
| 95 | + LD=$(which "$linker") |
| 96 | + if $USING_GCC; then |
| 97 | + # We must create a directory and symlink the linker into there. |
| 98 | + mkdir temp_linker_dir |
| 99 | + cd temp_linker_dir |
| 100 | + ln -s "$LD" ./ld |
| 101 | + cd .. |
| 102 | + export LDFLAGS="$LDFLAGS -B$(realpath temp_linker_dir)" |
| 103 | + else |
| 104 | + # Clang allows constructions such as -fuse-ld=/usr/bin/ld.lld-18 |
| 105 | + export LDFLAGS="$LDFLAGS -fuse-ld=$LD" |
| 106 | + fi |
| 107 | +fi |
| 108 | +echo "==== compile-all" |
| 109 | +echo "Using compiler $CC" |
| 110 | +echo "Using c++ compiler $CXX" |
| 111 | +if [ "$4" == "" ]; then |
| 112 | + echo "Using default linker" |
| 113 | +else |
| 114 | + echo "Using linker $LD" |
| 115 | +fi |
| 116 | +echo "====" |
| 117 | + |
| 118 | +# Flags for windows build. |
| 119 | +if [ "$UNAME" == "MINGW32_NT" ] ; then |
| 120 | + export cc_flags="-fstrict-aliasing -fno-omit-frame-pointer" |
| 121 | +fi |
| 122 | + |
| 123 | +# If we are building with clang, then add this to cc_flags |
| 124 | +if ! $USING_GCC; then |
| 125 | + export cc_flags="-fblocks -fobjc-nonfragile-abi ${cc_flags}" |
| 126 | +fi |
| 127 | + |
| 128 | +# Install make |
| 129 | +echo "Installing GNUstep into ${prefix}" |
| 130 | +cd tools-make |
| 131 | +# make distclean |
| 132 | +if $USING_GCC; then |
| 133 | + echo "==== BUILDING WITH GCC" |
| 134 | + echo "Build command: CCFLAGS=$cc_flags CC=$CC ./configure --prefix=${prefix} --with-library-combo=gnu-gnu-gnu --with-layout=gnustep $make_flags" |
| 135 | + |
| 136 | + echo "====" |
| 137 | + CCFLAGS=$cc_flags CXX=$CXX CC=$CC ./configure --prefix=${prefix} --with-library-combo=gnu-gnu-gnu --with-layout=gnustep ${make_flags} |
| 138 | +else |
| 139 | + echo "==== BUILDING WITH CLANG" |
| 140 | + unset CC |
| 141 | + unset CXX |
| 142 | + |
| 143 | + # Assume the presence of libdispatch if we are using clang and libobjc2 |
| 144 | + export CC=${compiler} |
| 145 | + export CXX=${cxxcompiler} |
| 146 | + # export LDFLAGS=-ldispatch |
| 147 | + echo "LDFLAGS=$LDFLAGS" |
| 148 | + echo "Build command: CCFLAGS=${cc_flags} CXX=${CXX} CC=${CC} ./configure --prefix=${prefix} --with-library-combo=ng-gnu-gnu --enable-objc-arc --enable-native-objc-exceptions --with-layout=gnustep ${make_flags}" |
| 149 | + CCFLAGS=${cc_flags} CXX=${CXX} CC=${CC} ./configure --prefix=${prefix} --with-library-combo=ng-gnu-gnu --enable-objc-arc --enable-native-objc-exceptions --with-layout=gnustep ${make_flags} |
| 150 | +fi |
| 151 | + |
| 152 | +# Install make after configuration... |
| 153 | +echo "======== Installing Make..." |
| 154 | +$MAKE |
| 155 | +if [ "true" == "$NEEDSROOT" ]; then |
| 156 | + ${SUDO} -u root $MAKE install |
| 157 | +else |
| 158 | + $MAKE install |
| 159 | +fi |
| 160 | +. $prefix/System/Library/Makefiles/GNUstep.sh |
| 161 | + |
| 162 | +# Setup clang specific libraries... |
| 163 | +if ! $USING_GCC; then |
| 164 | + ${scriptsdir}/clang-setup "$CLANG" "$CLANGPP" |
| 165 | +fi |
| 166 | + |
| 167 | +# Install base |
| 168 | +echo "======== Installing Base..." |
| 169 | +cd ../libs-base |
| 170 | +make distclean |
| 171 | +. $prefix/System/Library/Makefiles/GNUstep.sh |
| 172 | +# Temporary until KVO issues are fixed... |
| 173 | +./configure # --disable-newkvo |
| 174 | +LDFLAGS="$LDFLAGS -ldispatch" $MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes || exit 1 |
| 175 | +if [ "true" == "$NEEDSROOT" ]; then |
| 176 | +${SUDO} -u root ./install.sh $prefix $MAKE |
| 177 | +else |
| 178 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 179 | +fi |
| 180 | + |
| 181 | +# Install corebase |
| 182 | +echo "======== Installing CoreBase..." |
| 183 | +cd ../libs-corebase |
| 184 | +make distclean |
| 185 | +. $prefix/System/Library/Makefiles/GNUstep.sh |
| 186 | +./configure |
| 187 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes || exit 1 |
| 188 | +if [ "true" == "$NEEDSROOT" ]; then |
| 189 | +${SUDO} -u root $MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 190 | +else |
| 191 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 192 | +fi |
| 193 | + |
| 194 | +# Install gui |
| 195 | +echo "======== Installing GUI..." |
| 196 | +cd ../libs-gui |
| 197 | +make distclean |
| 198 | +. $prefix/System/Library/Makefiles/GNUstep.sh |
| 199 | +./configure --enable-imagemagick |
| 200 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes |
| 201 | +if [ "true" == "$NEEDSROOT" ]; then |
| 202 | +${SUDO} -u root ./install.sh $prefix $MAKE |
| 203 | +else |
| 204 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 205 | +fi |
| 206 | + |
| 207 | +# Install opal |
| 208 | +echo "======== Installing Opal..." |
| 209 | +cd ../libs-opal |
| 210 | +make distclean |
| 211 | +. $prefix/System/Library/Makefiles/GNUstep.sh |
| 212 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes |
| 213 | +if [ "true" == "$NEEDSROOT" ]; then |
| 214 | +${SUDO} -u root $MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 215 | +else |
| 216 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 217 | +fi |
| 218 | + |
| 219 | +# Install back |
| 220 | +echo "======== Installing Opal Backend..." |
| 221 | +cd ../libs-back |
| 222 | +make distclean |
| 223 | +. $prefix/System/Library/Makefiles/GNUstep.sh |
| 224 | +./configure --enable-graphics=opal |
| 225 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM debug=yes |
| 226 | +if [ "true" == "$NEEDSROOT" ]; then |
| 227 | +${SUDO} -u root ./install.sh $prefix $MAKE |
| 228 | +else |
| 229 | +$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install |
| 230 | +fi |
| 231 | + |
| 232 | +# Perform other operations |
| 233 | +echo "Add script to etc and xsession..." |
| 234 | +if [ ! -e /etc/profile.d/GNUstep.sh ]; then |
| 235 | + ${SUDO} -u root ln -s /usr/GNUstep/System/Library/Makefiles/GNUstep.sh /etc/profile.d/GNUstep.sh |
| 236 | +fi |
| 237 | +cd ../plugins-session |
| 238 | +${SUDO} -u root ./install.sh |
| 239 | +echo "Done." |
0 commit comments