source: mainline/uspace/app/binutils/Makefile@ bf49001

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since bf49001 was a0bb65af, checked in by Petr Koupy <petr.koupy@…>, 14 years ago

Added automatic download and extraction of binutils redistributable package.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1#
2# Copyright (c) 2011 Petr Koupy
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29nullstring =
30space = $(nullstring) # space
31
32# Information for obtaining specific binutils redistributable package.
33# Might be subject to change in the future.
34REDIST_VERSION = 2.21
35REDIST_NAME = binutils-$(REDIST_VERSION)
36REDIST_FILENAME = $(REDIST_NAME).tar.bz2
37REDIST_SOURCE = ftp://ftp.gnu.org/gnu/binutils/
38
39# Directory for the binutils source tree.
40REDIST_DIR = ./redist
41
42# File to detect the presence of binutils source tree.
43REDIST_DETECT = $(REDIST_DIR)/configure
44
45# $USPACE_PREFIX have to be based on the absolute path,
46# because targets derived from it will be referenced from
47# other than the current directory.
48USPACE_PREFIX = $(subst $(space),\ ,$(PWD))/../..
49
50# Ensure static configuration of Makefile.common.
51STATIC_ONLY = y
52
53# Makefile.common for native applications.
54COMMON_MAKEFILE_NATIVE = $(USPACE_PREFIX)/Makefile.common
55
56# Generated from native Makefile.common.
57COMMON_MAKEFILE_PATCHED = ./Makefile.common
58
59# AWK script which generates patched Makefile.common.
60PATCH_SCRIPT = ./patch.awk
61
62# Compilers that can be used to build binutils.
63SUPPORTED_COMPILERS = gcc_cross gcc_native
64
65# Patched Makefile.common for ported user space applications.
66include $(COMMON_MAKEFILE_PATCHED)
67
68# Map the HelenOS target to binutils target.
69ifeq ($(PLATFORM),amd64)
70TARGET=amd64-linux-gnu
71else ($(PLATFORM),arm32)
72TARGET=arm-linux-gnu
73else ($(PLATFORM),ia32)
74TARGET=i686-pc-linux-gnu
75else ($(PLATFORM),ia64)
76TARGET=ia64-pc-linux-gnu
77else ($(PLATFORM),mips32)
78TARGET=mipsel-linux-gnu
79else ($(PLATFORM),mips32eb)
80TARGET=mips-linux-gnu
81else ($(PLATFORM),mips64)
82TARGET=mips64el-linux-gnu
83else ($(PLATFORM),ppc32)
84TARGET=ppc-linux-gnu
85else ($(PLATFORM),ppc64)
86TARGET=ppc64-linux-gnu
87else ($(PLATFORM),sparc64)
88TARGET=sparc64-linux-gnu
89endif
90
91# Binutils configure flags.
92CONF_FLAGS = --disable-nls --disable-shared --enable-static \
93 --with-zlib=no
94
95# Binutils make targets.
96MAKE_TARGETS = all-gas all-ld
97
98# Patch native Makefile.common.
99# Download and extract binutils.
100# Check presence of gcc compiler.
101# Patch $PATH to intercept toolchain calls.
102# Generate false toolchain.
103# Patch binutils.
104# Configure binutils for target architecture.
105# Make binutils.
106# Copy binaries.
107all: $(COMMON_MAKEFILE_PATCHED) all_ $(REDIST_FILENAME) $(REDIST_DETECT)
108ifeq ($(COMPILER),$(findstring $(COMPILER),$(SUPPORTED_COMPILERS)))
109 OLDPATH = $(PATH)
110 PATH = $(PWD):$(PATH)
111 export PATH
112 ./toolchain.sh gcc $(CC) '$(CFLAGS)'
113 ./toolchain.sh as $(AS)
114 ./toolchain.sh ar $(AR)
115 ./toolchain.sh ranlib
116 ./toolchain.sh ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
117 ./toolchain.sh objdump $(OBJDUMP)
118 ./toolchain.sh objcopy $(OBJCOPY)
119 ./toolchain.sh strip $(STRIP)
120 ./intrusive.sh do $(REDIST_DIR)
121 ORIG_DIR = $(subst $(space),\ ,$(PWD))
122 cd $(REDIST_DIR)
123 ./configure --target=$(TARGET) $(CONF_FLAGS)
124 make $(MAKE_TARGETS)
125 cd $(ORIG_DIR)
126 cp $(REDIST_DIR)/gas/as-new ./as
127 cp $(REDIST_DIR)/ld/ld-new ./ld
128 PATH = $(OLDPATH)
129 export PATH
130else
131 echo 'Skipped: Cannot build binutils with unsupported compiler.'
132endif
133
134# Create patched Makefile.common from native Makefile.common.
135$(COMMON_MAKEFILE_PATCHED): $(PATCH_SCRIPT) $(COMMON_MAKEFILE_NATIVE)
136 awk -f $^ > $@
137
138# Download binutils redistributable package.
139$(REDIST_FILENAME):
140 wget -c $(REDIST_SOURCE)$(REDIST_FILENAME)
141
142# Extract binutils source tree.
143$(REDIST_DETECT): $(REDIST_FILENAME)
144 tar -x -j -f $<
145 mv -f $(REDIST_NAME) $(REDIST_DIR)
146
147# Delete binaries.
148# Clean binutils.
149# Unpatch binutils.
150# Delete generated scripts.
151clean:
152 rm -f as ld
153 ORIG_DIR = $(subst $(space),\ ,$(PWD))
154 cd $(REDIST_DIR)
155 make distclean
156 cd $(ORIG_DIR)
157 ./intrusive.sh undo $(REDIST_DIR)
158 rm -f gcc as ar ranlib ld objdump objcopy strip
159 rm -f $(COMMON_MAKEFILE_PATCHED)
160
Note: See TracBrowser for help on using the repository browser.