#!/bin/sh ############################################################ ## ## implementation of the "build" target of cc makefile ## ############################################################ MKDIRS=mkdirs if [ -f /usr/bin/arch ]; then # otherwise, OS is probably not NEXTSTEP-like PATH=/bin:/usr/bin:/usr/ucb export PATH if [ ! -f /bin/mkdirs ]; then MKDIRS="mkdir -p"; fi fi arch=`arch` if [ -f /bin/rm ]; then RM=/bin/rm else RM=rm fi if [ ! "$TEMP" ]; then TEMP=${temp:-/tmp} fi if [ ! -d $TEMP ]; then echo "The temporary directory $TEMP does not exist!" exit 1 fi # Use gnumake on OPENSTEP on Mach. make=`if [ -f /bin/gnumake ]; then echo /bin/gnumake; else echo make; fi` # what targets to produce compilers to TARGETS=$arch # what host we should produce executables for HOSTS=$arch # the host on which we are running at now BUILD=$arch # the target operating system TARGET_OS=$arch # where the sources reside SRCROOT=~comp/cc_proj/cc # this is where our gcc 2.x-based compiler is # where to do the build .. better have lots of space there! OBJROOT= # where to put binaries with debugger symbols SYMROOT= # where to put files that are supposed to be installed DSTROOT= # where to do the build .. better have lots of space there! BUILDROOT=$TEMP # what compilers to build. On NeXT, we only really need objc and objc++. LANGUAGES="objc objc++ c++" # flags to use when compiling the compiler CFLAGS="-g -dynamic" OPTIMIZE=-O # whether to bootstrap or not BOOTSTRAP= # command for invoking bison BISON= result=fats for arg do case $next_arg in --srcroot) SRCROOT=$arg next_arg= ;; --objroot) OBJROOT=$arg next_arg= ;; --dstroot) DSTROOT=$arg next_arg= ;; --symroot) SYMROOT=$arg next_arg= ;; --buildroot) BUILDROOT=$arg next_arg= ;; --host*) HOSTS=$arg next_arg= ;; --targetos) TARGET_OS=$arg next_arg= ;; --target*) TARGETS=$arg next_arg= ;; --cflags) CFLAGS=$arg next_arg= ;; --bootstrap) BOOTSTRAP=yes next_arg= ;; --bison) BISON=$arg next_arg= ;; *) case $arg in --srcroot=*) SRCROOT=`echo $arg | sed 's/-*s[a-z]*=//'` ;; --objroot=*) OBJROOT=`echo $arg | sed 's/-*o[a-z]*=//'` ;; --dstroot=*) DSTROOT=`echo $arg | sed 's/-*d[a-z]*=//'` ;; --symroot=*) SYMROOT=`echo $arg | sed 's/-*s[a-z]*=//'` ;; --buildroot=*) BUILDROOT=`echo $arg | sed 's/-*b[a-z]*=//'` ;; --hosts=*|--host=*) HOSTS=`echo $arg | sed 's/-*h[a-z]*=//'` ;; --targets=*|--target=*) TARGETS=`echo $arg | sed 's/-*t[a-z]*=//'` ;; --targetos=*) TARGET_OS=`echo $arg | sed 's/-*t[a-z]*=//'` ;; --cflags=*) CFLAGS=`echo $arg | sed 's/-*c[a-z]*=//'` ;; --optimize=*) if [ `echo $arg | sed 's/-*o[a-z]*=//'` = yes ]; then OPTIMIZE=-O else OPTIMIZE= fi ;; --bootstrap=*) if [ `echo $arg | sed 's/-*b[a-z]*=//'` = yes ]; then BOOTSTRAP=yes else BOOTSTRAP= fi ;; --bison=*) BISON=`echo $arg | sed 's/-*b[a-z]*=//'` ;; --fat|--fats) result=fats ;; --thin|--thins) result=thins ;; --clean) result=clean ;; --configure) result=configure ;; --optimize) OPTIMIZE=-O ;; --no-optimize) OPTIMIZE= ;; --bootstrap) BOOTSTRAP=yes ;; --no-bootstrap) BOOTSTRAP= ;; --lib_ofiles) result=lib_ofiles ;; --*) next_arg=$arg ;; *) echo unknown option $arg exit 1 ;; esac esac done # clean up TARGET_OS, TARGETS, and HOSTS if necessary case "$TARGET_OS" in sunos|solaris|hpux|osf) ;; *sun*) TARGET_OS=solaris ;; *hpux*) TARGET_OS=hpux ;; *win*) TARGET_OS=win32 ;; *) # determine if the target OS is actually Rhapsody if [ -f /usr/bin/uname -o "$TARGET_OS" -a \ "$TARGET_OS" != nextstep -a "$TARGET_OS" != $arch ] then RHAPSODY=rhapsody else RHAPSODY= fi if [ "$TARGET_OS" = macos ] then MAC_OS=macos else MAC_OS= fi TARGET_OS=nextstep # i.e., OPENSTEP, Rhapsody, or Mac OS X ;; esac # set the name of the null device if [ $TARGET_OS = win32 ]; then null=NUL: else null=/dev/null fi case "$TARGETS" in *sun*) TARGETS=sparc ;; *hpux*) TARGETS=hppa ;; *win*) TARGETS=i386 ;; esac case "$HOSTS" in *sun*) HOSTS=sparc ;; *hpux*) HOSTS=hppa ;; *win*) HOSTS=i386 ;; *) # Make the build host the first item in $HOSTS in order to prevent any # potential problems in trying to build a C++ cross compiler for a new # target. HOSTS=`echo $HOSTS | fgrep "$arch" >$null && echo -n "$arch "; \ echo $HOSTS | sed "s/$arch//"` ;; esac # get the version CCVERS=`cd $SRCROOT; vers_string -f cc` gcc_version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $SRCROOT/cc/version.c` # remove any -arch flags from CFLAGS CFLAGS=`echo $CFLAGS|sed 's/-arch [a-z0-9]*//g'` # add target arch... if [ "$RC_RELEASE" ]; then CFLAGS="$CFLAGS -DRC_RELEASE_"`echo $RC_RELEASE|tr '.' '_'` fi # add the ARCH macro if [ $TARGET_OS = win32 ]; then if [ "$BOOTSTRAP" ]; then CFLAGS="$CFLAGS -DARCH=\\\\\\\"$arch\\\\\\\"" else CFLAGS="$CFLAGS -DARCH=\\\"$arch\\\"" fi fi if [ x$SYMROOT = x ]; then SYMROOT=$BUILDROOT/$CCVERS.sym fi if [ x$OBJROOT = x ]; then OBJROOT=$BUILDROOT/$CCVERS.obj fi if [ x$DSTROOT = x ]; then DSTROOT=$BUILDROOT/$CCVERS.dst fi # set exe to the extension binary executables should have if [ $TARGET_OS = win32 ]; then exe=.exe else exe= fi # set up bison environment if [ ! "$BISON" ]; then if [ "$RHAPSODY" -a "$NEXT_ROOT" -a ! "$MAC_OS" ]; then BISON=/usr/local/bin/bison else BISON=$OBJROOT/bison_${arch}_obj/bison BISON_SIMPLE=$BISON.s1 export BISON_SIMPLE fi fi echo =========================================================== echo == 'Building NeXT Objective C compiler(s) **' $result '**' echo =========================================================== echo == 'BUILDHOST :' `hostname` -- a $arch echo == 'HOSTS :' $HOSTS echo == 'TARGETS :' $TARGETS echo == 'TARGET_OS :' $TARGET_OS echo == 'OBJROOT :' $OBJROOT echo == 'SYMROOT :' $SYMROOT echo == 'SRCROOT :' $SRCROOT echo == 'DSTROOT :' $DSTROOT echo == 'VERSION :' $CCVERS echo == 'CFLAGS :' $OPTIMIZE $CFLAGS echo =========================================================== # # Check that cross compilers are available # missing_cross=no if [ $TARGET_OS = nextstep -a "$result" != clean ]; then for host in $HOSTS; do if [ ! -d /`if [ "$MAC_OS" ]; then echo usr/libexec/gcc/darwin; elif [ "$RHAPSODY" ]; then echo usr/libexec; else echo lib; fi`/$host -a \ ! -d /usr/local/lib`if [ "$MAC_OS" ]; then echo exec/gcc/darwin; elif [ "$RHAPSODY" ]; then echo exec; fi`/$host ] then echo "***********************************************************" echo "** The directory /`if [ "$MAC_OS" ]; then echo usr/libexec/gcc/darwin; elif [ "$RHAPSODY" ]; then echo usr/libexec; else echo lib; fi`/$host is missing!!!" echo "** Please install a compiler that generates code for $host" missing_cross=yes fi done for host in $HOSTS; do if echo $TARGETS | grep $host >$null 2>&1; then true; else echo "***********************************************************" echo "** host type $host should also be a target" echo "***********************************************************" # missing_cross=yes fi done if [ $missing_cross = yes ]; then echo "***********************************************************" exit 1; fi fi safe_exec () { if ($*); then true; else exit 1; fi } clean_gcc () { echo =========================================================== echo == 'Cleaning NeXT Objective C compiler(s)' echo =========================================================== for target in $TARGETS; do for host in $HOSTS; do if [ -d $OBJROOT/cc-$target-on-$host ]; then echo '==' $OBJROOT/cc-$target-on-$host $RM -Rf $OBJROOT/cc-$target-on-$host fi done done for host in $HOSTS; do if [ -d $SYMROOT/$host ]; then echo '==' $SYMROOT/$host $RM -Rf $SYMROOT/$host fi done if [ X$DSTROOT != X$SRCROOT ]; then if [ -d $DSTROOT ]; then echo '==' $DSTROOT $RM -Rf $DSTROOT fi fi echo =========================================================== } configure_gcc () { for target in $TARGETS; do for host in $HOSTS; do $MKDIRS $OBJROOT/cc-$target-on-$host; cd $OBJROOT/cc-$target-on-$host; source=bad if [ -f make.id ]; then if [ X`cat make.id` = X$SRCROOT/cc:$arch ]; then source=ok fi fi if [ X$source = Xok -a -f Makefile ]; then echo =========================================================== echo == updating Makefile for cc-$target-on-$host\; buildhost=$arch echo =========================================================== safe_exec $make Makefile else echo =========================================================== echo == configuring cc-$target-on-$host\; buildhost=$arch echo =========================================================== $RM -f make.id echo $SRCROOT/cc:$arch > make.id $RM -f rtl.o bc-*.o $SRCROOT/cc/configure \ --host=`if [ $TARGET_OS = nextstep ]; \ then echo $host-${RHAPSODY:-nextstep}; \ else echo $arch; fi` \ --target=`if [ $TARGET_OS = nextstep ]; \ then echo $target-${RHAPSODY:-nextstep}; \ else echo $arch; fi` \ --build=`if [ $TARGET_OS = nextstep ]; then \ if [ -f /usr/bin/uname ]; \ then echo $BUILD-rhapsody; \ else echo $BUILD-nextstep; fi; \ else echo $arch; fi` \ --srcdir=$SRCROOT/cc \ # --force-build fi done done } install_newer () { if [ -f "$1" ]; then $RM -f $TEMP/make.$$ touch `if [ $TARGET_OS != win32 ]; then echo -f; fi` $TEMP/make.$$ echo "$2: $1" >> $TEMP/make.$$ echo " $RM -f $2" >> $TEMP/make.$$ echo " install -c $3 $1 $2" >> $TEMP/make.$$ safe_exec $make -f $TEMP/make.$$ $RM -f $TEMP/make.$$ else echo "build_gcc: $1: no such file" fi } build_compiler () { buildhost=$arch for host in $HOSTS; do for target in $TARGETS; do if [ "$TARGET_OS" = win32 ] then bootstrap=${BOOTSTRAP:+bootstrap}; elif [ ! "$BOOTSTRAP" -o $host != $target -o $BUILD != $host -o \ "$NEXT_ROOT" ] then bootstrap= else bootstrap=bootstrap fi cd $OBJROOT/cc-$target-on-$host echo =========================================================== echo == ${bootstrap:-build}ing cc-$target-on-$host\; buildhost:$buildhost echo =========================================================== ############################################################# # this will build the core compilers ############################################################# if [ -f /usr/bin/uname ]; then bootstrap=${bootstrap:+bootstrap gnucompare} fi if $make `echo ${bootstrap:-"specs all.build"}` \ srcdir=$SRCROOT/cc \ LANGUAGES="$LANGUAGES" \ HOST_PREFIX="$buildhost-" HOST_PREFIX_1="$buildhost-" \ HOST_CC="`if [ $TARGET_OS = win32 ]; then echo gcc; \ else echo ${NEXT_ROOT:+NEXT_ROOT=} cc -arch $buildhost -traditional-cpp; fi`" \ GCC_FOR_TARGET="`if [ "$TARGET_OS" = win32 ]; then \ echo ./xgcc -B./; \ elif [ "$NEXT_ROOT" ]; then \ echo cc -traditional-cpp; \ elif [ $BUILD != $host ]; then \ if [ -f ../cc-$target-on-$BUILD/xgcc ]; then \ echo ../cc-$target-on-$BUILD/xgcc -arch $target \ -B../cc-$target-on-$BUILD/ -traditional-cpp;\ else echo cc -arch $target -traditional-cpp; fi; \ else echo ./xgcc -B./ -traditional-cpp; fi`" \ BISON="$BISON" \ CFLAGS="$OPTIMIZE $CFLAGS" \ BOOT_CFLAGS="$OPTIMIZE $CFLAGS \ `if [ $TARGET_OS != win32 ]; then echo -traditional-cpp; fi`" \ CC="`if [ $TARGET_OS = win32 ]; then echo gcc; \ else echo cc -arch $host -traditional-cpp ${bootstrap:+"$CFLAGS"}; fi`" then echo "== Finished building compilers for cc-$target-on-$host" else exit 1; fi sym=$SYMROOT/$host srcdir=`if [ $TARGET_OS = win32 ]; then \ echo $sym/Developer/Source/gcc; \ else echo $sym/src/$target; \ fi` bindir=`if [ $TARGET_OS = win32 ]; then \ echo $sym/Developer/Executables; \ elif [ -f /usr/bin/uname ]; then \ echo $sym/usr/bin; \ else echo $sym/bin; \ fi` libdir=`if [ $TARGET_OS = win32 ]; then \ echo $sym/Developer/Libraries/gcc-lib/$BUILD/$gcc_version; \ else echo $sym/lib/$target; \ fi` $MKDIRS $srcdir $MKDIRS $bindir $MKDIRS $libdir install_newer cpp$exe $libdir/cpp$exe "-m 555" install_newer cc1obj$exe $libdir/cc1obj$exe "-m 555" install_newer cc1objplus$exe $libdir/cc1objplus$exe "-m 555" install_newer cc1plus$exe $libdir/cc1plus$exe "-m 555" if [ $TARGET_OS = win32 ]; then install_newer ld$exe $libdir/ld$exe "-m 555" install_newer specs $libdir/specs "-m 444" install_newer libgcc.a $sym/Developer/Libraries/libgcc.a "-m 444" fi gnutar cf - *.c *.h *.y cp/*.c cp/*.h cp/*.y obcp/*.c obcp/*.h obcp/*.y | \ (cd $srcdir; gnutar xvf -) done if echo $TARGETS | grep $host >$null; then install_newer \ $OBJROOT/cc-$host-on-$host/xgcc$exe \ $bindir/`if [ $TARGET_OS = nextstep ]; then \ echo cc; \ else \ echo gcc; \ fi`$exe \ "-m 555" install_newer \ $OBJROOT/cc-$host-on-$host/g++$exe \ $bindir/`if [ $TARGET_OS = nextstep ]; then \ echo c++; \ else \ echo g++; \ fi`$exe \ "-m 555" install_newer \ $OBJROOT/cc-$host-on-$host/c++filt$exe \ $bindir/c++filt$exe \ "-m 555" fi done } install_new_cc () { echo "************************************************************"; echo "** You must have the most recent version of the compiler " echo "** (host=" $arch " target=$target version=$CCVERS) installed" echo "** on the build host to finish this build... " echo "** OR have $host as one of the RC_HOSTS elements" echo "** Currently, version $target_vers is installed " echo "************************************************************"; exit 1; } build_libgcc () { CFLAGS=`echo $CFLAGS | sed 's/-dynamic//' | sed 's/-static//'` for target in $TARGETS; do host=$arch $MKDIRS $OBJROOT/cc-$target-on-$host; cd $OBJROOT/cc-$target-on-$host; # the buildhost is in hosts.. if echo $HOSTS | grep $host >$null; then compiler=./xgcc specs=specs else if [ -d /lib/$target ]; then # get version of installed $target compiler cc -arch $target -v 2> $TEMP/tmp.$$ target_vers=`cat $TEMP/tmp.$$ \ | grep 'version' \ | sed 's/, gcc.*$//' \ | sed 's/^.*version //'` $RM $TEMP/tmp.$$ if [ X$target_vers != X$CCVERS ]; then install_new_cc fi compiler=cc $RM -f specs cp /lib/$target/specs specs specs= else install_new_cc fi fi ############################################################# # now, build the gcc specs and runtime libraries ############################################################# echo "===============================================================" echo "Building runtime libraries using new compiler for target $target:" $compiler -B./ -v echo "===============================================================" $RM -f libgcc.a libgcc1.a libgcc2.a echo '== building STATIC version' if [ -f libgcc_static.a ]; then mv -f libgcc_static.a libgcc.a; fi if [ -f libgcc1_static.a ]; then mv -f libgcc1_static.a libgcc1.a; fi if [ -f libgcc2_static.a ]; then mv -f libgcc2_static.a libgcc2.a; fi if $make $specs libgcc.a \ srcdir=$SRCROOT/cc \ LANGUAGES="$LANGUAGES" \ HOST_PREFIX="$arch-" HOST_PREFIX_1="$arch-" \ HOST_CC="cc -arch $arch -traditional-cpp" \ GCC_FOR_TARGET="$compiler -B./" \ CFLAGS="$OPTIMIZE $CFLAGS" \ BISON="$BISON" \ GCC_CFLAGS="-traditional-cpp $CFLAGS" \ AR_FOR_TARGET=ar \ CC="cc -arch $host -traditional-cpp" \ TARGET_LIBGCC2_CFLAGS="`if [ $target = ppc ]; then echo -force_cpusubtype_ALL; fi` -DPRIVATE_EXTERN=__private_extern__ -DPRIVATE_EXTERN_ASM_OP=\\\".private_extern\\\" -static"; \ then echo '== ok'; else exit 1; fi mv -f libgcc.a libgcc_static.a mv -f libgcc1.a libgcc1_static.a mv -f libgcc2.a libgcc2_static.a if [ ! "$RHAPSODY" -o "$NEXT_ROOT" -a ! "$MAC_OS" ]; then echo '== building SHLIB version' if [ -f libgcc_shlib.a ]; then mv -f libgcc_shlib.a libgcc.a; fi if [ -f libgcc1_shlib.a ]; then mv -f libgcc1_shlib.a libgcc1.a; fi if [ -f libgcc2_shlib.a ]; then mv -f libgcc2_shlib.a libgcc2.a; fi if $make specs libgcc.a \ srcdir=$SRCROOT/cc \ LANGUAGES="$LANGUAGES" \ HOST_PREFIX="$arch-" HOST_PREFIX_1="$arch-" \ HOST_CC="cc -arch $arch -traditional-cpp -DSHLIB" \ GCC_FOR_TARGET="$compiler -B./" \ CFLAGS="$OPTIMIZE $CFLAGS" \ BISON="$BISON" \ GCC_CFLAGS="-traditional-cpp $CFLAGS" \ AR_FOR_TARGET=ar \ CC="cc -arch $host -traditional-cpp" \ TARGET_LIBGCC2_CFLAGS="-DSHLIB -static"; \ then echo '== ok'; else exit 1; fi mv -f libgcc.a libgcc_shlib.a mv -f libgcc1.a libgcc1_shlib.a mv -f libgcc2.a libgcc2_shlib.a echo '== building DYLIB version' if [ -f libgcc_dylib.a ]; then mv -f libgcc_dylib.a libgcc.a; fi if [ -f libgcc1_dylib.a ]; then mv -f libgcc1_dylib.a libgcc1.a; fi if [ -f libgcc2_dylib.a ]; then mv -f libgcc2_dylib.a libgcc2.a; fi if $make specs libgcc.a \ srcdir=$SRCROOT/cc \ LANGUAGES="$LANGUAGES" \ HOST_PREFIX="$arch-" HOST_PREFIX_1="$arch-" \ HOST_CC="cc -arch $arch -traditional-cpp" \ GCC_FOR_TARGET="$compiler -B./" \ CFLAGS="$OPTIMIZE $CFLAGS" \ BISON="$BISON" \ GCC_CFLAGS="-traditional-cpp $CFLAGS" \ AR_FOR_TARGET=ar \ CC="cc -arch $host -traditional-cpp" \ TARGET_LIBGCC2_CFLAGS="`if [ $target = ppc ]; then echo -static; fi`";\ then echo '== ok'; else exit 1; fi mv -f libgcc.a libgcc_dylib.a mv -f libgcc1.a libgcc1_dylib.a mv -f libgcc2.a libgcc2_dylib.a fi echo '== building DYNAMIC ARCHIVE version' if [ -f libgcc_dynamic.a ]; then mv -f libgcc_dynamic.a libgcc.a; fi if [ -f libgcc1_dynamic.a ]; then mv -f libgcc1_dynamic.a libgcc1.a; fi if [ -f libgcc2_dynamic.a ]; then mv -f libgcc2_dynamic.a libgcc2.a; fi if $make specs libgcc.a \ srcdir=$SRCROOT/cc \ LANGUAGES="$LANGUAGES" \ HOST_PREFIX="$arch-" HOST_PREFIX_1="$arch-" \ HOST_CC="cc -arch $arch -traditional-cpp" \ GCC_FOR_TARGET="$compiler -B./" \ CFLAGS="$OPTIMIZE $CFLAGS" \ BISON="$BISON" \ GCC_CFLAGS="-traditional-cpp $CFLAGS" \ AR_FOR_TARGET=ar \ CC="cc -arch $host -traditional-cpp" \ TARGET_LIBGCC2_CFLAGS="`if [ $target = ppc ]; then echo -force_cpusubtype_ALL; fi` -DPRIVATE_EXTERN=__private_extern__ -DPRIVATE_EXTERN_ASM_OP=\\\".private_extern\\\""; \ then echo '== ok'; else exit 1; fi mv -f libgcc.a libgcc_dynamic.a mv -f libgcc1.a libgcc1_dynamic.a mv -f libgcc2.a libgcc2_dynamic.a echo '== installing libcc.a in symroot' for host in $HOSTS; do sym=$SYMROOT/$host $MKDIRS $sym/lib/$target install_newer specs $sym/lib/$target/specs "-m 444" install_newer libgcc_static.a $sym/lib/$target/libcc.a \ "-m 444 `if [ -f /usr/bin/uname ]; then echo -S -S; else echo -sS; fi`" ranlib -t $sym/lib/$target/libcc.a install_newer libgcc_dynamic.a $sym/lib/$target/libcc_dynamic.a \ "-m 444 `if [ -f /usr/bin/uname ]; then echo -S -S; else echo -sS; fi`" ranlib -t $sym/lib/$target/libcc_dynamic.a done if [ ! "$RHAPSODY" -o "$NEXT_ROOT" -a ! "$MAC_OS" ]; then echo '== extracting libcc.a files in objroot' if [ "$target" = hppa -o "$target" = sparc ]; then special='|_udiv_w_sdiv.o' else special='' fi libgcc=`pwd`/libgcc_shlib.a shlib=$OBJROOT/shlib_${target}_obj ($MKDIRS $shlib; cd $shlib; ar x $libgcc; \ $RM -f libgcc.ofileList ; \ ls -1 *.o | egrep -v "(__main$special|_exit.o)" > libgcc.ofileList) libgcc=`pwd`/libgcc_dylib.a dylib=$OBJROOT/dynamic_obj/$target ($MKDIRS $dylib; cd $dylib; ar x $libgcc; \ $RM -f libgcc.ofileList ; \ ls -1 *.o | egrep -v "(__main$special|_exit.o)" > libgcc.ofileList) fi done } install_fat () { echo "============================================================" echo "== Building fat binaries [$HOSTS] fat for targets: $TARGETS" echo "============================================================" fat=$DSTROOT sym=$SYMROOT lib=`if [ "$RHAPSODY" ]; then echo usr/lib; else echo lib; fi` libexec=`if [ "$MAC_OS" ]; then echo usr/libexec/gcc/darwin; \ elif [ "$RHAPSODY" ]; then echo usr/libexec; \ else echo lib; fi` $MKDIRS $fat $MKDIRS $fat/`if [ -f /usr/bin/uname ]; then echo usr/; fi`bin $MKDIRS $fat/$lib $MKDIRS $fat/$libexec for target in $TARGETS; do $MKDIRS $fat/$libexec/$target`if [ "$RHAPSODY" ]; then echo /$gcc_version; fi` for file in cpp cc1obj cc1objplus cc1plus; do thin_files="" for host in $HOSTS; do thin_files="$thin_files $sym/$host/lib/$target/$file" done fat_file=$fat/$libexec/$target`if [ "$RHAPSODY" ]; then echo /$gcc_version; fi`/$file $RM -f $fat_file $RM -f $TEMP/make.$$ touch -f $TEMP/make.$$ echo "$fat_file: $thin_files" >> $TEMP/make.$$ echo " $RM -f $fat_file" >> $TEMP/make.$$ echo " lipo -create -output $fat_file $thin_files" >> $TEMP/make.$$ echo " strip $fat_file" >> $TEMP/make.$$ echo " chmod 555 $fat_file" >> $TEMP/make.$$ safe_exec $make -f $TEMP/make.$$ $RM -f $TEMP/make.$$ done install_newer $sym/$host/lib/$target/specs \ $fat/$libexec/$target`if [ "$RHAPSODY" ]; then echo /$gcc_version; fi`/specs \ "-m 444" done if [ ! "$NEXT_ROOT" ]; then for file in libcc.a libcc_dynamic.a; do thin_files="" for target in $TARGETS; do thin_files="$thin_files $sym/$host/lib/$target/$file" done $RM -f $fat/$lib/$file $RM -f $TEMP/make.$$ touch -f $TEMP/make.$$ echo "$fat/$lib/$file: $thin_files" >>$TEMP/make.$$ echo " $RM -f $fat/$lib/$file" >>$TEMP/make.$$ echo " libtool -o $fat/$lib/$file $thin_files" >>$TEMP/make.$$ echo " chmod 444 $fat/$lib/$file" >>$TEMP/make.$$ safe_exec $make -f $TEMP/make.$$ $RM -f $TEMP/make.$$ done fi # cc, c++, and c++filt no longer installed! # for file in ${RHAPSODY:+usr/}bin/cc ${RHAPSODY:+usr/bin/c++} ${RHAPSODY:+usr/}bin/c++filt; do # thin_files="" # for host in $HOSTS; do # if echo $TARGETS | grep $host >$null; then # thin_files="$thin_files $sym/$host/$file" # else # echo "***********************************************************" # echo '**' "host type $host must also be a target" # echo '**' in order to properly create fat binaries such as cc # echo "***********************************************************" # exit 1 # fi # done # $RM -f $fat/$file # $RM -f $TEMP/make.$$ # touch -f $TEMP/make.$$ # echo "$fat/$file: $thin_files" >> $TEMP/make.$$ # echo " $RM -f $fat/$file" >> $TEMP/make.$$ # echo " lipo -create -output $fat/$file $thin_files" >> $TEMP/make.$$ # echo " strip $fat/$file" >> $TEMP/make.$$ # echo " chmod 555 $fat/$file" >> $TEMP/make.$$ # safe_exec $make -f $TEMP/make.$$ # $RM -f $TEMP/make.$$ # done } # lib_ofiles bootstrap target required by RC API build_lib_ofiles() { # set the host variable to an arbitrary host. for host in $HOSTS; do break; done lib=`if [ "$RHAPSODY" ]; then echo usr/lib; else echo lib; fi` extra_cflags=-static for library in libcc.a libcc_dynamic.a; do for target in $TARGETS; do cd $OBJROOT/cc-$target-on-$host echo ====== building $library for target $target ====== $RM -f libgcc.a libgcc1.a libgcc2.a if $make libgcc.a \ srcdir=$SRCROOT/cc \ LANGUAGES="$LANGUAGES" \ HOST_PREFIX="$arch-" HOST_PREFIX_1="$arch-" \ HOST_CC="cc -arch $arch -traditional-cpp" \ GCC_FOR_TARGET="cc -arch $target -traditional-cpp" \ CFLAGS="$OPTIMIZE $CFLAGS" \ BISON="$BISON" \ GCC_CFLAGS="-traditional-cpp $CFLAGS" \ AR_FOR_TARGET=ar \ CC="cc -arch $host -traditional-cpp" \ GCC_PASSES="" \ AR_FOR_TARGET="ar" \ TARGET_LIBGCC2_CFLAGS="-DPRIVATE_EXTERN=__private_extern__ -DPRIVATE_EXTERN_ASM_OP=\\\".private_extern\\\" $extra_cflags"; \ then echo '== ok'; else exit 1; fi done thin_files="" for target in $TARGETS; do thin_files="$thin_files $OBJROOT/cc-$target-on-$host/libgcc.a" done $MKDIRS $DSTROOT/$lib $RM -f $DSTROOT/$lib/$library $RM -f $TEMP/make.$$ touch -f $TEMP/make.$$ echo "$DSTROOT/$lib/$library: $thin_files" >>$TEMP/make.$$ echo " $RM -f $DSTROOT/$lib/$library" >>$TEMP/make.$$ echo " libtool -o $DSTROOT/$lib/$library $thin_files" >>$TEMP/make.$$ echo " strip -S $DSTROOT/$lib/$library" >>$TEMP/make.$$ echo " chmod 444 $DSTROOT/$lib/$library" >>$TEMP/make.$$ safe_exec $make -f $TEMP/make.$$ $RM -f $TEMP/make.$$ extra_cflags='' done } if [ X$result = Xclean ]; then clean_gcc exit 0 fi configure_gcc if [ X$result = Xconfigure ]; then exit 0 fi #take care of the special system bootstrap target if [ "$result" = lib_ofiles -o "$NEXT_ROOT" -a "$result" != thins ]; then build_lib_ofiles if [ "$result" = lib_ofiles ]; then exit 0; fi # Copy the builder's specs files because the executables the builder creates # don't run on the builder. for target in $TARGETS; do lib=`if [ -d /usr/libexec ]; then echo usr/libexec/$target/$gcc_version; else echo lib/$target; fi` $MKDIRS $DSTROOT/$lib install_newer /$lib/specs $DSTROOT/$lib/specs "-m 444" done fi build_compiler if [ $TARGET_OS = nextstep ]; then if [ ! "$NEXT_ROOT" ]; then build_libgcc; fi else (cd $SYMROOT/$TARGETS; gnutar cf - Developer) | (cd $DSTROOT; gnutar xvf -) $RM -rf $DSTROOT/Developer/Source/gcc fi if [ $result = thins ]; then exit 0; fi install_fat