summaryrefslogtreecommitdiff
path: root/binutils/Makefrag.am
blob: 3fd3a0dfcbb3314810fdd4325e528de4d096893e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Copyright (C) 2003, 2005, 2008 Free Software Foundation, Inc.
# 
# This file is part of the GNU Hurd.
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Patches to apply to the source tree.
patch_files = 00-bfd-config-bfd.patch \
	01-ld-configure-tgt.patch

EXTRA_DIST = $(addprefix binutils/patches/, $(patch_files))

# The GNU binutils version that we use.
binutils_version = 2.19
binutils_tarball = binutils-$(binutils_version).tar.bz2
binutils_snapshot = ftp://ftp.gnu.org/gnu/binutils/$(binutils_tarball)

$(srcdir)/binutils/$(binutils_tarball):
	wget $(binutils_snapshot) -O $(srcdir)/binutils/$(binutils_tarball)

$(srcdir)/binutils/binutils/unpack.stamp: $(srcdir)/binutils/$(binutils_tarball)
	if test -d $(srcdir)/binutils/binutils/.; then \
		echo "Refusing to extract over $(srcdir)/binutils/binutils"; \
		exit 1; \
	fi
	( cd $(srcdir)/binutils/ \
		&& tar xfvj $(binutils_tarball) \
		&& mv binutils-$(binutils_version) binutils )
	touch $@

# Apply any local patches.  (Revert any applied older version.)
$(addprefix $(srcdir)/binutils/binutils/,$(addsuffix .applied,$(patch_files))): $(srcdir)/binutils/binutils/unpack.stamp
$(addprefix $(srcdir)/binutils/binutils/,$(addsuffix .applied,$(patch_files))): $(srcdir)/binutils/binutils/%.applied: $(srcdir)/binutils/patches/%
	if test -e "$@"; \
	then \
	  ( cd $(srcdir)/binutils/binutils && sh /dev/stdin -R ) < $@ && rm -f $@; \
	fi
	( cd $(srcdir)/binutils/binutils && sh /dev/stdin ) < $<
	cp $< $@

rpatch:
	for p in $(shell tac -s ' ' $(patch_files)) ; do \
		(cd $(srcdir)/binutils/binutils; sh ../$(srcdir)/$${p} -R) || exit 1 ; \
	done

$(srcdir)/binutils/binutils/patch.stamp: $(srcdir)/binutils/binutils/unpack.stamp \
  $(addprefix $(srcdir)/binutils/binutils/,$(addsuffix .applied,$(patch_files)))
	cd $(srcdir)/binutils/binutils/ && \
	$(fix_config_guess_and_sub)
	touch $@

binutils/binutils.build/configure.stamp: $(srcdir)/binutils/binutils/patch.stamp
	rm -rf binutils/binutils.build
	mkdir -p binutils/binutils.build
	( cd binutils/binutils.build && \
	  $(abs_srcdir)/binutils/binutils/configure \
	    --target=$(host_alias) \
	    --prefix='$(abs_top_builddir)' \
	    --with-sysroot='$(SYSROOT)' \
	    --disable-nls \
	)
	touch $@

# About MAKEINFO: See <http://sourceware.org/bugzilla/show_bug.cgi?id=5021>.
# Will be fixed with next binutils release.
binutils/binutils.build/build.stamp: binutils/binutils.build/configure.stamp
	cd binutils/binutils.build/ && \
	$(MAKE) \
	  MAKEINFO=makeinfo \
	  all
	touch $@

binutils/binutils.build/install.stamp: binutils/binutils.build/build.stamp
	cd binutils/binutils.build/ && \
	$(MAKE) \
	  MAKEINFO=makeinfo \
	  install
	touch $@

#TODO: clean etc.