This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
here's the current version of mini-crosstool, which runs successfully up to creating the bootstrap gcc compiler -- i'm open to feedback while i work on the last two phases of the build. note: i cut a lot of corners in terms of what i reproduced from the full version, as a lot of the patchwork that's in crosstool may very well be relevant only to older software which i'm deliberately ignoring. in some cases, i didn't put in some of those fixes until the corresponding error actually occurred. i'm also aware that some of the stuff i've left out may not cause problems until the final stages that i haven't done yet but, little by little, i figure. (yes, the code could use cleaning. i'm getting there.) ######################################################################## # # mini-crosstool.sh # # This script is a wickedly-condensed version of Dan Kegel's "crosstool" # script for creating a cross-compile toolchain. (Dan's full version # can be found at http://www.kegel.com/crosstool.) # # This shorter version does a lot of simplification, makes a lot of # assumptions and does virtually no error checking (kind of like a lot # of production software). In addition, it tries as much as possible # to follow the standards in Karim Yaghmour's book in terms of naming # conventions. This script is primarily for teaching purposes to show # you the general structure of building a toolchain, after which you # can move on up to the real "crosstool". # # Some of the assumptions made here WRT to "crosstool": # # 1) You already have all of the .bz2-format tarballs for the # components you're going to use on your system (most of them # are available at ftp.gnu.org). # 2) You're going to use sanitized kernel headers and not a full # kernel source tree. # 3) You're going to use the SYSROOT option for configures. # 4) You're going to use leading-edge components for your build (this # script doesn't make any effort to support legacy software. # Sorry.) # # One final note: each step in the build process is mostly independent # from the other steps, so you can see *exactly* what it takes to do each # phase in the build process. This means it should technically be # possible to break this script apart and run each step separately with # only a little work. (It also means that I try not to do any processing # until that processing is actually necessary for that stage.) # # Utility functions. # unpack_and_patch_all() { unpack_and_patch linux-libc-headers ${HEADERS_VERSION} unpack_and_patch binutils ${BINUTILS_VERSION} unpack_and_patch glibc ${GLIBC_VERSION} unpack_and_patch gcc ${GCC_VERSION} } unpack_and_patch() { SW=$1 VERSION=$2 FULL="${SW}-${VERSION}" echo "Unpacking ${FULL}." rm -rf ${BUILD_DIR}/${FULL} tar ${VERBOSE_TAR}xjf ${TARBALLS_DIR}/${FULL}.tar.bz2 \ -C ${BUILD_DIR} echo "Patching ${FULL}." for PFILE in ${PATCHES_DIR}/${FULL}/*.patch ; do echo "Processing patch file ${PFILE}." patch \ -d ${BUILD_DIR}/${FULL} \ --fuzz=1 \ -p 1 \ --force < ${PFILE} done } ################################################################ # Variables you *need* to set: ################################################################ TARBALLS_DIR=~/ct/tarballs # where are the .bz2 tarballs? PATCHES_DIR=~/ct/crosstool-0.38/patches # stolen shamelessly HOST=i686-pc-linux-gnu TARGET=sh3-unknown-linux-gnu # target toolchain type ARCH=sh # based on include/asm-${ARCH} RESULTS_DIR=~/results # *all* toolchains go here PROJECT=jornada # give this build some name HEADERS_VERSION=2.6.12.0 BINUTILS_VERSION=2.16.1 GLIBC_VERSION=2.3.5 GCC_VERSION=4.0.2 # Build/configuration variables. # (empty for now, coming soon) # # Directory layout: # # ${RESULTS_DIR}/ (for *all* results if you want) # ${PROJECT}/ ${PRJROOT} # tools/ ${PREFIX} # bin/ (actual cross-compile commands) # ${TARGET}/ ${TARGET_PREFIX} # sys-root/ ${SYSROOT_DIR} # build-tools/ ${BUILD_DIR} # linux-libc-headers-?? # binutils-??/ # build-binutils/ # glibc-?? # build-glibc-headers # ... more to come ... # PRJROOT=${RESULTS_DIR}/${PROJECT} PREFIX=${PRJROOT}/tools TARGET_PREFIX=${PREFIX}/${TARGET} SYSROOT_DIR=${TARGET_PREFIX}/sys-root HEADERS_DIR=${SYSROOT_DIR}/usr/include BUILD_DIR=${PRJROOT}/build-tools PATH=${PREFIX}/bin:${PATH} # # Variables to unset. # unset CFLAGS unset CXXFLAGS unset LD_LIBRARY_PATH rm -rf ${PREFIX} ; mkdir -p ${PREFIX} rm -rf ${BUILD_DIR} ; mkdir -p ${BUILD_DIR} ; unpack_and_patch_all ###################################################################### # # 1. Install the appropriate header files into sys-root, based on # the architecture. # ###################################################################### do_kernel_headers() { rm -rf ${HEADERS_DIR} mkdir -p ${HEADERS_DIR} HEADERS_SRC_DIR=${BUILD_DIR}/linux-libc-headers-${HEADERS_VERSION} cp -r ${HEADERS_SRC_DIR}/include/linux ${HEADERS_DIR} cp -r ${HEADERS_SRC_DIR}/include/asm-${ARCH} ${HEADERS_DIR}/asm # rm -rf ${HEADERS_SRC_DIR} # redundant now, right? } do_kernel_headers ###################################################################### # # 2. Configure, build and install the binutils. # ###################################################################### do_binutils() { BINUTILS_SRC_DIR=${BUILD_DIR}/binutils-${BINUTILS_VERSION} rm -rf ${BUILD_DIR}/build-binutils mkdir -p ${BUILD_DIR}/build-binutils cd ${BUILD_DIR}/build-binutils ${BINUTILS_SRC_DIR}/configure \ --host=${HOST} \ --target=${TARGET} \ --prefix=${PREFIX} \ --with-sysroot=${SYSROOT_DIR} \ --disable-nls \ ${BINUTILS_EXTRA_CONFIG} make all install } do_binutils PATH=${PREFIX}/bin:$PATH ###################################################################### # # 3. Configure, build and install glibc headers. # ###################################################################### do_glibc_headers() { GLIBC_SRC_DIR=${BUILD_DIR}/glibc-${GLIBC_VERSION} rm -rf ${BUILD_DIR}/build-glibc-headers mkdir -p ${BUILD_DIR}/build-glibc-headers cd ${BUILD_DIR}/build-glibc-headers CC=gcc \ libc_cv_ppc_machine=yes \ ${GLIBC_SRC_DIR}/configure \ --prefix=/usr \ --build=${HOST} \ --host=${TARGET} \ --without-cvs \ --disable-sanity-checks \ --enable-hacker-mode \ --with-headers=${SYSROOT_DIR}/usr/include libc_cv_ppc_machine=yes \ make \ cross_compiling=yes \ install_root=${SYSROOT_DIR} \ CFLAGS=-DBOOTSTRAP_GCC \ install-headers } do_glibc_headers ###################################################################### # # 4. Build the bootstrap gcc compiler, and install it in the build # directory in gcc-core-prefix/. # ###################################################################### GCC_SRC_DIR=${BUILD_DIR}/gcc-${GCC_VERSION} rm -rf ${BUILD_DIR}/build-gcc-core mkdir -p ${BUILD_DIR}/build-gcc-core CORE_PREFIX=${BUILD_DIR}/gcc-core-prefix rm -rf ${CORE_PREFIX} mkdir -p ${CORE_PREFIX} # # Fix some header issues left over from the previous step -- some # header files that have to be manually installed. All of that is # being done *here* since it's related to *this* step, not the previous # one. # GLIBC_HEADERS_DIR=${BUILD_DIR}/build-glibc-headers cp ${GLIBC_HEADERS_DIR}/bits/stdio_lim.h ${HEADERS_DIR}/bits touch ${HEADERS_DIR}/gnu/stubs.h # # Copy cross-compiling binutils utilities. (Can this be avoided by # a judicious use of PATH?) # mkdir -p ${CORE_PREFIX}/${TARGET}/bin for util in ar as ld strip ; do cp ${PREFIX}/${TARGET}/bin/${util} ${CORE_PREFIX}/${TARGET}/bin done PATH=${CORE_PREFIX}/bin:${PATH} # Right place for this? (cd ${BUILD_DIR}/build-gcc-core ; \ ${GCC_SRC_DIR}/configure \ --host=${HOST} \ --target=${TARGET} \ --prefix=${CORE_PREFIX} \ --with-local-prefix=${SYSROOT_DIR} \ --with-sysroot=${SYSROOT_DIR} \ --disable-multilib \ --with-newlib \ --disable-nls \ --disable-shared \ --enable-threads=no \ --enable-symvers=gnu \ --enable-__cxa_atexit \ --enable-languages=c ; \ make all-gcc install-gcc ) ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |