1#   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
2#   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
3#
4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8# 
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13# 
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17#
18
19# This Makefile contains release scripts for gdb, binutils, and other
20# packages which live in src.  It used to be part of the top level Makefile,
21# but that turned out to be very messy and hard to maintain.
22
23# This stuff really ought to be cleaned up and turned into something other
24# than a Makefile.  As it is it's heavily recursive.
25
26# This is the name of this script (!).  Needed due to horrible recursion.
27SELF = src-release
28
29SHELL = /bin/sh
30
31BZIPPROG = bzip2
32MD5PROG = md5sum
33
34# (Default to avoid splitting info files by setting the threshold high.)
35MAKEINFOFLAGS = --split-size=5000000
36
37# pwd command to use.  Allow user to override default by setting PWDCMD in
38# the environment to account for automounters.  The make variable must not
39# be called PWDCMD, otherwise the value set here is passed to make
40# subprocesses and overrides the setting from the user's environment.
41PWD = $${PWDCMD-pwd}
42
43#
44# Support for building net releases
45
46# Files in devo used in any net release.
47# ChangeLog omitted because it may refer to files which are not in this
48# distribution (perhaps it would be better to include it anyway).
49DEVO_SUPPORT= README Makefile.in configure configure.ac \
50	config.guess config.sub config move-if-change \
51	COPYING COPYING.LIB install-sh config-ml.in symlink-tree \
52	mkinstalldirs ltmain.sh missing ylwrap \
53	libtool.m4 ltsugar.m4 ltversion.m4 ltoptions.m4 \
54	Makefile.def Makefile.tpl src-release config.rpath \
55	COPYING3 COPYING3.LIB
56
57# Files in devo/etc used in any net release.
58# ChangeLog omitted because it may refer to files which are not in this
59# distribution (perhaps it would be better to include it anyway).
60ETC_SUPPORT= Makefile.in configure configure.in standards.texi \
61	make-stds.texi standards.info* configure.texi configure.info* \
62	configbuild.* configdev.* fdl.texi texi2pod.pl
63
64
65# When you use `make setup-dirs' or `make taz' you should always redefine
66# this macro.
67SUPPORT_FILES = list-of-support-files-for-tool-in-question
68
69# NOTE: No double quotes in the below.  It is used within shell script
70# as VER="$(VER)"
71VER = `	if grep 'AM_INIT_AUTOMAKE.*BFD_VERSION' $(TOOL)/configure.in >/dev/null 2>&1; then \
72	  sed < bfd/configure.in -n 's/AM_INIT_AUTOMAKE[^,]*, *\([^)]*\))/\1/p'; \
73	elif grep AM_INIT_AUTOMAKE $(TOOL)/configure.in >/dev/null 2>&1; then \
74	  sed < $(TOOL)/configure.in -n 's/AM_INIT_AUTOMAKE[^,]*, *\([^)]*\))/\1/p'; \
75	elif test -f $(TOOL)/version.in; then \
76	  head -1 $(TOOL)/version.in; \
77	elif grep VERSION $(TOOL)/Makefile.in > /dev/null 2>&1; then \
78	  sed < $(TOOL)/Makefile.in -n 's/^VERSION *= *//p'; \
79	else \
80	  echo VERSION; \
81	fi`
82PACKAGE = $(TOOL)
83
84.PHONY: taz
85taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
86	$(MAKE) -f $(SELF) do-proto-toplev \
87		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
88		MD5PROG="$(MD5PROG)" \
89		SUPPORT_FILES="$(SUPPORT_FILES)"
90	$(MAKE) -f $(SELF) do-md5sum \
91		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
92		MD5PROG="$(MD5PROG)" \
93		SUPPORT_FILES="$(SUPPORT_FILES)"
94	$(MAKE) -f $(SELF) do-tar \
95		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
96		MD5PROG="$(MD5PROG)" \
97		SUPPORT_FILES="$(SUPPORT_FILES)"
98	$(MAKE) -f $(SELF) do-bz2 \
99		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
100		MD5PROG="$(MD5PROG)" \
101		SUPPORT_FILES="$(SUPPORT_FILES)"
102
103.PHONY: gdb-tar
104gdb-tar: $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
105	$(MAKE) -f $(SELF) do-proto-toplev \
106		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
107		MD5PROG="$(MD5PROG)" \
108		SUPPORT_FILES="$(SUPPORT_FILES)"
109	$(MAKE) -f $(SELF) do-md5sum \
110		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
111		MD5PROG="$(MD5PROG)" \
112		SUPPORT_FILES="$(SUPPORT_FILES)"
113	$(MAKE) -f $(SELF) do-djunpack \
114		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
115		MD5PROG="$(MD5PROG)" \
116		SUPPORT_FILES="$(SUPPORT_FILES)"
117	$(MAKE) -f $(SELF) do-tar \
118		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
119		MD5PROG="$(MD5PROG)" \
120		SUPPORT_FILES="$(SUPPORT_FILES)"
121
122.PHONY: gdb-taz
123gdb-taz: gdb-tar $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
124	$(MAKE) -f $(SELF) gdb-tar \
125		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
126		MD5PROG="$(MD5PROG)" \
127		SUPPORT_FILES="$(SUPPORT_FILES)"
128	$(MAKE) -f $(SELF) do-bz2 \
129		TOOL=$(TOOL) PACKAGE="$(PACKAGE)" VER="$(VER)" \
130		MD5PROG="$(MD5PROG)" \
131		SUPPORT_FILES="$(SUPPORT_FILES)"
132
133.PHONY: do-proto-toplev
134do-proto-toplev: $(DEVO_SUPPORT) $(SUPPORT_FILES) texinfo/texinfo.tex
135	echo "==> Making $(PACKAGE)-$(VER)/"
136	# Take out texinfo from a few places.
137	sed -e '/^all\.normal: /s/\all-texinfo //' \
138	    -e '/^	install-texinfo /d' \
139	<Makefile.in >tmp
140	mv -f tmp Makefile.in
141	#
142	./configure i686-pc-linux-gnu
143	$(MAKE) configure-host configure-target \
144	    ALL_GCC="" ALL_GCC_C="" ALL_GCC_CXX="" \
145	    CC_FOR_TARGET="$(CC)" CXX_FOR_TARGET="$(CXX)"
146	# Make links, and run "make diststuff" or "make info" when needed.
147	rm -rf proto-toplev ; mkdir proto-toplev
148	set -e ; dirs="$(DEVO_SUPPORT) $(SUPPORT_FILES) $(TOOL)" ; \
149	for d in $$dirs ; do \
150	  if [ -d $$d ]; then \
151	    if [ ! -f $$d/Makefile ] ; then true ; \
152	    elif grep '^diststuff:' $$d/Makefile >/dev/null ; then \
153		(cd $$d ; $(MAKE) MAKEINFOFLAGS="$(MAKEINFOFLAGS)" \
154			  diststuff ) || exit 1 ; \
155	    elif grep '^info:' $$d/Makefile >/dev/null ; then \
156		(cd $$d ; $(MAKE) MAKEINFOFLAGS="$(MAKEINFOFLAGS)" \
157			  info ) || exit 1 ; \
158	    fi ; \
159	    if [ -d $$d/proto-$$d.dir ]; then \
160	      ln -s ../$$d/proto-$$d.dir proto-toplev/$$d ; \
161	    else \
162	      ln -s ../$$d proto-toplev/$$d ; \
163	    fi ; \
164	  else ln -s ../$$d proto-toplev/$$d ; fi ; \
165	done
166	cd etc && $(MAKE) MAKEINFOFLAGS="$(MAKEINFOFLAGS)" info
167	$(MAKE) distclean
168	# Kludge for pr gdb/857.  intl/Makefile.in lacks a couple
169	# of files in the distclean rule.  Zack W is planning to make
170	# the gcc version of intl/ the master version and then push
171	# that version to src soon.  See:
172	#   http://sources.redhat.com/ml/binutils/2003-07/msg00032.html
173	# After the src version of intl/ is upgraded, we can look at
174	# moving this logic into intl/Makefile.in distclean rule
175	# if it is still needed.  -- chastain 2003-09-12
176	rm -f intl/config.cache
177	rm -f intl/config.status
178	rm -f intl/config.h
179	rm -f intl/stamp-h
180	#
181	mkdir proto-toplev/etc
182	(cd proto-toplev/etc; \
183	 for i in $(ETC_SUPPORT); do \
184		ln -s ../../etc/$$i . ; \
185	 done)
186	#
187	# Take out texinfo from configurable dirs
188	rm proto-toplev/configure.ac
189	sed -e '/^host_tools=/s/texinfo //' \
190	    <configure.ac >proto-toplev/configure.ac
191	#
192	mkdir proto-toplev/texinfo
193	ln -s ../../texinfo/texinfo.tex		proto-toplev/texinfo/
194	if test -r texinfo/util/tex3patch ; then \
195	  mkdir proto-toplev/texinfo/util && \
196	  ln -s ../../../texinfo/util/tex3patch	proto-toplev/texinfo/util ; \
197	else true; fi
198	chmod -R og=u . || chmod og=u `find . -print`
199	#
200	# Create .gmo files from .po files.
201	for f in `find . -name '*.po' -type f -print`; do \
202	     msgfmt -o `echo $$f | sed -e 's/\.po$$/.gmo/'` $$f ; \
203	done
204	#
205	-rm -f $(PACKAGE)-$(VER)
206	ln -s proto-toplev $(PACKAGE)-$(VER)
207
208CVS_NAMES= \( -name CVS -o -name '.cvsignore' \)
209
210.PHONY: do-tar
211do-tar:
212	echo "==> Making $(PACKAGE)-$(VER).tar"
213	-rm -f $(PACKAGE)-$(VER).tar
214	find $(PACKAGE)-$(VER) -follow $(CVS_NAMES) -prune \
215			-o -type f -print \
216		| tar cTfh - $(PACKAGE)-$(VER).tar
217
218.PHONY: do-bz2
219do-bz2:
220	echo "==> Bzipping $(PACKAGE)-$(VER).tar.bz2"
221	-rm -f $(PACKAGE)-$(VER).tar.bz2
222	$(BZIPPROG) -v -9 $(PACKAGE)-$(VER).tar
223
224.PHONY: do-md5sum
225do-md5sum:
226	echo "==> Adding md5 checksum to top-level directory"
227	cd proto-toplev && find * -follow $(CVS_NAMES) -prune \
228			-o -type f -print \
229		| xargs $(MD5PROG) > ../md5.new
230	-rm -f proto-toplev/md5.sum
231	mv md5.new proto-toplev/md5.sum
232
233.PHONY: do-djunpack
234do-djunpack:
235	echo "==> Adding updated djunpack.bat to top-level directory"
236	echo - 's /gdb-[0-9\.]*/$(PACKAGE)-'"$(VER)"'/'
237	sed < djunpack.bat > djunpack.new \
238		-e 's/gdb-[0-9][0-9\.]*/$(PACKAGE)-'"$(VER)"'/'
239	-rm -f proto-toplev/djunpack.bat
240	mv djunpack.new proto-toplev/djunpack.bat
241
242TEXINFO_SUPPORT= texinfo/texinfo.tex
243DIST_SUPPORT= $(DEVO_SUPPORT) $(TEXINFO_SUPPORT)
244
245.PHONY: gas.tar.bz2
246GAS_SUPPORT_DIRS= bfd include libiberty opcodes intl setup.com makefile.vms mkdep
247gas.tar.bz2: $(DIST_SUPPORT) $(GAS_SUPPORT_DIRS) gas
248	$(MAKE) -f $(SELF) taz TOOL=gas \
249		MD5PROG="$(MD5PROG)" \
250		SUPPORT_FILES="$(GAS_SUPPORT_DIRS)"
251
252# The FSF "binutils" release includes gprof and ld.
253.PHONY: binutils.tar.bz2
254BINUTILS_SUPPORT_DIRS= bfd gas include libiberty opcodes ld gprof intl setup.com makefile.vms mkdep cpu
255binutils.tar.bz2: $(DIST_SUPPORT) $(BINUTILS_SUPPORT_DIRS) binutils
256	$(MAKE) -f $(SELF) taz TOOL=binutils \
257		MD5PROG="$(MD5PROG)" \
258		SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS)"
259
260.PHONY: gas+binutils.tar.bz2
261GASB_SUPPORT_DIRS= $(GAS_SUPPORT_DIRS) binutils ld gprof
262gas+binutils.tar.bz2: $(DIST_SUPPORT) $(GASB_SUPPORT_DIRS) gas
263	$(MAKE) -f $(SELF) taz TOOL=gas \
264		MD5PROG="$(MD5PROG)" \
265		SUPPORT_FILES="$(GASB_SUPPORT_DIRS)"
266
267GNATS_SUPPORT_DIRS=include libiberty send-pr
268gnats.tar.bz2: $(DIST_SUPPORT) $(GNATS_SUPPORT_DIRS) gnats
269	$(MAKE) -f  $(SELF) taz TOOL=gnats \
270		MD5PROG="$(MD5PROG)" \
271		SUPPORT_FILES="$(GNATS_SUPPORT_DIRS)"
272
273.PHONY: gdb.tar.bz2
274GDB_SUPPORT_DIRS= bfd include libiberty opcodes readline sim intl
275gdb.tar.bz2: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
276	$(MAKE) -f $(SELF) gdb-taz TOOL=gdb \
277		MD5PROG="$(MD5PROG)" \
278		SUPPORT_FILES="$(GDB_SUPPORT_DIRS)"
279.PHONY: gdb.tar
280gdb.tar: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
281	$(MAKE) -f $(SELF) gdb-tar TOOL=gdb \
282		MD5PROG="$(MD5PROG)" \
283		SUPPORT_FILES="$(GDB_SUPPORT_DIRS)"
284
285.PHONY: insight.tar.bz2
286INSIGHT_SUPPORT_DIRS= $(GDB_SUPPORT_DIRS) tcl tk itcl libgui
287insight.tar.bz2: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
288	$(MAKE) -f $(SELF) gdb-taz TOOL=gdb PACKAGE=insight \
289		MD5PROG="$(MD5PROG)" \
290		SUPPORT_FILES="$(INSIGHT_SUPPORT_DIRS)"
291.PHONY: insight.tar
292insight.tar: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb
293	$(MAKE) -f $(SELF) gdb-tar TOOL=gdb PACKAGE=insight \
294		MD5PROG="$(MD5PROG)" \
295		SUPPORT_FILES="$(INSIGHT_SUPPORT_DIRS)"
296
297.NOEXPORT:
298MAKEOVERRIDES=
299