source: mainline/uspace/app/binutils/Makefile@ 53d9ee9

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

Added scripts that interconnect HelenOS build process with binutils build process.

  • Property mode set to 100644
File size: 4.7 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# Symlink to the sources of the ported application.
33APP_DIR = ./src
34
35# Default directory for the binutils source tree.
36REDIST_DIR = ./redist
37
38# Absolute path to the binutils source tree.
39# Can be set externally, defaults to $REDIST_DIR.
40BINUTILS_ABS_PATH ?= $(subst $(space),\ ,$(PWD))/$(REDIST_DIR)
41
42# $USPACE_PREFIX have to be based on the absolute path,
43# because targets derived from it will be referenced from
44# other than the current directory.
45USPACE_PREFIX = $(subst $(space),\ ,$(PWD))/../..
46
47# Ensure static configuration of Makefile.common.
48STATIC_ONLY = y
49
50# Makefile.common for native applications.
51COMMON_MAKEFILE_NATIVE = $(USPACE_PREFIX)/Makefile.common
52
53# Generated from native Makefile.common.
54COMMON_MAKEFILE_PATCHED = ./Makefile.common
55
56# AWK script which generates patched Makefile.common.
57PATCH_SCRIPT = ./patch.awk
58
59# Compilers that can be used to build binutils.
60SUPPORTED_COMPILERS = gcc_cross gcc_native
61
62# Patched Makefile.common for ported user space applications.
63include $(COMMON_MAKEFILE_PATCHED)
64
65# Map the HelenOS target to binutils target.
66ifeq ($(PLATFORM),amd64)
67TARGET=amd64-linux-gnu
68else ($(PLATFORM),arm32)
69TARGET=arm-linux-gnu
70else ($(PLATFORM),ia32)
71TARGET=i686-pc-linux-gnu
72else ($(PLATFORM),ia64)
73TARGET=ia64-pc-linux-gnu
74else ($(PLATFORM),mips32)
75TARGET=mipsel-linux-gnu
76else ($(PLATFORM),mips32eb)
77TARGET=mips-linux-gnu
78else ($(PLATFORM),mips64)
79TARGET=mips64el-linux-gnu
80else ($(PLATFORM),ppc32)
81TARGET=ppc-linux-gnu
82else ($(PLATFORM),ppc64)
83TARGET=ppc64-linux-gnu
84else ($(PLATFORM),sparc64)
85TARGET=sparc64-linux-gnu
86endif
87
88# Binutils configure flags.
89CONF_FLAGS = --disable-nls --disable-shared --enable-static \
90 --with-zlib=no
91
92# Binutils make targets.
93MAKE_TARGETS = all-gas all-ld
94
95# Patch native Makefile.common.
96# Check presence of gcc compiler.
97# Patch $PATH to intercept toolchain calls.
98# Generate false toolchain.
99# Create symlink to the binutils directory.
100# Patch binutils.
101# Configure binutils for target architecture.
102# Make binutils.
103# Copy binaries.
104all: $(COMMON_MAKEFILE_PATCHED) all_
105ifeq ($(COMPILER),$(findstring $(COMPILER),$(SUPPORTED_COMPILERS)))
106 OLDPATH = $(PATH)
107 PATH = $(PWD):$(PATH)
108 export PATH
109 ./toolchain.sh gcc $(CC) '$(CFLAGS)'
110 ./toolchain.sh as $(AS)
111 ./toolchain.sh ar $(AR)
112 ./toolchain.sh ranlib
113 ./toolchain.sh ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
114 ./toolchain.sh objdump $(OBJDUMP)
115 ./toolchain.sh objcopy $(OBJCOPY)
116 ./toolchain.sh strip $(STRIP)
117 ln -s -T $(BINUTILS_ABS_PATH) $(APP_DIR)
118 ./intrusive.sh do $(APP_DIR)
119 ORIG_DIR = $(subst $(space),\ ,$(PWD))
120 cd $(APP_DIR)
121 ./configure --target=$(TARGET) $(CONF_FLAGS)
122 make $(MAKE_TARGETS)
123 cd $(ORIG_DIR)
124 cp $(APP_DIR)/gas/as-new ./as
125 cp $(APP_DIR)/ld/ld-new ./ld
126 PATH = $(OLDPATH)
127 export PATH
128else
129 echo 'Skipped: Cannot build binutils with unsupported compiler.'
130endif
131
132# Create patched Makefile.common from native Makefile.common.
133$(COMMON_MAKEFILE_PATCHED): $(PATCH_SCRIPT) $(COMMON_MAKEFILE_NATIVE)
134 awk -f $^ > $@
135
136# Delete binaries.
137# Clean binutils.
138# Unpatch binutils.
139# Delete symlink
140# Delete generated scripts.
141clean:
142 rm -f as ld
143 ORIG_DIR = $(subst $(space),\ ,$(PWD))
144 cd $(APP_DIR)
145 make distclean
146 cd $(ORIG_DIR)
147 ./intrusive.sh undo $(APP_DIR)
148 rm -f $(APP_DIR)
149 rm -f gcc as ar ranlib ld objdump objcopy strip
150 rm -f $(COMMON_MAKEFILE_PATCHED)
151
Note: See TracBrowser for help on using the repository browser.