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

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

Added flag that connects libposix with binutils.

  • Property mode set to 100644
File size: 5.1 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# 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.
63PATCH_SCRIPT = ./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.
69include $(COMMON_MAKEFILE_PATCHED)
70
71# Map the HelenOS target to binutils target.
72ifeq ($(PLATFORM),amd64)
73TARGET=amd64-linux-gnu
74else ($(PLATFORM),arm32)
75TARGET=arm-linux-gnu
76else ($(PLATFORM),ia32)
77TARGET=i686-pc-linux-gnu
78else ($(PLATFORM),ia64)
79TARGET=ia64-pc-linux-gnu
80else ($(PLATFORM),mips32)
81TARGET=mipsel-linux-gnu
82else ($(PLATFORM),mips32eb)
83TARGET=mips-linux-gnu
84else ($(PLATFORM),mips64)
85TARGET=mips64el-linux-gnu
86else ($(PLATFORM),ppc32)
87TARGET=ppc-linux-gnu
88else ($(PLATFORM),ppc64)
89TARGET=ppc64-linux-gnu
90else ($(PLATFORM),sparc64)
91TARGET=sparc64-linux-gnu
92endif
93
94# Binutils configure flags.
95CONF_FLAGS = --disable-nls --disable-shared --enable-static \
96 --with-zlib=no
97
98# Binutils make targets.
99MAKE_TARGETS = all-gas all-ld
100
101# Patch native Makefile.common.
102# Download and extract binutils.
103# Check presence of gcc compiler.
104# Patch $PATH to intercept toolchain calls.
105# Generate false toolchain.
106# Patch binutils.
107# Configure binutils for target architecture.
108# Make binutils.
109# Copy binaries.
110all: $(COMMON_MAKEFILE_PATCHED) all_ $(REDIST_FILENAME) $(REDIST_DETECT)
111ifeq ($(COMPILER),$(findstring $(COMPILER),$(SUPPORTED_COMPILERS)))
112 OLDPATH = $(PATH)
113 PATH = $(PWD):$(PATH)
114 export PATH
115 ./toolchain.sh gcc $(CC) '$(CFLAGS)'
116 ./toolchain.sh as $(AS)
117 ./toolchain.sh ar $(AR)
118 ./toolchain.sh ranlib
119 ./toolchain.sh ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
120 ./toolchain.sh objdump $(OBJDUMP)
121 ./toolchain.sh objcopy $(OBJCOPY)
122 ./toolchain.sh strip $(STRIP)
123 ./intrusive.sh do $(REDIST_DIR)
124 ORIG_DIR = $(subst $(space),\ ,$(PWD))
125 cd $(REDIST_DIR)
126 ./configure --target=$(TARGET) $(CONF_FLAGS)
127 make $(MAKE_TARGETS)
128 cd $(ORIG_DIR)
129 cp $(REDIST_DIR)/gas/as-new ./as
130 cp $(REDIST_DIR)/ld/ld-new ./ld
131 PATH = $(OLDPATH)
132 export PATH
133else
134 echo 'Skipped: Cannot build binutils with unsupported compiler.'
135endif
136
137# Create patched Makefile.common from native Makefile.common.
138$(COMMON_MAKEFILE_PATCHED): $(PATCH_SCRIPT) $(COMMON_MAKEFILE_NATIVE)
139 awk -f $^ > $@
140
141# Download binutils redistributable package.
142$(REDIST_FILENAME):
143 wget -c $(REDIST_SOURCE)$(REDIST_FILENAME)
144
145# Extract binutils source tree.
146$(REDIST_DETECT): $(REDIST_FILENAME)
147 tar -x -j -f $<
148 mv -f $(REDIST_NAME) $(REDIST_DIR)
149
150# Delete binaries.
151# Clean binutils.
152# Unpatch binutils.
153# Delete generated scripts.
154clean:
155 rm -f as ld
156 ORIG_DIR = $(subst $(space),\ ,$(PWD))
157 cd $(REDIST_DIR)
158 make distclean
159 cd $(ORIG_DIR)
160 ./intrusive.sh undo $(REDIST_DIR)
161 rm -f gcc as ar ranlib ld objdump objcopy strip
162 rm -f $(COMMON_MAKEFILE_PATCHED)
163
Note: See TracBrowser for help on using the repository browser.