make/devkit/Tools.gmk

Print this page




  32 # NOTE: There is a bug here. We don't limit the
  33 # PATH when building BUILD -> BUILD, which means that
  34 # if you configure after you've once build the BUILD->BUILD
  35 # compiler THAT one will be picked up as the compiler for itself.
  36 # This is not so great, especially if you did a partial delete
  37 # of the target tree.
  38 #
  39 # Fix this...
  40 #
  41 
  42 $(info TARGET=$(TARGET))
  43 $(info HOST=$(HOST))
  44 $(info BUILD=$(BUILD))
  45 
  46 ARCH := $(word 1,$(subst -, ,$(TARGET)))
  47 
  48 ##########################################################################################
  49 # Define external dependencies
  50 
  51 # Latest that could be made to work.
  52 gcc_ver := gcc-4.7.3
  53 binutils_ver := binutils-2.22
  54 ccache_ver := ccache-3.1.9
  55 mpfr_ver := mpfr-3.0.1
  56 gmp_ver := gmp-4.3.2
  57 mpc_ver := mpc-1.0.1
  58 
  59 GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.bz2
  60 BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.bz2
  61 CCACHE := http://samba.org/ftp/ccache/$(ccache_ver).tar.gz
  62 MPFR := http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2
  63 GMP := http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2
  64 MPC := http://www.multiprecision.org/mpc/download/${mpc_ver}.tar.gz
  65 
  66 # RPMs in OEL5.5

  67 RPM_LIST := \
  68     kernel-headers \
  69     glibc-2 glibc-headers glibc-devel \
  70     cups-libs cups-devel \
  71     libX11 libX11-devel \
  72     xorg-x11-proto-devel \
  73     alsa-lib alsa-lib-devel \
  74     libXext libXext-devel \
  75     libXtst libXtst-devel \
  76     libXrender libXrender-devel \
  77     freetype freetype-devel \
  78     libXt libXt-devel \
  79     libSM libSM-devel \
  80     libICE libICE-devel \
  81     libXi libXi-devel \
  82     libXdmcp libXdmcp-devel \
  83     libXau libXau-devel \
  84     libgcc
  85 
  86 


 104 ifeq ($(RPM_FILE_LIST),)
 105   $(error Found no RPMs, RPM_DIR must point to list of directories to search for RPMs)
 106 endif
 107 
 108 ##########################################################################################
 109 # Define common directories and files
 110 
 111 # Ensure we have 32-bit libs also for x64. We enable mixed-mode.
 112 ifeq (x86_64,$(ARCH))
 113   LIBDIRS := lib64 lib
 114   CFLAGS_lib := -m32
 115 else
 116   LIBDIRS := lib
 117 endif
 118 
 119 # Define directories
 120 RESULT := $(OUTPUT_ROOT)/result
 121 BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET)
 122 PREFIX := $(RESULT)/$(HOST)
 123 TARGETDIR := $(PREFIX)/$(TARGET)
 124 SYSROOT := $(TARGETDIR)/sys-root
 125 DOWNLOAD := $(OUTPUT_ROOT)/download
 126 SRCDIR := $(OUTPUT_ROOT)/src
 127 
 128 # Marker file for unpacking rpms
 129 rpms := $(SYSROOT)/rpms_unpacked
 130 
 131 # Need to patch libs that are linker scripts to use non-absolute paths
 132 libs := $(SYSROOT)/libs_patched
 133 
 134 ##########################################################################################
 135 # Unpack source packages
 136 
 137 # Generate downloading + unpacking of sources.
 138 define Download
 139   $(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1))))))
 140   $(1)_CFG = $$($(1)_DIR)/configure
 141   $(1)_FILE = $(DOWNLOAD)/$(notdir $($(1)))
 142 
 143   $$($(1)_CFG) : $$($(1)_FILE)
 144         mkdir -p $$(SRCDIR)


 167 endef
 168 
 169 %.unpacked :
 170         $(info Unpacking target rpms and libraries from $<)
 171         @(mkdir -p $(@D); \
 172         cd $(@D); \
 173         rpm2cpio $< | \
 174             cpio --extract --make-directories \
 175                 -f \
 176                 "./usr/share/doc/*" \
 177                 "./usr/share/man/*" \
 178                 "./usr/X11R6/man/*" \
 179                 "*/X11/locale/*" \
 180             || die ; )
 181         touch $@
 182 
 183 $(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p))))
 184 
 185 ##########################################################################################
 186 
 187 # Note: MUST create a <sys-root>/usr/lib even if not really needed.
 188 # gcc will use a path relative to it to resolve lib64. (x86_64).
 189 # we're creating multi-lib compiler with 32bit libc as well, so we should
 190 # have it anyway, but just to make sure...
 191 # Patch libc.so and libpthread.so to force linking against libraries in sysroot
 192 # and not the ones installed on the build machine.
 193 $(libs) : $(rpms)
 194         @echo Patching libc and pthreads
 195         @(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \
 196           (cat $$f | sed -e 's|/usr/lib64/||g' \
 197               -e 's|/usr/lib/||g' \
 198               -e 's|/lib64/||g' \
 199               -e 's|/lib/||g' ) > $$f.tmp ; \
 200           mv $$f.tmp $$f ; \
 201         done)
 202         @mkdir -p $(SYSROOT)/usr/lib
 203         @touch $@
 204 
 205 ##########################################################################################
 206 
 207 # Define marker files for each source package to be compiled


 442   $(gccpatch) :
 443         @echo 'done'
 444 endif
 445 
 446 ##########################################################################################
 447 # Build in two steps.
 448 # make <default>
 449 # make install.
 450 # Use path to our build hosts cross tools
 451 # Always need to build cross tools for build host self.
 452 $(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile
 453         $(info Building $(basename $@). Log in $(<D)/log.build)
 454         $(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1
 455         @echo -n 'installing...'
 456         $(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.install 2>&1
 457         @touch $@
 458         @echo 'done'
 459 
 460 ##########################################################################################
 461 













 462 bfdlib : $(bfdlib)
 463 binutils : $(binutils)
 464 rpms : $(rpms)
 465 libs : $(libs)
 466 sysroot : rpms libs
 467 gcc : sysroot $(gcc) $(gccpatch)
 468 all : binutils gcc bfdlib
 469 
 470 # this is only built for host. so separate.
 471 ccache : $(ccache)



 472 
 473 .PHONY : gcc all binutils bfdlib link_libs rpms libs sysroot


  32 # NOTE: There is a bug here. We don't limit the
  33 # PATH when building BUILD -> BUILD, which means that
  34 # if you configure after you've once build the BUILD->BUILD
  35 # compiler THAT one will be picked up as the compiler for itself.
  36 # This is not so great, especially if you did a partial delete
  37 # of the target tree.
  38 #
  39 # Fix this...
  40 #
  41 
  42 $(info TARGET=$(TARGET))
  43 $(info HOST=$(HOST))
  44 $(info BUILD=$(BUILD))
  45 
  46 ARCH := $(word 1,$(subst -, ,$(TARGET)))
  47 
  48 ##########################################################################################
  49 # Define external dependencies
  50 
  51 # Latest that could be made to work.
  52 gcc_ver := gcc-4.8.2
  53 binutils_ver := binutils-2.24
  54 ccache_ver := ccache-3.1.9
  55 mpfr_ver := mpfr-3.0.1
  56 gmp_ver := gmp-4.3.2
  57 mpc_ver := mpc-1.0.1
  58 
  59 GCC := http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.bz2
  60 BINUTILS := http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.bz2
  61 CCACHE := http://samba.org/ftp/ccache/$(ccache_ver).tar.gz
  62 MPFR := http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2
  63 GMP := http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2
  64 MPC := http://www.multiprecision.org/mpc/download/${mpc_ver}.tar.gz
  65 
  66 # RPMs in OEL5.5
  67 LINUX_VERSION := OEL5.5
  68 RPM_LIST := \
  69     kernel-headers \
  70     glibc-2 glibc-headers glibc-devel \
  71     cups-libs cups-devel \
  72     libX11 libX11-devel \
  73     xorg-x11-proto-devel \
  74     alsa-lib alsa-lib-devel \
  75     libXext libXext-devel \
  76     libXtst libXtst-devel \
  77     libXrender libXrender-devel \
  78     freetype freetype-devel \
  79     libXt libXt-devel \
  80     libSM libSM-devel \
  81     libICE libICE-devel \
  82     libXi libXi-devel \
  83     libXdmcp libXdmcp-devel \
  84     libXau libXau-devel \
  85     libgcc
  86 
  87 


 105 ifeq ($(RPM_FILE_LIST),)
 106   $(error Found no RPMs, RPM_DIR must point to list of directories to search for RPMs)
 107 endif
 108 
 109 ##########################################################################################
 110 # Define common directories and files
 111 
 112 # Ensure we have 32-bit libs also for x64. We enable mixed-mode.
 113 ifeq (x86_64,$(ARCH))
 114   LIBDIRS := lib64 lib
 115   CFLAGS_lib := -m32
 116 else
 117   LIBDIRS := lib
 118 endif
 119 
 120 # Define directories
 121 RESULT := $(OUTPUT_ROOT)/result
 122 BUILDDIR := $(OUTPUT_ROOT)/$(HOST)/$(TARGET)
 123 PREFIX := $(RESULT)/$(HOST)
 124 TARGETDIR := $(PREFIX)/$(TARGET)
 125 SYSROOT := $(TARGETDIR)/sysroot
 126 DOWNLOAD := $(OUTPUT_ROOT)/download
 127 SRCDIR := $(OUTPUT_ROOT)/src
 128 
 129 # Marker file for unpacking rpms
 130 rpms := $(SYSROOT)/rpms_unpacked
 131 
 132 # Need to patch libs that are linker scripts to use non-absolute paths
 133 libs := $(SYSROOT)/libs_patched
 134 
 135 ##########################################################################################
 136 # Unpack source packages
 137 
 138 # Generate downloading + unpacking of sources.
 139 define Download
 140   $(1)_DIR = $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1))))))
 141   $(1)_CFG = $$($(1)_DIR)/configure
 142   $(1)_FILE = $(DOWNLOAD)/$(notdir $($(1)))
 143 
 144   $$($(1)_CFG) : $$($(1)_FILE)
 145         mkdir -p $$(SRCDIR)


 168 endef
 169 
 170 %.unpacked :
 171         $(info Unpacking target rpms and libraries from $<)
 172         @(mkdir -p $(@D); \
 173         cd $(@D); \
 174         rpm2cpio $< | \
 175             cpio --extract --make-directories \
 176                 -f \
 177                 "./usr/share/doc/*" \
 178                 "./usr/share/man/*" \
 179                 "./usr/X11R6/man/*" \
 180                 "*/X11/locale/*" \
 181             || die ; )
 182         touch $@
 183 
 184 $(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p))))
 185 
 186 ##########################################################################################
 187 
 188 # Note: MUST create a <sysroot>/usr/lib even if not really needed.
 189 # gcc will use a path relative to it to resolve lib64. (x86_64).
 190 # we're creating multi-lib compiler with 32bit libc as well, so we should
 191 # have it anyway, but just to make sure...
 192 # Patch libc.so and libpthread.so to force linking against libraries in sysroot
 193 # and not the ones installed on the build machine.
 194 $(libs) : $(rpms)
 195         @echo Patching libc and pthreads
 196         @(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \
 197           (cat $$f | sed -e 's|/usr/lib64/||g' \
 198               -e 's|/usr/lib/||g' \
 199               -e 's|/lib64/||g' \
 200               -e 's|/lib/||g' ) > $$f.tmp ; \
 201           mv $$f.tmp $$f ; \
 202         done)
 203         @mkdir -p $(SYSROOT)/usr/lib
 204         @touch $@
 205 
 206 ##########################################################################################
 207 
 208 # Define marker files for each source package to be compiled


 443   $(gccpatch) :
 444         @echo 'done'
 445 endif
 446 
 447 ##########################################################################################
 448 # Build in two steps.
 449 # make <default>
 450 # make install.
 451 # Use path to our build hosts cross tools
 452 # Always need to build cross tools for build host self.
 453 $(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile
 454         $(info Building $(basename $@). Log in $(<D)/log.build)
 455         $(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1
 456         @echo -n 'installing...'
 457         $(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.install 2>&1
 458         @touch $@
 459         @echo 'done'
 460 
 461 ##########################################################################################
 462 
 463 $(PREFIX)/devkit.info: FRC
 464         @echo 'Creating devkit.info in the root of the kit'
 465         rm -f $@
 466         touch $@
 467         echo '# This file describes to configure how to interpret the contents of this' >> $@
 468         echo '# devkit' >> $@
 469         echo '' >> $@
 470         echo 'DEVKIT_NAME="$(gcc_ver) - $(LINUX_VERSION)"' >> $@
 471         echo 'DEVKIT_TOOLCHAIN_PATH="$$DEVKIT_ROOT/bin"' >> $@
 472         echo 'DEVKIT_SYSROOT="$$DEVKIT_ROOT/$$host/sysroot"' >> $@
 473 
 474 ##########################################################################################
 475 
 476 bfdlib : $(bfdlib)
 477 binutils : $(binutils)
 478 rpms : $(rpms)
 479 libs : $(libs)
 480 sysroot : rpms libs
 481 gcc : sysroot $(gcc) $(gccpatch)
 482 all : binutils gcc bfdlib $(PREFIX)/devkit.info
 483 
 484 # this is only built for host. so separate.
 485 ccache : $(ccache)
 486 
 487 # Force target
 488 FRC:
 489 
 490 .PHONY : gcc all binutils bfdlib link_libs rpms libs sysroot