common/makefiles/devkit/Tools.gmk
author rbackman
Mon, 15 Jul 2013 12:06:50 +0200
changeset 18935 10110aabe1eb
parent 18021 680b9b43e2d6
child 20363 fa7663fc5d50
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18021
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     1
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     2
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     4
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    10
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    15
# accompanied this code).
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    16
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    20
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    23
# questions.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    24
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    25
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    26
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    27
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    28
# Workhorse makefile for creating ONE cross compiler
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    29
# Needs either to be from BUILD -> BUILD OR have 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    30
# BUILD -> HOST prebuilt
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    31
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    32
# NOTE: There is a bug here. We don't limit the 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    33
# PATH when building BUILD -> BUILD, which means that 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    34
# if you configure after you've once build the BUILD->BUILD
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    35
# compiler THAT one will be picked up as the compiler for itself.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    36
# This is not so great, especially if you did a partial delete
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    37
# of the target tree. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    38
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    39
# Fix this...
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    40
#
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    41
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    42
$(info TARGET=$(TARGET))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    43
$(info HOST=$(HOST))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    44
$(info BUILD=$(BUILD))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    45
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    46
ARCH		:= $(word 1,$(subst -, ,$(TARGET)))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    47
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    48
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    49
# Define external dependencies
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    50
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    51
# Latest that could be made to work.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    52
gcc_ver		:= gcc-4.7.3
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    53
binutils_ver	:= binutils-2.22
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    54
ccache_ver	:= ccache-3.1.9
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    55
mpfr_ver        := mpfr-3.0.1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    56
gmp_ver         := gmp-4.3.2
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    57
mpc_ver		:= mpc-1.0.1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    58
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    59
GCC		:= http://ftp.gnu.org/pub/gnu/gcc/$(gcc_ver)/$(gcc_ver).tar.bz2
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    60
BINUTILS	:= http://ftp.gnu.org/pub/gnu/binutils/$(binutils_ver).tar.bz2
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    61
CCACHE		:= http://samba.org/ftp/ccache/$(ccache_ver).tar.gz
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    62
MPFR		:= http://www.mpfr.org/${mpfr_ver}/${mpfr_ver}.tar.bz2
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    63
GMP 		:= http://ftp.gnu.org/pub/gnu/gmp/${gmp_ver}.tar.bz2
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    64
MPC		:= http://www.multiprecision.org/mpc/download/${mpc_ver}.tar.gz
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    65
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    66
# RPMs in OEL5.5
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    67
RPM_LIST 	:= \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    68
		kernel-headers \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    69
		glibc-2 glibc-headers glibc-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    70
		cups-libs cups-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    71
		libX11 libX11-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    72
		xorg-x11-proto-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    73
		alsa-lib alsa-lib-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    74
		libXext libXext-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    75
		libXtst libXtst-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    76
		libXrender libXrender-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    77
		freetype freetype-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    78
		libXt libXt-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    79
		libSM libSM-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    80
		libICE libICE-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    81
		libXi libXi-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    82
		libXdmcp libXdmcp-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    83
		libXau libXau-devel \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    84
		libgcc
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    85
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    86
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    87
ifeq ($(ARCH),x86_64)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    88
  RPM_DIR ?= $(RPM_DIR_x86_64)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    89
  RPM_ARCHS := x86_64
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    90
  ifeq ($(BUILD),$(HOST))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    91
    ifeq ($(TARGET),$(HOST))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    92
      # When building the native compiler for x86_64, enable mixed mode.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    93
      RPM_ARCHS	+= i386 i686
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    94
    endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    95
  endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    96
else
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    97
  RPM_DIR ?= $(RPM_DIR_i686)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    98
  RPM_ARCHS := i386 i686
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
    99
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   100
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   101
# Sort to remove duplicates
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   102
RPM_FILE_LIST := $(sort $(foreach a,$(RPM_ARCHS),$(wildcard $(patsubst %,$(RPM_DIR)/%*$a.rpm,$(RPM_LIST)))))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   103
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   104
ifeq ($(RPM_FILE_LIST),)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   105
  $(error Found no RPMs, RPM_DIR must point to list of directories to search for RPMs)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   106
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   107
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   108
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   109
# Define common directories and files
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   110
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   111
# Ensure we have 32-bit libs also for x64. We enable mixed-mode.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   112
ifeq (x86_64,$(ARCH))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   113
  LIBDIRS	:= lib64 lib
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   114
  CFLAGS_lib	:= -m32
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   115
else
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   116
  LIBDIRS 	:= lib
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   117
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   118
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   119
# Define directories
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   120
RESULT		:= $(OUTPUT_ROOT)/result
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   121
BUILDDIR	:= $(OUTPUT_ROOT)/$(HOST)/$(TARGET)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   122
PREFIX		:= $(RESULT)/$(HOST)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   123
TARGETDIR	:= $(PREFIX)/$(TARGET)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   124
SYSROOT		:= $(TARGETDIR)/sys-root
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   125
DOWNLOAD	:= $(OUTPUT_ROOT)/download
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   126
SRCDIR		:= $(OUTPUT_ROOT)/src
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   127
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   128
# Marker file for unpacking rpms
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   129
rpms		:= $(SYSROOT)/rpms_unpacked
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   130
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   131
# Need to patch libs that are linker scripts to use non-absolute paths 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   132
libs		:= $(SYSROOT)/libs_patched
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   133
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   134
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   135
# Unpack source packages
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   136
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   137
# Generate downloading + unpacking of sources. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   138
define Download
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   139
$(1)_DIR	= $(abspath $(SRCDIR)/$(basename $(basename $(notdir $($(1))))))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   140
$(1)_CFG	= $$($(1)_DIR)/configure
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   141
$(1)_FILE	= $(DOWNLOAD)/$(notdir $($(1)))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   142
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   143
$$($(1)_CFG)	: $$($(1)_FILE)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   144
		mkdir -p $$(SRCDIR)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   145
		tar -C $$(SRCDIR) -x$$(if $$(findstring .gz, $$<),z,j)f $$<
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   146
		$$(foreach p,$$(abspath $$(wildcard $$(notdir $$($(1)_DIR)).patch)),	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   147
			echo PATCHING $$(p) ;						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   148
			patch -d $$($(1)_DIR) -p1 -i $$(p) ; 				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   149
			)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   150
		touch $$@
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   151
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   152
$$($(1)_FILE)	:
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   153
		wget -P $(DOWNLOAD) $$($(1))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   154
endef
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   155
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   156
# Download and unpack all source packages
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   157
$(foreach p,GCC BINUTILS CCACHE MPFR GMP MPC,$(eval $(call Download,$(p))))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   158
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   159
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   160
# Unpack RPMS
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   161
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   162
# Note. For building linux you should install rpm2cpio. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   163
define unrpm
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   164
$(SYSROOT)/$(notdir $(1)).unpacked	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   165
		: $(1)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   166
$$(rpms)	: $(SYSROOT)/$(notdir $(1)).unpacked
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   167
endef
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   168
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   169
%.unpacked	:
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   170
		$(info Unpacking target rpms and libraries from $<)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   171
		@(mkdir -p $(@D);					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   172
		cd $(@D);						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   173
		rpm2cpio $< | 						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   174
			cpio --extract --make-directories 		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   175
				-f 					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   176
				"./usr/share/doc/*" 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   177
				"./usr/share/man/*"			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   178
				"./usr/X11R6/man/*" 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   179
				"*/X11/locale/*"			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   180
				|| die ; )
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   181
		touch $@
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   182
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   183
$(foreach p,$(RPM_FILE_LIST),$(eval $(call unrpm,$(p))))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   184
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   185
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   186
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   187
# Note: MUST create a <sys-root>/usr/lib even if not really needed. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   188
# gcc will use a path relative to it to resolve lib64. (x86_64). 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   189
# we're creating multi-lib compiler with 32bit libc as well, so we should 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   190
# have it anyway, but just to make sure...
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   191
# Patch libc.so and libpthread.so to force linking against libraries in sysroot
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   192
# and not the ones installed on the build machine.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   193
$(libs)		: $(rpms)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   194
		@echo Patching libc and pthreads
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   195
		@(for f in `find $(SYSROOT) -name libc.so -o -name libpthread.so`; do \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   196
			(cat $$f | sed -e 's|/usr/lib64/||g' 		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   197
				       -e 's|/usr/lib/||g'		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   198
				       -e 's|/lib64/||g'		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   199
				       -e 's|/lib/||g' ) > $$f.tmp ;	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   200
			mv $$f.tmp $$f				;	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   201
		done)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   202
		@mkdir -p $(SYSROOT)/usr/lib
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   203
		@touch $@
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   204
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   205
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   206
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   207
# Define marker files for each source package to be compiled
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   208
$(foreach t,binutils mpfr gmp mpc gcc ccache,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   209
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   210
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   211
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   212
# Default base config
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   213
CONFIG		= --target=$(TARGET) 					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   214
			--host=$(HOST) --build=$(BUILD)			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   215
			--prefix=$(PREFIX)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   216
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   217
PATHEXT 	= $(RESULT)/$(BUILD)/bin:
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   218
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   219
PATHPRE		= PATH=$(PATHEXT)$(PATH)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   220
BUILDPAR	= -j16
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   221
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   222
# Default commands to when making
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   223
MAKECMD		=
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   224
INSTALLCMD	= install
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   225
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   226
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   227
declare_tools   = CC$(1)=$(2)gcc LD$(1)=$(2)ld AR$(1)=$(2)ar AS$(1)=$(2)as RANLIB$(1)=$(2)ranlib CXX$(1)=$(2)g++ OBJDUMP$(1)=$(2)objdump
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   228
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   229
ifeq ($(HOST),$(BUILD))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   230
ifeq ($(HOST),$(TARGET))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   231
TOOLS		= $(call declare_tools,_FOR_TARGET,)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   232
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   233
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   234
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   235
TOOLS		?=  $(call declare_tools,_FOR_TARGET,$(TARGET)-)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   236
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   237
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   238
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   239
# Create a TARGET bfd + libiberty only. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   240
# Configure one or two times depending on mulitlib arch.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   241
# If multilib, the second should be 32-bit, and we resolve 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   242
# CFLAG_<name> to most likely -m32.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   243
define mk_bfd
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   244
$$(info Libs for $(1)) 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   245
$$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   246
		: CFLAGS += $$(CFLAGS_$(1))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   247
$$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   248
		: LIBDIRS = --libdir=$(TARGETDIR)/$(1)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   249
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   250
bfdlib		+= $$(TARGETDIR)/$$(binutils_ver)-$(subst /,-,$(1)).done
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   251
bfdmakes	+= $$(BUILDDIR)/$$(binutils_ver)-$(subst /,-,$(1))/Makefile
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   252
endef
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   253
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   254
# Create one set of bfds etc for each multilib arch
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   255
$(foreach l,$(LIBDIRS),$(eval $(call mk_bfd,$(l))))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   256
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   257
# Only build these two libs.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   258
$(bfdlib)	: MAKECMD 	= all-libiberty all-bfd
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   259
$(bfdlib)	: INSTALLCMD 	= install-libiberty install-bfd
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   260
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   261
# Building targets libbfd + libiberty. HOST==TARGET, i.e not 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   262
# for a cross env. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   263
$(bfdmakes)	: CONFIG = --target=$(TARGET) 				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   264
			--host=$(TARGET) --build=$(BUILD)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   265
			--prefix=$(TARGETDIR) 				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   266
			--with-sysroot=$(SYSROOT) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   267
			$(LIBDIRS)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   268
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   269
$(bfdmakes)	: TOOLS = $(call declare_tools,_FOR_TARGET,$(TARGET)-) $(call declare_tools,,$(TARGET)-)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   270
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   271
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   272
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   273
$(gcc)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   274
$(binutils)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   275
$(gmp)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   276
$(mpfr)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   277
$(mpc)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   278
$(bfdmakes)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   279
$(ccache)	: ENVS += $(TOOLS)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   280
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   281
# libdir to work around hateful bfd stuff installing into wrong dirs...
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   282
# ensure we have 64 bit bfd support in the HOST library. I.e our 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   283
# compiler on i686 will know 64 bit symbols, BUT later
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   284
# we build just the libs again for TARGET, then with whatever the arch 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   285
# wants.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   286
$(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   287
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   288
# Makefile creation. Simply run configure in build dir.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   289
$(bfdmakes)				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   290
$(BUILDDIR)/$(binutils_ver)/Makefile	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   291
		: $(BINUTILS_CFG)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   292
		$(info Configuring $@. Log in $(@D)/log.config)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   293
		@mkdir -p $(@D)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   294
		(						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   295
			cd $(@D) ;				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   296
			$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)"	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   297
				$(BINUTILS_CFG) 		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   298
				$(CONFIG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   299
				--with-sysroot=$(SYSROOT)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   300
				--disable-nls			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   301
				--program-prefix=$(TARGET)-	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   302
				--enable-multilib		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   303
		) > $(@D)/log.config 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   304
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   305
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   306
$(BUILDDIR)/$(mpfr_ver)/Makefile	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   307
		: $(MPFR_CFG)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   308
		$(info Configuring $@. Log in $(@D)/log.config)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   309
		@mkdir -p $(@D)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   310
		(						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   311
			cd $(@D) ;				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   312
			$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)"	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   313
				$(MPFR_CFG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   314
				$(CONFIG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   315
				--program-prefix=$(TARGET)-	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   316
				--enable-shared=no		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   317
				--with-gmp=$(PREFIX)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   318
		) > $(@D)/log.config 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   319
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   320
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   321
$(BUILDDIR)/$(gmp_ver)/Makefile	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   322
		: $(GMP_CFG)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   323
		$(info Configuring $@. Log in $(@D)/log.config)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   324
		@mkdir -p $(@D)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   325
		(						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   326
			cd $(@D) ;				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   327
			$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)"	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   328
				$(GMP_CFG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   329
				--host=$(HOST) --build=$(BUILD)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   330
				--prefix=$(PREFIX)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   331
				--disable-nls			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   332
				--program-prefix=$(TARGET)-	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   333
				--enable-shared=no		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   334
				--with-mpfr=$(PREFIX)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   335
		) > $(@D)/log.config 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   336
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   337
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   338
$(BUILDDIR)/$(mpc_ver)/Makefile	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   339
		: $(MPC_CFG)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   340
		$(info Configuring $@. Log in $(@D)/log.config)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   341
		@mkdir -p $(@D)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   342
		(						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   343
			cd $(@D) ;				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   344
			$(PATHPRE) $(ENVS) CFLAGS="$(CFLAGS)"	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   345
				$(MPC_CFG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   346
				$(CONFIG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   347
				--program-prefix=$(TARGET)-	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   348
				--enable-shared=no		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   349
				--with-mpfr=$(PREFIX)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   350
				--with-gmp=$(PREFIX)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   351
		) > $(@D)/log.config 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   352
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   353
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   354
# Only valid if glibc target -> linux
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   355
# proper destructor handling for c++
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   356
ifneq (,$(findstring linux,$(TARGET)))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   357
$(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --enable-__cxa_atexit 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   358
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   359
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   360
# Want:
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   361
# 	c,c++
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   362
# 	shared libs
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   363
#	multilib (-m32/-m64 on x64)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   364
# 	skip native language. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   365
#	and link and assemble with the binutils we created 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   366
#	earlier, so --with-gnu*
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   367
$(BUILDDIR)/$(gcc_ver)/Makefile	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   368
		: $(GCC_CFG) 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   369
		$(info Configuring $@. Log in $(@D)/log.config)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   370
		mkdir -p $(@D)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   371
		(						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   372
			cd $(@D) ;				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   373
			$(PATHPRE) $(ENVS) $(GCC_CFG) $(EXTRA_CFLAGS) \
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   374
				$(CONFIG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   375
				--with-sysroot=$(SYSROOT)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   376
				--enable-languages=c,c++ 	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   377
				--enable-shared			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   378
				--enable-multilib		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   379
				--disable-nls			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   380
				--with-gnu-as 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   381
				--with-gnu-ld			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   382
				--with-mpfr=$(PREFIX)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   383
				--with-gmp=$(PREFIX)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   384
				--with-mpc=$(PREFIX)		\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   385
		) > $(@D)/log.config 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   386
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   387
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   388
# need binutils for gcc
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   389
$(gcc)		: $(binutils) 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   390
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   391
# as of 4.3 or so need these for doing config
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   392
$(BUILDDIR)/$(gcc_ver)/Makefile : $(gmp) $(mpfr) $(mpc)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   393
$(mpfr)		: $(gmp)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   394
$(mpc)		: $(gmp) $(mpfr)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   395
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   396
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   397
# very straightforward. just build a ccache. it is only for host. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   398
$(BUILDDIR)/$(ccache_ver)/Makefile	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   399
		: $(CCACHE_CFG)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   400
		$(info Configuring $@. Log in $(@D)/log.config)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   401
		@mkdir -p $(@D)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   402
		@(						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   403
			cd $(@D) ;				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   404
			$(PATHPRE) $(ENVS) $(CCACHE_CFG)	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   405
				$(CONFIG) 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   406
		) > $(@D)/log.config 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   407
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   408
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   409
gccpatch	= $(TARGETDIR)/gcc-patched
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   410
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   411
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   412
# For some reason cpp is not created as a target-compiler 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   413
ifeq ($(HOST),$(TARGET))
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   414
$(gccpatch)	: $(gcc) link_libs
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   415
		@echo -n 'Creating compiler symlinks...'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   416
		@for f in cpp; do 				\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   417
			if [ ! -e $(PREFIX)/bin/$(TARGET)-$$f ];\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   418
			then					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   419
			cd $(PREFIX)/bin && 			\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   420
				ln -s $$f $(TARGET)-$$f ;	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   421
			fi					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   422
		done
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   423
		@touch $@
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   424
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   425
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   426
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   427
# Ugly at best. Seems that when we compile host->host compiler, that are NOT
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   428
# the BUILD compiler, the result will not try searching for libs in package root.
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   429
# "Solve" this by create links from the target libdirs to where they are. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   430
link_libs:
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   431
		@echo -n 'Creating library symlinks...'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   432
		@$(foreach l,$(LIBDIRS),							\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   433
		for f in `cd $(PREFIX)/$(l) && ls`; do 						\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   434
			if [ ! -e $(TARGETDIR)/$(l)/$$f ]; then					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   435
				mkdir -p $(TARGETDIR)/$(l) &&					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   436
				cd $(TARGETDIR)/$(l)/ && 					\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   437
				ln -s $(if $(findstring /,$(l)),../,)../../$(l)/$$f $$f;	\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   438
			fi									\
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   439
		done;) 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   440
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   441
else
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   442
$(gccpatch)	:
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   443
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   444
endif
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   445
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   446
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   447
# Build in two steps. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   448
# make <default>
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   449
# make install. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   450
# Use path to our build hosts cross tools
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   451
# Always need to build cross tools for build host self. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   452
$(TARGETDIR)/%.done : $(BUILDDIR)/%/Makefile 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   453
		$(info Building $(basename $@). Log in $(<D)/log.build)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   454
		$(PATHPRE) $(ENVS) $(MAKE) $(BUILDPAR) -f $< -C $(<D) $(MAKECMD) $(MAKECMD.$(notdir $@)) > $(<D)/log.build 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   455
		@echo -n 'installing...'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   456
		$(PATHPRE) $(MAKE) $(INSTALLPAR) -f $< -C $(<D) $(INSTALLCMD) $(MAKECMD.$(notdir $@))  > $(<D)/log.install 2>&1
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   457
		@touch $@
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   458
		@echo 'done'
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   459
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   460
##########################################################################################
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   461
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   462
bfdlib		: $(bfdlib)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   463
binutils	: $(binutils)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   464
rpms		: $(rpms)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   465
libs		: $(libs)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   466
sysroot		: rpms libs
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   467
gcc		: sysroot $(gcc) $(gccpatch)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   468
all		: binutils gcc bfdlib
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   469
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   470
# this is only built for host. so separate. 
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   471
ccache		: $(ccache)
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   472
680b9b43e2d6 8015377: Support using compiler devkits on Linux
erikj
parents:
diff changeset
   473
.PHONY		: gcc all binutils bfdlib link_libs rpms libs sysroot