source: mainline/uspace/app/binutils/Makefile@ 10fdd0e

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

libsoftfloat included into linker library list. Removed minor bug in Makefile.

  • Property mode set to 100644
File size: 6.8 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),\ ,$(shell pwd))/../..
49
50# Ensure static configuration of Makefile.common.
51STATIC_ONLY = y
52
53# Link with POSIX runtime library.
54POSIX_COMPAT = y
55
56# Makefile.common for native applications.
57COMMON_MAKEFILE_NATIVE = $(USPACE_PREFIX)/Makefile.common
58
59# Generated from native Makefile.common.
60COMMON_MAKEFILE_PATCHED = ./Makefile.common
61
62# AWK script which generates patched Makefile.common.
63MAKEFILE_PATCH = ./patch.awk
64
65# Compilers that can be used to build binutils.
66SUPPORTED_COMPILERS = gcc_cross gcc_native
67
68# Patched Makefile.common for ported user space applications.
69-include $(COMMON_MAKEFILE_PATCHED)
70
71# Patch $PATH to intercept toolchain calls.
72PATH := $(shell pwd):$(PATH)
73export PATH
74
75# Shell script for false toolchain generation.
76TOOLCHAIN_SCRIPT = ./toolchain.sh
77
78# False toolchain.
79TOOLCHAIN = ./gcc ./as ./ar ./ranlib ./ld ./objdump ./objcopy ./strip
80
81# Stamp indicating whether the binutils source tree is patched.
82BINUTILS_PATCHED = ./done
83
84# Shell script for instrusive patches of binutils source tree.
85BINUTILS_PATCH = ./intrusive.sh
86
87# Detection whether the binutils are already configured.
88BINUTILS_CONFIGURED = $(REDIST_DIR)/Makefile
89
90# Generated source file for libposix function stubs without posix_ prefix.
91CONFOBJ_SOURCE = ./confobj.c
92
93# Dummy object file for libposix function stubs without posix_ prefix..
94# Required by binutils configure script tests that links against symbols
95# without including headers (which means that symbols are not prefixed).
96CONFOBJ_OBJECT = $(subst $(space),\ ,$(shell pwd))/confobj.o
97
98# Required by libposix on RISC platforms.
99BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
100
101# Map the HelenOS target to binutils target.
102ifeq ($(PLATFORM),amd64)
103TARGET = amd64-linux-gnu
104endif
105ifeq ($(PLATFORM),arm32)
106TARGET = arm-linux-gnu
107endif
108ifeq ($(PLATFORM),ia32)
109TARGET = i686-pc-linux-gnu
110endif
111ifeq ($(PLATFORM),ia64)
112TARGET = ia64-pc-linux-gnu
113endif
114ifeq ($(PLATFORM),mips32)
115TARGET = mipsel-linux-gnu
116endif
117ifeq ($(PLATFORM),mips32eb)
118TARGET = mips-linux-gnu
119endif
120ifeq ($(PLATFORM),mips64)
121TARGET = mips64el-linux-gnu
122endif
123ifeq ($(PLATFORM),ppc32)
124TARGET = ppc-linux-gnu
125endif
126ifeq ($(PLATFORM),ppc64)
127TARGET = ppc64-linux-gnu
128endif
129ifeq ($(PLATFORM),sparc64)
130TARGET = sparc64-linux-gnu
131endif
132
133# Binutils configure flags.
134CONF_FLAGS = --disable-nls --disable-shared --enable-static \
135 --with-zlib=no --with-ppl=no --with-cloog=no \
136 --with-gmp=no --with-mpfr=no --with-mpc=no
137
138# Binutils make targets.
139MAKE_TARGETS = all-gas all-ld
140
141# Check presence of gcc compiler.
142# Make binutils.
143# Copy binaries.
144ifeq ($(COMPILER),$(findstring $(COMPILER),$(SUPPORTED_COMPILERS)))
145all: $(COMMON_MAKEFILE_PATCHED) all_ $(TOOLCHAIN) $(BINUTILS_PATCHED) \
146 $(CONFOBJ_OBJECT) $(BINUTILS_CONFIGURED) $(REDIST_DETECT)
147 make -C $(REDIST_DIR) $(MAKE_TARGETS)
148 cp -f $(REDIST_DIR)/gas/as-new ./as
149 cp -f $(REDIST_DIR)/ld/ld-new ./ld
150else
151all:
152 # Skipped: Cannot build binutils with unsupported compiler.
153endif
154
155# Create patched Makefile.common from native Makefile.common.
156$(COMMON_MAKEFILE_PATCHED): $(MAKEFILE_PATCH) $(COMMON_MAKEFILE_NATIVE)
157 awk -f $^ > $@
158
159# Download binutils redistributable package.
160$(REDIST_FILENAME):
161 wget -c $(REDIST_SOURCE)$(REDIST_FILENAME)
162
163# Extract binutils source tree.
164$(REDIST_DETECT): $(REDIST_FILENAME)
165 tar -x -j -f $<
166 mv -f -T $(REDIST_NAME) $(REDIST_DIR)
167 touch $@
168
169# Generate stubs for libposix functions without posix_ prefix.
170$(CONFOBJ_SOURCE):
171 echo '/* GENERATED FILE. DO NOT MODIFY. */' > $@; \
172 $(OBJDUMP) -t $(LIBPOSIX_PREFIX)/libposix.a | \
173 grep F | grep -o -h -I -E 'posix_.*$$' | sort -u | \
174 sed 's/posix_\([^ ]*\)/char \1() { return 0; }/g' >> $@
175
176# Compile dummy object for configure script tests.
177$(CONFOBJ_OBJECT): $(CONFOBJ_SOURCE) $(TOOLCHAIN)
178 ./gcc -c -o $@ $<
179
180# Generate false toolchain scripts.
181$(TOOLCHAIN): $(TOOLCHAIN_SCRIPT)
182 ./$< gcc $(CC) \
183 '$(CFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS) $(CONFOBJ_OBJECT)'
184 ./$< as $(AS)
185 ./$< ar $(AR)
186 ./$< ranlib
187 ./$< ld $(LD) \
188 '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
189 ./$< objdump $(OBJDUMP)
190 ./$< objcopy $(OBJCOPY)
191 ./$< strip $(STRIP)
192
193# Patch binutils source tree.
194$(BINUTILS_PATCHED): $(BINUTILS_PATCH) $(REDIST_DETECT)
195 ./$< do $(REDIST_DIR)
196 touch $@
197
198# Configure binutils.
199# $LD variable have to exported to override configure script caching.
200$(BINUTILS_CONFIGURED): $(REDIST_DIR)/configure $(REDIST_DETECT)
201 export LD=ld; \
202 cd $(REDIST_DIR); \
203 ./configure --target=$(TARGET) $(CONF_FLAGS)
204
205# Delete binaries.
206# Clean binutils.
207# Unpatch binutils.
208# Delete generated scripts.
209clean: $(BINUTILS_PATCH) clean_
210 rm -f as ld
211 rm -f $(CONFOBJ_SOURCE) $(CONFOBJ_OBJECT)
212 if [ -e $(REDIST_DIR)/Makefile ]; then \
213 make -C $(REDIST_DIR) distclean; \
214 fi
215 if [ -e $(BINUTILS_PATCHED) ]; then \
216 ./intrusive.sh undo $(REDIST_DIR); \
217 rm -f $(BINUTILS_PATCHED); \
218 fi
219 rm -f $(TOOLCHAIN)
220 rm -f $(COMMON_MAKEFILE_PATCHED)
221
Note: See TracBrowser for help on using the repository browser.