This is the mail archive of the crossgcc@sources.redhat.com 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]

Re: build-crossgcc for m68k-elf - help


>Hi,
>
>I've been quietly sitting in the background listening to this discussion and
>gleaning lots of very useful info. I'm trying to build a crossgcc to target
>m68k-elf, using Bill Gatliff's build-crossgcc.sh script. It always exits
>after having built binutils in the section labeled as:
>#

I don't use a script since I needed to automate my build from a cvs
tree.
Here's a makefile that builds up a full m68k-elf toolchain (thanx to
help from people on this list).  It assumes binutils-2.13,
newlib-1.11.0, and gcc-3.3, but you can change the appropriate bits in
the Makefile to suit your environment(it has build gcc-3.2.3 and
gcc-3.0.4).  This makefile can also build a host compiler which can be
used to build the rest of the tools. 

If you want a gcc-3.3 host compiler that will be used to build all the
tools: 

make host-gcc all 

otherwise:

make all 

--
Peter Barada
peter@baradas.org


#
# Build an m68k-elf compiler from *scratch*
#

# Where all the sources are (assumed in the current directory)
SOURCE_PATH    := $(shell pwd)

# where to install the tools
PREFIX		=/tmp/m68k-elf
HOST_INSTALL_DIR	=${PREFIX}/host

# Target ARCH needed for configuring Linux kernel
ARCH	=m68k
# Target to configure GNU tools for
TARGET        =${ARCH}-elf

LANGUAGES=c,c++

# Source directories (all subdirectories of SOURCE_PATH)
BINUTILS_SOURCE_PATH    =${SOURCE_PATH}/binutils-2.13
#GCC_HOST_SOURCE_PATH        =${SOURCE_PATH}/gcc-2.95.3
#GCC_SOURCE_PATH        =${SOURCE_PATH}/gcc-304
#GCC_SOURCE_PATH        =${SOURCE_PATH}/gcc-3.2.3-20030416
GCCREV=3.3
GCC_SOURCE_PATH        =${SOURCE_PATH}/gcc-${GCCREV}
GCC_HOST_SOURCE_PATH        =${SOURCE_PATH}/${GCCREV}
NEWLIB_SOURCE_PATH        =${SOURCE_PATH}/newlib-1.11.0

# Directories used to build each component
O=obj/m68k-elf
HOSTGCC_BUILDDIR	=$(O)/host-gcc
BINUTILS_BUILDDIR    =$(O)/${TARGET}-binutils
BOOTSTRAP_BUILDDIR    =$(O)/${TARGET}-bootstrap
GCC_BUILDDIR        =$(O)/${TARGET}-gcc
NEWLIB_BUILDDIR        =$(O)/${TARGET}-newlib

.PHONY: binutils bootstrap crossgcc

all: binutils bootstrap newlib gcc

clean-target:
	rm -rf ${PREFIX}

clean-host:
	rm -rf ${HOSTGCC_BUILDDIR}

clean-binutils:
	rm -rf ${BINUTILS_BUILDDIR}

clean-bootstrap:
	rm -rf ${BOOTSTRAP_BUILDDIR}

clean-newlib:
	rm -rf ${NEWLIB_BUILDDIR}

clean-gcc:
	rm -rf ${GCC_BUILDDIR}

clean:	clean-target clean-host clean-binutils clean-bootstrap clean-newlib clean-gcc

host-compiler:	hostgcc install-hostgcc

hostgcc: ${HOSTGCC_BUILDDIR} ${HOSTGCC_BUILDDIR}/Makefile \
	 ${HOSTGCC_BUILDDIR}/gcc/cc1 install-hostgcc

# host compiler chain
${HOSTGCC_BUILDDIR}:
	mkdir ${HOSTGCC_BUILDDIR}

${HOSTGCC_BUILDDIR}/Makefile:
	echo target: ${HOSTGCC_BUILDDIR}/Makefile
	cd ${HOSTGCC_BUILDDIR}; \
	${GCC_HOST_SOURCE_PATH}/configure --prefix=${HOST_INSTALL_DIR} \
	--enable-languages=c

${HOSTGCC_BUILDDIR}/gcc/cc1:
	echo target: ${HOSTGCC_BULDDIR}/gcc/cc1
	make -C ${HOSTGCC_BUILDDIR}

install-hostgcc:
	echo target: install-hostgcc
	cd ${HOSTGCC_BUILDDIR} ; make install

#
# the ld-new target isnt THAT secure and unique entry here. Does
# anyone have an idea
#
binutils:    ${BINUTILS_BUILDDIR} ${BINUTILS_BUILDDIR}/Makefile \
        ${BINUTILS_BUILDDIR}/ld/ld-new install-binutils

${BINUTILS_BUILDDIR}:
	mkdir -p ${BINUTILS_BUILDDIR}

${BINUTILS_BUILDDIR}/Makefile:
	cd ${BINUTILS_BUILDDIR}; \
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	echo "PATH="$$PATH; \
	${BINUTILS_SOURCE_PATH}/configure --target=${TARGET} \
	--prefix=${PREFIX}

${BINUTILS_BUILDDIR}/ld/ld-new:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	make -C ${BINUTILS_BUILDDIR}

install-binutils:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	cd ${BINUTILS_BUILDDIR}; make install

#
# like above, target gcc-cross may be weak ...
#
bootstrap:    ${BOOTSTRAP_BUILDDIR} ${BOOTSTRAP_BUILDDIR}/Makefile \
	${BOOTSTRAP_BUILDDIR}/gcc/cc1 install-bootstrap

${BOOTSTRAP_BUILDDIR}:
	mkdir -p ${BOOTSTRAP_BUILDDIR}

${BOOTSTRAP_BUILDDIR}/Makefile:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	echo "PATH="$$PATH; \
	cd ${BOOTSTRAP_BUILDDIR}; \
	${GCC_SOURCE_PATH}/configure --target=${TARGET} \
	--prefix=${PREFIX} \
	--enable-languages=c \
	--with-local-prefix=${PREFIX}/${TARGET} \
        --without-headers \
	--with-newlib \
	--disable-shared \
	--disable-threads

${BOOTSTRAP_BUILDDIR}/gcc/cc1:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	make -C ${BOOTSTRAP_BUILDDIR} all-gcc

install-bootstrap:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	cd ${BOOTSTRAP_BUILDDIR}; make install-gcc

cleanup-bootstrap:
	rm -f ${PREFIX}/lig/gcc-lib/${TARGET}/${GCCREV}/include/stdlib.h

newlib:	${NEWLIB_BUILDDIR} ${NEWLIB_BUILDDIR}/Makefile \
	${NEWLIB_BUILDDIR}/libc.a install-newlib fix-headers

${NEWLIB_BUILDDIR}:
	mkdir -p ${NEWLIB_BUILDDIR}

${NEWLIB_BUILDDIR}/Makefile:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	echo "PATH="$$PATH; \
	cd ${NEWLIB_BUILDDIR}; \
	${NEWLIB_SOURCE_PATH}/configure --target=${TARGET} \
	--prefix=${PREFIX}

${NEWLIB_BUILDDIR}/libc.a:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	cd ${NEWLIB_BUILDDIR}; make all

install-newlib:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	cd ${NEWLIB_BUILDDIR}; make install

gcc:    ${GCC_BUILDDIR} ${GCC_BUILDDIR}/Makefile \
	${GCC_BUILDDIR}/gcc/cc1 install-gcc

${GCC_BUILDDIR}:
	mkdir -p ${GCC_BUILDDIR}

#
# gcc-3.x is broken in that it fixinc's stdlib.h which is wrong since
# newlib already supplied a good stdlib.h  See
# http://gcc.gnu.org/ml/gcc/2003-05/msg01998.html
#
fix-headers:
	cd ${PREFIX}/${TARGET}/sys-include; \
	ln -s ../include/stdlib.h stdlib.h; \
	ln -s ../include/unistd.h unistd.h; \
	ln -s ../include/string.h string.h; \
	ln -s ../include/limits.h limits.h;


${GCC_BUILDDIR}/Makefile:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	echo "PATH="$$PATH; \
	cd ${GCC_BUILDDIR}; \
	${GCC_SOURCE_PATH}/configure --target=${TARGET} \
	--prefix=${PREFIX} --with-newlib \
	--enable-languages=${LANGUAGES} \
	--with-local-prefix=${PREFIX}/${TARGET}

${GCC_BUILDDIR}/gcc/cc1:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	make -C ${GCC_BUILDDIR} all

install-gcc:
	export PATH=${PREFIX}/host/bin:${PREFIX}/bin:$$PATH; \
	cd ${GCC_BUILDDIR}; make install


------
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]