summaryrefslogtreecommitdiff
path: root/gcc/Makefrag.am
blob: 35ddf1ba170b12de1d90e45d1157df329f78db5c (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 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/>.

# The GCC version that we use.
gcc_version = 4.2.2
gcc_tarballs = gcc-core-$(gcc_version).tar.bz2 gcc-g++-$(gcc_version).tar.bz2
gcc_snapshot = $(addprefix ftp://ftp.gnu.org/gnu/gcc/gcc-$(gcc_version)/,$(1))

# Patches to apply to GCC's source tree.
gcc_patch_files = \
	configury.patch \
	configury2.patch

$(addprefix $(srcdir)/gcc/,$(gcc_tarballs)): $(srcdir)/gcc/%:
	cd $(srcdir)/gcc/ && \
	wget $(call gcc_snapshot, $*)

$(srcdir)/gcc/gcc/unpack.stamp: $(addprefix $(srcdir)/gcc/,$(gcc_tarballs))
	if test -d $(srcdir)/gcc/gcc/.; then \
		echo "Refusing to extract over $(srcdir)/gcc/gcc"; \
		exit 1; \
	fi
	for f in $^; do \
	  ( cd $(srcdir)/gcc/ && \
	    tar xvj ) \
	      < "$$f" \
	      || exit "$$?"; \
	done
	mv $(srcdir)/gcc/gcc-$(gcc_version) $(srcdir)/gcc/gcc
	touch $@

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

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

gcc/gcc.build/configure.stamp: $(srcdir)/gcc/gcc/patch.stamp binutils/binutils.build/install.stamp
	rm -rf gcc/gcc.build
	mkdir -p gcc/gcc.build
	( cd gcc/gcc.build && \
	  case "$(host_alias)" in \
	    i[34567]86-*-*) \
	      extra_args=--with-arch=$(word 1,$(subst -, ,$(host_alias))) \
	      ;; \
	  esac && \
	  $(abs_srcdir)/gcc/gcc/configure \
	    --target=$(host_alias) \
	    --prefix='$(abs_top_builddir)' \
	    --with-sysroot='$(SYSROOT)' \
	    --disable-nls \
	    --disable-shared \
	    --disable-threads \
	    --without-headers \
	    --with-newlib \
	    --enable-languages=c \
            $${extra_args} \
	)
	touch $@

gcc/gcc.build/build.stamp: gcc/gcc.build/configure.stamp
	cd gcc/gcc.build/ && \
	$(MAKE) all-gcc
	touch $@

gcc/gcc.build/install.stamp: gcc/gcc.build/build.stamp
	cd gcc/gcc.build/ && \
	$(MAKE) install-gcc
	touch $@


# libstdc++

libstdc++: gcc/gcc.build/$(host_alias)/libstdc++-v3/install.stamp

# While it would be desirable to have the following two target re-ran each
# turn, stamp files (to inhibit this) are being created nevertheless, as the
# GCC build system doesn't do dependency tracking to external (header) files,
# so nothing would be rebuilt anyway.
gcc/gcc.build/$(host_alias)/libstdc++-v3/build.stamp: gcc/gcc.build/build.stamp gcc/gcc.build/frob-Makefile-FLAGS_FOR_TARGET
	cd gcc/gcc.build/ && \
	$(MAKE) all-target-libstdc++-v3
	touch $@

gcc/gcc.build/$(host_alias)/libstdc++-v3/install.stamp: gcc/gcc.build/$(host_alias)/libstdc++-v3/build.stamp
	cd gcc/gcc.build/ && \
	$(MAKE) install-target-libstdc++-v3
	touch $@

# Doing this is needed to teach GCC about where to find the libc headers, etc.
# TODO.  It also does provoke a bunch of warnings in the libstdc++ compilation.
# Someone might want to sort that out...
gcc/gcc.build/frob-Makefile-FLAGS_FOR_TARGET: gcc/gcc.build/Makefile
	sed '/^FLAGS_FOR_TARGET/s%$$% $(USER_CPPFLAGS) $(USER_CFLAGS)%' \
	  < $^ > $^.new && \
	mv $^.new $^
	touch $@


#TODO: clean etc.