All pastes #1019405 Raw Edit

Untitled

public text v1 · immutable
#1019405 ·published 2008-05-15 20:23 UTC
rendered paste body
###########################################################
#
# gcc
#
###########################################################

# You must replace "gcc" and "GCC" with the lower case name and
# upper case name of your new package.  Some places below will say
# "Do not change this" - that does not include this global change,
# which must always be done to ensure we have unique names.

#
# GCC_VERSION, GCC_SITE and GCC_SOURCE define
# the upstream location of the source code for the package.
# GCC_DIR is the directory which is created when the source
# archive is unpacked.
# GCC_UNZIP is the command used to unzip the source.
# It is usually "zcat" (for .gz) or "bzcat" (for .bz2)
#
# You should change all these variables to suit your package.
# Please make sure that you add a description, and that you
# list all your packages' dependencies, seperated by commas.
# 
# If you list yourself as MAINTAINER, please give a valid email
# address, and indicate your irc nick if it cannot be easily deduced
# from your name or email address.  If you leave MAINTAINER set to
# "NSLU2 Linux" other developers will feel free to edit.
#
GCC_VERSION=4.1.2
GCC_SITE=http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)
GCC_SOURCE=gcc-$(GCC_VERSION).tar.bz2
GCC_DIR=gcc-$(GCC_VERSION)
GCC_UNZIP=bzcat
GCC_MAINTAINER=NSLU2 Linux <nslu2-linux@yahoogroups.com>
GCC_DESCRIPTION=Describe gcc here.
GCC_SECTION=base
GCC_PRIORITY=optional
GCC_DEPENDS=binutils
GCC_SUGGESTS=
GCC_CONFLICTS=

#
# GCC_IPK_VERSION should be incremented when the ipk changes.
#
GCC_IPK_VERSION=1

#
# GCC_CONFFILES should be a list of user-editable files
#GCC_CONFFILES=/opt/etc/gcc.conf /opt/etc/init.d/SXXgcc

#
# GCC_PATCHES should list any patches, in the the order in
# which they should be applied to the source code.
#
GCC_PATCHES=	$(GCC_SOURCE_DIR)/100-uclibc-conf.patch			\
		$(GCC_SOURCE_DIR)/110-arm-eabi.patch			\
		$(GCC_SOURCE_DIR)/200-uclibc-locale.patch		\
		$(GCC_SOURCE_DIR)/300-libstdc++-pic.patch		\
		$(GCC_SOURCE_DIR)/301-missing-execinfo_h.patch		\
		$(GCC_SOURCE_DIR)/302-c99-snprintf.patch		\
		$(GCC_SOURCE_DIR)/303-c99-complex-ugly-hack.patch	\
		$(GCC_SOURCE_DIR)/304-index_macro.patch			\
		$(GCC_SOURCE_DIR)/500-avr32.patch			\
		$(GCC_SOURCE_DIR)/740-sh-pr24836.patch			\
		$(GCC_SOURCE_DIR)/800-arm-bigendian.patch		\
		$(GCC_SOURCE_DIR)/900-c++_fixes.patch

#
# If the compilation of the package requires additional
# compilation or linking flags, then list them here.
#
GCC_CPPFLAGS=
GCC_LDFLAGS=

#
# GCC_BUILD_DIR is the directory in which the build is done.
# GCC_SOURCE_DIR is the directory which holds all the
# patches and ipkg control files.
# GCC_IPK_DIR is the directory in which the ipk is built.
# GCC_IPK is the name of the resulting ipk files.
#
# You should not change any of these variables.
#
GCC_BUILD_DIR=$(BUILD_DIR)/gcc
GCC_SOURCE_DIR=$(SOURCE_DIR)/gcc
GCC_IPK_DIR=$(BUILD_DIR)/gcc-$(GCC_VERSION)-ipk
GCC_IPK=$(BUILD_DIR)/gcc_$(GCC_VERSION)-$(GCC_IPK_VERSION)_$(TARGET_ARCH).ipk

.PHONY: gcc-source gcc-unpack gcc gcc-stage gcc-ipk gcc-clean gcc-dirclean gcc-check

#
# This is the dependency on the source code.  If the source is missing,
# then it will be fetched from the site using wget.
#
$(DL_DIR)/$(GCC_SOURCE):
	$(WGET) -P $(DL_DIR) $(GCC_SITE)/$(@F) || \
	$(WGET) -P $(DL_DIR) $(SOURCES_NLO_SITE)/$(@F)

#
# The source code depends on it existing within the download directory.
# This target will be called by the top level Makefile to download the
# source code's archive (.tar.gz, .bz2, etc.)
#
gcc-source: $(DL_DIR)/$(GCC_SOURCE) $(GCC_PATCHES)

#
# This target unpacks the source code in the build directory.
# If the source archive is not .tar.gz or .tar.bz2, then you will need
# to change the commands here.  Patches to the source code are also
# applied in this target as required.
#
# This target also configures the build within the build directory.
# Flags such as LDFLAGS and CPPFLAGS should be passed into configure
# and NOT $(MAKE) below.  Passing it to configure causes configure to
# correctly BUILD the Makefile with the right paths, where passing it
# to Make causes it to override the default search paths of the compiler.
#
# If the compilation of the package requires other packages to be staged
# first, then do that first (e.g. "$(MAKE) <bar>-stage <baz>-stage").
#
# If the package uses  GNU libtool, you should invoke $(PATCH_LIBTOOL) as
# shown below to make various patches to it.
#
$(GCC_BUILD_DIR)/.configured: $(DL_DIR)/$(GCC_SOURCE) $(GCC_PATCHES) #make/gcc.mk
	rm -rf $(BUILD_DIR)/$(GCC_DIR) $(@D)
	$(GCC_UNZIP) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(BUILD_DIR) -xvf -
	if test -n "$(GCC_PATCHES)" ; \
		then cat $(GCC_PATCHES) | \
		patch -d $(BUILD_DIR)/$(GCC_DIR) -p1 ; \
	fi
	if test "$(BUILD_DIR)/$(GCC_DIR)" != "$(@D)" ; \
		then mv $(BUILD_DIR)/$(GCC_DIR) $(@D) ; \
	fi
	(cd $(@D); \
		$(TARGET_CONFIGURE_OPTS) \
		CPPFLAGS="$(STAGING_CPPFLAGS) $(GCC_CPPFLAGS)" \
		LDFLAGS="$(STAGING_LDFLAGS) $(GCC_LDFLAGS)" \
		ORIGINAL_NM_FOR_TARGET=$(TARGET_NM) \
		./configure \
		--build=$(GNU_HOST_NAME) \
		--host=$(GNU_TARGET_NAME)-uclibc \
		--target=$(GNU_TARGET_NAME)-uclibc \
		--prefix=/opt \
		--disable-nls \
		--disable-static \
		--with-as=$(TARGET_AS) \
		--with-ld=$(TARGET_LD) \
		--enable-languages=c,c++ \
	)
	#$(PATCH_LIBTOOL) $(@D)/libtool
	touch $@

gcc-unpack: $(GCC_BUILD_DIR)/.configured

#
# This builds the actual binary.
#
$(GCC_BUILD_DIR)/.built: $(GCC_BUILD_DIR)/.configured
	rm -f $@
	echo $(PATH)
	rm $(STAGING_DIR)/bin/$(TARGET_ARCH)-$(TARGET_OS)-cc
	ln -s $(TARGET_CROSS_TOP)/bin/$(TARGET_ARCH)-$(TARGET_OS)-gcc $(STAGING_DIR)/bin/$(TARGET_ARCH)-$(TARGET_OS)-cc
	PATH=$(PATH):$(STAGING_DIR)/bin;$(MAKE) -C $(@D)
	touch $@

#
# This is the build convenience target.
#
gcc: $(GCC_BUILD_DIR)/.built

#
# If you are building a library, then you need to stage it too.
#
$(GCC_BUILD_DIR)/.staged: $(GCC_BUILD_DIR)/.built
	rm -f $@
	$(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
	touch $@

gcc-stage: $(GCC_BUILD_DIR)/.staged

#
# This rule creates a control file for ipkg.  It is no longer
# necessary to create a seperate control file under sources/gcc
#
$(GCC_IPK_DIR)/CONTROL/control:
	@install -d $(@D)
	@rm -f $@
	@echo "Package: gcc" >>$@
	@echo "Architecture: $(TARGET_ARCH)" >>$@
	@echo "Priority: $(GCC_PRIORITY)" >>$@
	@echo "Section: $(GCC_SECTION)" >>$@
	@echo "Version: $(GCC_VERSION)-$(GCC_IPK_VERSION)" >>$@
	@echo "Maintainer: $(GCC_MAINTAINER)" >>$@
	@echo "Source: $(GCC_SITE)/$(GCC_SOURCE)" >>$@
	@echo "Description: $(GCC_DESCRIPTION)" >>$@
	@echo "Depends: $(GCC_DEPENDS)" >>$@
	@echo "Suggests: $(GCC_SUGGESTS)" >>$@
	@echo "Conflicts: $(GCC_CONFLICTS)" >>$@

#
# This builds the IPK file.
#
# Binaries should be installed into $(GCC_IPK_DIR)/opt/sbin or $(GCC_IPK_DIR)/opt/bin
# (use the location in a well-known Linux distro as a guide for choosing sbin or bin).
# Libraries and include files should be installed into $(GCC_IPK_DIR)/opt/{lib,include}
# Configuration files should be installed in $(GCC_IPK_DIR)/opt/etc/gcc/...
# Documentation files should be installed in $(GCC_IPK_DIR)/opt/doc/gcc/...
# Daemon startup scripts should be installed in $(GCC_IPK_DIR)/opt/etc/init.d/S??gcc
#
# You may need to patch your application to make it use these locations.
#
$(GCC_IPK): $(GCC_BUILD_DIR)/.built
	rm -rf $(GCC_IPK_DIR) $(BUILD_DIR)/gcc_*_$(TARGET_ARCH).ipk
	$(MAKE) -C $(GCC_BUILD_DIR) DESTDIR=$(GCC_IPK_DIR) install
	rm -f $(GCC_IPK_DIR)/opt/lib/libiberty.a $(GCC_IPK_DIR)/opt/info/dir $(GCC_IPK_DIR)/opt/info/dir.old
	$(STRIP_COMMAND) $(GCC_IPK_DIR)/opt/gcc
	$(STRIP_COMMAND) $(GCC_IPK_DIR)/opt/cpp
	$(STRIP_COMMAND) $(GCC_IPK_DIR)/opt/gcov
#	install -d $(GCC_IPK_DIR)/opt/etc/
#	install -m 644 $(GCC_SOURCE_DIR)/gcc.conf $(GCC_IPK_DIR)/opt/etc/gcc.conf
#	install -d $(GCC_IPK_DIR)/opt/etc/init.d
#	install -m 755 $(GCC_SOURCE_DIR)/rc.gcc $(GCC_IPK_DIR)/opt/etc/init.d/SXXgcc
#	sed -i -e '/^#!/aOPTWARE_TARGET=${OPTWARE_TARGET}' $(GCC_IPK_DIR)/opt/etc/init.d/SXXgcc
	$(MAKE) $(GCC_IPK_DIR)/CONTROL/control
#	install -m 755 $(GCC_SOURCE_DIR)/postinst $(GCC_IPK_DIR)/CONTROL/postinst
#	sed -i -e '/^#!/aOPTWARE_TARGET=${OPTWARE_TARGET}' $(GCC_IPK_DIR)/CONTROL/postinst
#	install -m 755 $(GCC_SOURCE_DIR)/prerm $(GCC_IPK_DIR)/CONTROL/prerm
#	sed -i -e '/^#!/aOPTWARE_TARGET=${OPTWARE_TARGET}' $(GCC_IPK_DIR)/CONTROL/prerm
#	if test -n "$(UPD-ALT_PREFIX)"; then \
		sed -i -e '/^[ 	]*update-alternatives /s|update-alternatives|$(UPD-ALT_PREFIX)/bin/&|' \
			$(GCC_IPK_DIR)/CONTROL/postinst $(GCC_IPK_DIR)/CONTROL/prerm; \
	fi
	echo $(GCC_CONFFILES) | sed -e 's/ /\n/g' > $(GCC_IPK_DIR)/CONTROL/conffiles
	cd $(BUILD_DIR); $(IPKG_BUILD) $(GCC_IPK_DIR)

#
# This is called from the top level makefile to create the IPK file.
#
gcc-ipk: $(GCC_IPK)

#
# This is called from the top level makefile to clean all of the built files.
#
gcc-clean:
	rm -f $(GCC_BUILD_DIR)/.built
	-$(MAKE) -C $(GCC_BUILD_DIR) clean

#
# This is called from the top level makefile to clean all dynamically created
# directories.
#
gcc-dirclean:
	rm -rf $(BUILD_DIR)/$(GCC_DIR) $(GCC_BUILD_DIR) $(GCC_IPK_DIR) $(GCC_IPK)
#
#
# Some sanity check for the package.
#
gcc-check: $(GCC_IPK)
	perl scripts/optware-check-package.pl --target=$(OPTWARE_TARGET) $(GCC_IPK)