kumquat-buildroot/make/gcc_target.mk

310 lines
11 KiB
Makefile
Raw Normal View History

# Makefile for to build a gcc/uClibc toolchain linked vs uClibc
#
# Copyright (C) 2002 Erik Andersen <andersen@uclibc.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#############################################################
#
# You should probably leave this stuff alone unless you are
# hacking on the toolchain...
#
#############################################################
TARGET_LANGUAGES:=c,c++
# If you want multilib enabled, enable this...
2003-01-20 20:24:02 +01:00
MULTILIB:=--enable-multilib
#############################################################
#
# Where we can find things....
#
# for various dependancy reasons, these need to live
# here at the top... Easier to find things here anyways...
#
#############################################################
BINUTILS_DIR2:=$(BUILD_DIR)/binutils-target
GCC_BUILD_DIR3:=$(BUILD_DIR)/gcc-target
#############################################################
#
# build binutils
#
#############################################################
$(BINUTILS_DIR2)/.configured:
mkdir -p $(BINUTILS_DIR2)
mkdir -p $(TARGET_DIR)/usr/include
mkdir -p $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/
(cd $(TARGET_DIR)/usr/$(GNU_TARGET_NAME); ln -fs ../include sys-include)
2003-02-12 09:10:40 +01:00
(cd $(BINUTILS_DIR2); PATH=$(TARGET_PATH) AR=$(TARGET_CROSS)ar \
RANLIB=$(TARGET_CROSS)ranlib LD=$(TARGET_CROSS)ld NM=$(TARGET_CROSS)nm \
CC=$(TARGET_CROSS)gcc \
2003-01-07 22:00:41 +01:00
$(BINUTILS_DIR)/configure \
2003-01-19 12:24:32 +01:00
--target=$(GNU_TARGET_NAME) \
2003-01-21 07:42:01 +01:00
--host=$(GNU_TARGET_NAME) \
2003-01-07 22:00:41 +01:00
--prefix=/usr \
2003-01-21 07:42:01 +01:00
--exec-prefix=/usr \
2003-01-07 22:00:41 +01:00
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib \
2003-01-07 22:00:41 +01:00
--sysconfdir=/etc \
--datadir=/usr/share \
--libdir=/usr/lib \
--localstatedir=/var \
--mandir=/usr/man \
--infodir=/usr/info \
--includedir=$(STAGING_DIR)/include \
--with-gxx-include-dir=$(STAGING_DIR)/include/c++ \
2003-02-12 09:10:40 +01:00
--enable-shared $(MULTILIB) \
--program-prefix="" \
);
touch $(BINUTILS_DIR2)/.configured
$(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
2003-02-12 09:10:40 +01:00
$(MAKE) AR=$(TARGET_CROSS)ar \
RANLIB=$(TARGET_CROSS)ranlib LD=$(TARGET_CROSS)ld \
2003-01-19 12:24:32 +01:00
CC=$(TARGET_CROSS)gcc GCC_FOR_TARGET=$(TARGET_CROSS)gcc \
2003-02-12 09:10:40 +01:00
CC_FOR_TARGET=$(TARGET_CROSS)gcc tooldir=/usr -C $(BINUTILS_DIR2)
$(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump
2003-02-12 09:10:40 +01:00
CC=$(HOSTCC) GCC_FOR_TARGET=$(TARGET_CROSS)gcc \
AR_FOR_TARGET=$(TARGET_CROSS)ar RANLIB_FOR_TARGET=$(TARGET_CROSS)ranlib \
LD_FOR_TARGET=$(TARGET_CROSS)ld NM_FOR_TARGET=$(TARGET_CROSS)nm \
CC_FOR_TARGET=$(TARGET_CROSS)gcc \
$(MAKE) \
2003-02-12 09:10:40 +01:00
tooldor=/usr \
2003-01-07 22:00:41 +01:00
prefix=$(TARGET_DIR)/usr \
exec_prefix=$(TARGET_DIR)/usr \
bindir=$(TARGET_DIR)/usr/bin \
sbindir=$(TARGET_DIR)/usr/sbin \
libexecdir=$(TARGET_DIR)/usr/lib \
2003-01-07 22:00:41 +01:00
datadir=$(TARGET_DIR)/usr/share \
sysconfdir=$(TARGET_DIR)/etc \
sharedstatedir=$(TARGET_DIR)/usr/com \
localstatedir=$(TARGET_DIR)/var \
libdir=$(TARGET_DIR)/usr/lib \
infodir=$(TARGET_DIR)/usr/info \
mandir=$(TARGET_DIR)/usr/man \
includedir=$(TARGET_DIR)/usr/include \
gxx_include_dir=$(TARGET_DIR)/usr/include/c++ \
toolexecdir=$(TARGET_DIR)/lib/gcc-lib/$(GNU_TARGET_NAME) \
-C $(BINUTILS_DIR2) install;
2003-01-17 09:51:21 +01:00
rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
$(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
2002-11-14 13:10:18 +01:00
-$(STRIP) $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/bin/*
-$(STRIP) $(TARGET_DIR)/usr/bin/*
$(TARGET_DIR)/usr/lib/libg.a:
2003-02-12 09:10:40 +01:00
$(TARGET_CROSS)ar rv $(TARGET_DIR)/usr/lib/libg.a;
cp $(BINUTILS_DIR)/include/ansidecl.h $(TARGET_DIR)/usr/include/
cp $(BINUTILS_DIR)/include/bfdlink.h $(TARGET_DIR)/usr/include/
cp $(BINUTILS_DIR)/include/dis-asm.h $(TARGET_DIR)/usr/include/
cp $(BINUTILS_DIR)/include/libiberty.h $(TARGET_DIR)/usr/include/
cp $(BINUTILS_DIR)/include/symcat.h $(TARGET_DIR)/usr/include/
cp $(BINUTILS_DIR2)/bfd/bfd.h $(TARGET_DIR)/usr/include/
cp -a $(BINUTILS_DIR2)/bfd/.libs/* $(TARGET_DIR)/usr/lib/
cp -a $(BINUTILS_DIR2)/opcodes/.libs/* $(TARGET_DIR)/usr/lib/
cp -a $(BINUTILS_DIR2)/libiberty/libiberty.a $(TARGET_DIR)/usr/lib/
binutils_target: gcc_final $(TARGET_DIR)/usr/bin/ld $(TARGET_DIR)/usr/lib/libg.a
binutils_target-clean:
rm -f $(TARGET_DIR)/bin/$(GNU_TARGET_NAME)*
-$(MAKE) -C $(BINUTILS_DIR2) clean
binutils_target-dirclean:
rm -rf $(BINUTILS_DIR2)
#############################################################
#
# uClibc just needs its header files and whatnot installed.
#
#############################################################
$(TARGET_DIR)/usr/lib/libc.a: $(STAGING_DIR)/lib/libc.a
$(MAKE) DEVEL_PREFIX=$(TARGET_DIR)/usr SYSTEM_DEVEL_PREFIX=$(TARGET_DIR) \
DEVEL_TOOL_PREFIX=$(TARGET_DIR) -C $(UCLIBC_DIR) \
install_dev
2003-02-12 09:10:40 +01:00
#remove the extra copy of the shared libs
rm -f $(TARGET_DIR)/usr/lib/*-*.so
2002-11-14 13:10:18 +01:00
(cd $(TARGET_DIR)/usr/lib; \
ln -fs /lib/libc.so.0 libc.so; \
ln -fs /lib/libdl.so.0 libdl.so; \
ln -fs /lib/libcrypt.so.0 libcrypt.so; \
ln -fs /lib/libresolv.so.0 libresolv.so; \
ln -fs /lib/libutil.so.0 libutil.so; \
ln -fs /lib/libm.so.0 libm.so; \
ln -fs /lib/libpthread.so.0 libpthread.so; \
2003-02-12 09:10:40 +01:00
ln -fs /lib/libnsl.so.0 libnsl.so; \
2002-11-14 13:10:18 +01:00
)
uclibc_target: gcc_final $(TARGET_DIR)/usr/lib/libc.a
uclibc_target-clean:
rm -f $(TARGET_DIR)/include
uclibc_target-dirclean:
rm -f $(TARGET_DIR)/include
#############################################################
#
# Next build target gcc compiler
#
#############################################################
2003-01-07 22:00:41 +01:00
$(GCC_BUILD_DIR3)/.gcc_build_hacks:
#
# Make certain the uClibc start files are found
#
perl -i -p -e "s,standard_startfile_prefix_1 = \".*,standard_startfile_prefix_1=\
\"/lib/\";,;" $(GCC_DIR)/gcc/gcc.c;
perl -i -p -e "s,standard_startfile_prefix_2 = \".*,standard_startfile_prefix_2=\
\"/usr/lib/\";,;" $(GCC_DIR)/gcc/gcc.c;
#
# Make certain the uClibc include files are found
#
perl -i -p -e "s,^NATIVE_SYSTEM_HEADER_DIR.*,NATIVE_SYSTEM_HEADER_DIR=\
2003-01-21 07:42:01 +01:00
/usr/include,;" $(GCC_DIR)/gcc/Makefile.in;
2003-01-07 22:00:41 +01:00
perl -i -p -e "s,^CROSS_SYSTEM_HEADER_DIR.*,CROSS_SYSTEM_HEADER_DIR=\
2003-01-21 07:42:01 +01:00
/usr/include,;" $(GCC_DIR)/gcc/Makefile.in;
2003-01-07 22:00:41 +01:00
perl -i -p -e "s,^#define.*STANDARD_INCLUDE_DIR.*,#define STANDARD_INCLUDE_DIR \
\"/usr/include\",;" $(GCC_DIR)/gcc/cppdefault.h;
mkdir -p $(GCC_BUILD_DIR3)
touch $(GCC_BUILD_DIR3)/.gcc_build_hacks
2003-01-07 22:00:41 +01:00
$(GCC_BUILD_DIR3)/.configured: $(GCC_BUILD_DIR3)/.gcc_build_hacks
2003-01-21 07:42:01 +01:00
mkdir -p $(TARGET_DIR)/usr/lib/gcc-lib
mkdir -p $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)
(cd $(TARGET_DIR)/usr/$(GNU_TARGET_NAME); ln -fs ../include)
(cd $(TARGET_DIR)/usr/$(GNU_TARGET_NAME); ln -fs ../include sys-include)
2003-02-12 09:10:40 +01:00
(cd $(GCC_BUILD_DIR3); PATH=$(TARGET_PATH) \
2003-01-19 12:24:32 +01:00
AS=$(TARGET_CROSS)as \
LD=$(TARGET_CROSS)ld \
AR=$(TARGET_CROSS)ar \
NM=$(TARGET_CROSS)nm \
CC=$(TARGET_CROSS)gcc \
GCC=$(TARGET_CROSS)gcc \
CXX=$(TARGET_CROSS)c++ \
RANLIB=$(TARGET_CROSS)ranlib \
$(GCC_DIR)/configure \
--target=$(GNU_TARGET_NAME) \
2003-01-21 07:42:01 +01:00
--host=$(GNU_TARGET_NAME) \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--localstatedir=/var \
--mandir=/usr/man \
--infodir=/usr/info \
--with-local-prefix=/usr/local \
--libdir=/usr/lib \
--includedir=$(TARGET_DIR)/usr/include \
--with-gxx-include-dir=$(TARGET_DIR)/usr/include/c++ \
--disable-shared $(MULTILIB) \
--enable-target-optspace --disable-nls \
--with-gnu-ld --disable-__cxa_atexit \
--enable-languages=$(TARGET_LANGUAGES) \
$(EXTRA_GCC_CONFIG_OPTIONS) \
--program-prefix="" \
);
touch $(GCC_BUILD_DIR3)/.configured
$(GCC_BUILD_DIR3)/.compiled: $(GCC_BUILD_DIR3)/.configured
2003-01-19 12:24:32 +01:00
AS=$(TARGET_CROSS)as \
LD=$(TARGET_CROSS)ld \
AR=$(TARGET_CROSS)ar \
NM=$(TARGET_CROSS)nm \
CC=$(TARGET_CROSS)gcc \
GCC=$(TARGET_CROSS)gcc \
2003-01-21 07:42:01 +01:00
CXX=$(TARGET_CROSS)g++ \
2003-01-19 12:24:32 +01:00
RANLIB=$(TARGET_CROSS)ranlib \
$(MAKE) -C $(GCC_BUILD_DIR3)
touch $(GCC_BUILD_DIR3)/.compiled
$(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
2003-01-21 07:42:01 +01:00
$(MAKE) \
CC=$(TARGET_CROSS)gcc \
2003-01-19 12:24:32 +01:00
AS=$(TARGET_CROSS)as \
LD=$(TARGET_CROSS)ld \
AR=$(TARGET_CROSS)ar \
NM=$(TARGET_CROSS)nm \
CC=$(TARGET_CROSS)gcc \
GCC=$(TARGET_CROSS)gcc \
2003-01-21 07:42:01 +01:00
CXX=$(TARGET_CROSS)g++ \
2003-01-19 12:24:32 +01:00
RANLIB=$(TARGET_CROSS)ranlib \
2003-01-07 22:00:41 +01:00
prefix=$(TARGET_DIR)/usr \
exec_prefix=$(TARGET_DIR)/usr \
bindir=$(TARGET_DIR)/usr/bin \
sbindir=$(TARGET_DIR)/usr/sbin \
2003-01-21 07:42:01 +01:00
libexecdir=$(TARGET_DIR)/usr/libexec \
2003-01-07 22:00:41 +01:00
datadir=$(TARGET_DIR)/usr/share \
sysconfdir=$(TARGET_DIR)/etc \
sharedstatedir=$(TARGET_DIR)/usr/com \
localstatedir=$(TARGET_DIR)/var \
libdir=$(TARGET_DIR)/usr/lib \
2003-01-21 07:42:01 +01:00
includedir=$(TARGET_DIR)/usr/include \
oldincludedir=$(TARGET_DIR)/usr/include \
2003-01-07 22:00:41 +01:00
infodir=$(TARGET_DIR)/usr/info \
mandir=$(TARGET_DIR)/usr/man \
2003-01-21 07:42:01 +01:00
gxx_include_dir=$(TARGET_DIR)/usr/include/c++ \
tooldir=$(TARGET_DIR)/usr/$(GNU_TARGET_NAME) \
build_tooldir=$(TARGET_DIR)/usr/$(GNU_TARGET_NAME) \
2003-01-21 17:29:56 +01:00
-C $(GCC_BUILD_DIR3) install-gcc;
2003-01-20 20:24:02 +01:00
(cd $(TARGET_DIR)/usr/bin; ln -fs gcc cc)
2003-01-21 07:42:01 +01:00
rm -rf $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/include
rm -rf $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
2003-02-12 09:10:40 +01:00
rm -rf $(TARGET_DIR)/usr/include/include $(TARGET_DIR)/usr/usr
2003-01-20 20:24:02 +01:00
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-cpp $(TARGET_DIR)/usr/bin/cpp
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-gcc $(TARGET_DIR)/usr/bin/gcc
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-c++ $(TARGET_DIR)/usr/bin/c++
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-g++ $(TARGET_DIR)/usr/bin/g++
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-c++filt $(TARGET_DIR)/usr/bin/c++filt
2003-01-21 17:29:56 +01:00
-cp -dpf $(STAGING_DIR)/lib/libgcc* $(TARGET_DIR)/lib/
2003-02-12 09:10:40 +01:00
chmod a-x $(STAGING_DIR)/lib/*++*
2003-01-21 17:29:56 +01:00
cp -a $(STAGING_DIR)/lib/*++* $(TARGET_DIR)/lib/
2003-01-28 12:33:24 +01:00
cp -a $(STAGING_DIR)/include/c++ $(TARGET_DIR)/usr/include/
2003-02-12 09:10:40 +01:00
-mv $(TARGET_DIR)/lib/*.a $(TARGET_DIR)/usr/lib/
-mv $(TARGET_DIR)/lib/*.la $(TARGET_DIR)/usr/lib/
rm -f $(TARGET_DIR)/lib/libstdc++.so
2003-02-15 23:58:44 +01:00
(cd $(TARGET_DIR)/usr/lib; ln -fs /lib/libstdc++.so.5.0.2 libstdc++.so)
2003-01-21 07:42:01 +01:00
-$(STRIP) $(TARGET_DIR)/bin/*
-$(STRIP) $(TARGET_DIR)/usr/bin/*
2003-01-20 20:24:02 +01:00
rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
$(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
rm -f $(TARGET_DIR)/usr/lib/*.la*
2003-01-21 07:42:01 +01:00
# gcc "fixincludes" step is totally broken and takes unwanted
# stuff from the host system. Fix that here.
rm -rf $(TARGET_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/*
cp -a $(STAGING_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/* \
$(TARGET_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/
2003-01-20 20:24:02 +01:00
touch -c $(TARGET_DIR)/usr/bin/gcc
gcc_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc
gcc_target-clean:
rm -rf $(GCC_BUILD_DIR3)
rm -f $(TARGET_DIR)/bin/$(GNU_TARGET_NAME)*
gcc_target-dirclean:
rm -rf $(GCC_BUILD_DIR3)