# Generated automatically from Makefile.in by configure.
# Makefile for GNU Assembler
#   Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
#   Free Software Foundation, Inc.

# This file is part of GNU GAS.

# GNU GAS 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 2, or (at your option)
# any later version.

# GNU GAS 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 GNU GAS; see the file COPYING.  If not, write to the Free
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

# The targets for external use include:
# all, doc, proto, install, uninstall, includes, TAGS,
# clean, mostlyclean, distclean, realclean, stage1, stage2, stage3, stage4.

# Variables that exist for you to override.
# See below for how to change them for certain systems.

srcdir = .
srcroot = $(srcdir)/..

target_alias = i386-aout-vsta
prefix = /usr/local

program_transform_name = s,x,x,
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
tooldir = $(exec_prefix)/$(target_alias)

datadir = ${prefix}/share
mandir = ${prefix}/man
man1dir = $(mandir)/man1
man2dir = $(mandir)/man2
man3dir = $(mandir)/man3
man4dir = $(mandir)/man4
man5dir = $(mandir)/man5
man6dir = $(mandir)/man6
man7dir = $(mandir)/man7
man8dir = $(mandir)/man8
man9dir = $(mandir)/man9
infodir = ${prefix}/info
includedir = ${prefix}/include

VERSION=2.8.1

SHELL = /bin/sh

INSTALL = $${srcroot}/install.sh -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)'
INSTALL_XFORM1= $(INSTALL_XFORM) -b=.1

DISTSTUFF= make-gas.com m68k-parse.c itbl-parse.c itbl-parse.h itbl-lex.c

AR = ar
AR_FLAGS = qv
BISON = bison -y
BISONFLAGS =
LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ;  else echo flex ; fi`
LEXFLAGS =
MAKEINFO = makeinfo
TEXI2DVI = texi2dvi
RANLIB = ranlib
CC = gcc -O2
HLDFLAGS = 
HLDENV = 
RPATH_ENVVAR = LD_LIBRARY_PATH
CFLAGS =
LDFLAGS =
DEP = mkdep

MAKEOVERRIDES=

EXPECT = `if [ -f $${rootme}/../expect/expect ] ; then \
          echo $${rootme}/../expect/expect ; \
          else echo expect ; fi`

FLAGS_TO_PASS = \
	"prefix=$(prefix)" \
	"exec_prefix=$(exec_prefix)" \
	"tooldir=$(tooldir)" \
	"AR=$(AR)" \
	"AR_FLAGS=$(AR_FLAGS)" \
	"CC=$(CC)" \
	"CFLAGS=$(CFLAGS)" \
	"RANLIB=$(RANLIB)" \
	"LOADLIBES=$(LOADLIBES)" \
	"LDFLAGS=$(LDFLAGS)" \
	"BISON=$(BISON)" \
	"LEX=$(LEX)" \
	"MAKEINFO=$(MAKEINFO)" \
	"INSTALL=$(INSTALL)" \
	"INSTALL_DATA=$(INSTALL_DATA)" \
	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)"

RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
		echo $${srcdir}/../dejagnu/runtest ; else echo runtest; \
	   fi`
RUNTESTFLAGS=

TARG_CPU = i386
TARG_CPU_C = $(srcdir)/config/tc-i386.c
TARG_CPU_O = tc-i386.o
TARG_CPU_H = $(srcdir)/config/tc-i386.h
OBJ_FORMAT_C = $(srcdir)/config/obj-aout.c
OBJ_FORMAT_O = obj-aout.o
OBJ_FORMAT_H = $(srcdir)/config/obj-aout.h
TARG_ENV_H = $(srcdir)/config/te-generic.h
ATOF_TARG_C = $(srcdir)/config/atof-ieee.c
ATOF_TARG_O = atof-ieee.o

# use i386 for refering to configured target name
IT_HDRS=itbl-parse.h $(srcdir)/itbl-ops.h 
IT_SRCS=itbl-parse.c itbl-lex.c $(srcdir)/itbl-ops.c
IT_DEPS=$(srcdir)/itbl-parse.y $(srcdir)/itbl-lex.l $(srcdir)/config/itbl-i386.h
IT_OBJS=itbl-parse.o itbl-lex.o itbl-ops.o

# CPU types.  This is only used for dependency information.

CPU_TYPES = \
	a29k \
	alpha \
	arm \
	d10v \
	h8300 \
	h8500 \
	hppa \
	i386 \
	i860 \
	i960 \
	m32r \
	m68k \
	m88k \
	mips \
	mn10200 \
	mn10300 \
	ns32k \
	ppc \
	sh \
	sparc \
	tahoe \
	vax \
	w65 \
	z8k

# Object format types.  This is only used for dependency information.
# We deliberately omit som, since it does not work as a cross assembler.

OBJ_FORMATS = \
	aout \
	bout \
	coff \
	ecoff \
	elf \
	evax \
	hp300 \
	ieee \
	vms

# This is an sh case which sets valid according to whether the CPU
# type in the shell variable c and the OS type in the shell variable o
# are supported.  This helps cuts down on the amount of dependency
# information.

CPU_OBJ_VALID = \
	valid= ; \
	case $$o in \
	aout) \
	  case $$c in \
	  a29k | arm | i386 | i860 | m68k | mips | ns32k | sparc | tahoe | vax) \
	    valid=yes ;; \
	  esac ;; \
	bout) \
	  case $$c in \
	  i960) valid=yes ;; \
	  esac ;; \
	coff) valid=yes ;; \
	ecoff) \
	  case $$c in \
	  mips | alpha) valid=yes ;; \
	  esac ;; \
	elf) valid=yes ;; \
	evax) \
	  case $$c in \
	  alpha) valid=yes ;; \
	  esac ;; \
	hp300) \
	  case $$c in \
	  m68k) valid=yes ;; \
	  esac ;; \
	vms) \
	  case $$c in \
	  vax) valid=yes ;; \
	  esac ;; \
	esac;

# This is like CPU_OBJ_VALID, for the obj=multi case.

CPU_MULTI_VALID = \
	valid= ; \
	case $$c in \
	i386 | mips) valid=yes ;; \
	esac;

# Regular source files.

CFILES = \
	app.c \
	as.c \
	atof-generic.c \
	bignum-copy.c \
	cond.c \
	ecoff.c \
	expr.c \
	flonum-copy.c \
	flonum-konst.c \
	flonum-mult.c \
	frags.c \
	gasp.c \
	hash.c \
	input-file.c \
	input-scrub.c \
	itbl-ops.c \
	listing.c \
	literal.c \
	macro.c \
	messages.c \
	output-file.c \
	read.c \
	sb.c \
	stabs.c \
	subsegs.c \
	symbols.c \
	write.c

HFILES = \
	as.h \
	bignum.h \
	bit_fix.h \
	ecoff.h \
	emul-target.h \
	emul.h \
	expr.h \
	flonum.h \
	frags.h \
	hash.h \
	input-file.h \
	itbl-ops.h \
	listing.h \
	macro.h \
	obj.h \
	output-file.h \
	read.h \
	sb.h \
	struc-symbol.h \
	subsegs.h \
	symbols.h \
	tc.h \
	write.h

# CPU files in config.

TARGET_CPU_CFILES = \
	config/tc-i386.c

TARGET_CPU_HFILES = \
	config/tc-i386.h

# OBJ files in config

OBJ_FORMAT_CFILES = \
	config/obj-aout.c

OBJ_FORMAT_HFILES = \
	config/obj-aout.h

# Emulation header files in config

TARG_ENV_HFILES = \
	config/te-386bsd.h \
	config/te-aux.h \
	config/te-generic.h \
	config/te-linux.h \
	config/te-nbsd.h

# Multi files in config

MULTI_CFILES =

# 

OBJS = \
	$(TARG_CPU_O) \
	$(OBJ_FORMAT_O) \
	$(ATOF_TARG_O) \
	app.o \
	as.o \
	atof-generic.o \
	bignum-copy.o \
	cond.o \
	expr.o \
	flonum-konst.o \
	flonum-copy.o \
	flonum-mult.o \
	frags.o \
	hash.o \
	input-file.o \
	input-scrub.o \
	literal.o \
	messages.o \
	output-file.o \
	read.o \
	subsegs.o \
	symbols.o \
	write.o \
	listing.o \
	ecoff.o \
	stabs.o \
	sb.o \
	macro.o \
	

GASPOBJS = \
	gasp.o \
	macro.o \
	sb.o \
	hash.o

all: as.new gasp.new
	@srcroot=`cd $(srcroot); pwd`; export srcroot; \
	(cd doc ; $(MAKE) $(FLAGS_TO_PASS) all)

dvi info install-info clean-info:
	@srcroot=`cd $(srcroot); pwd`; export srcroot; \
	(cd doc ; $(MAKE) $(FLAGS_TO_PASS) $@)

make-gas.com: stamp-mk.com
stamp-mk.com: vmsconf.sh Makefile
	sh $(srcdir)/vmsconf.sh $(OBJS) > new-make.com
	./move-if-change new-make.com $(srcdir)/make-gas.com
	touch stamp-mk.com

# Now figure out from those variables how to compile and link.

# This is the variable actually used when we compile.
ALL_CFLAGS = -D_GNU_SOURCE $(INTERNAL_CFLAGS) $(CROSS) $(CFLAGS) $(HDEFINES) $(TDEFINES)

# How to link with both our special library facilities
# and the system's installed libraries.

LIBDEPS =   $(LOCAL_LOADLIBES) ../libiberty/libiberty.a
LIBS =   $(LOCAL_LOADLIBES) ../libiberty/libiberty.a

BASEDIR = $(srcdir)/..
BFDDIR = $(BASEDIR)/bfd
INCDIR = $(BASEDIR)/include

# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
# so that tm.h and config.h will be found in the compilation
# subdirectory rather than in the source directory.
INCLUDES = -I. -I$(srcdir) -I../bfd -I$(srcdir)/config -I$(INCDIR) -I$(srcdir)/.. -I$(BFDDIR)

# Always use -I$(srcdir)/config when compiling.
.c.o:
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $<

# This tells GNU make version 3 not to export all the variables
# defined in this file into the environment.
.NOEXPORT:

# Files to be copied away after each stage in building.
STAGESTUFF = *.o as.new gasp.new

$(OBJS): 

as.new: $(OBJS) $(LIBDEPS)
	$(HLDENV) $(CC) $(HLDFLAGS) $(ALL_CFLAGS) $(LDFLAGS) -o as.new $(OBJS) $(LIBS) $(LOADLIBES)

# Stuff that every object file depends upon.  If anything is removed
# from this list, remove it from dep-in.sed as well.
$(OBJS): config.h as.h $(TARG_ENV_H) $(OBJ_FORMAT_H) $(TARG_CPU_H) flonum.h \
	expr.h struc-symbol.h write.h frags.h hash.h read.h symbols.h tc.h \
	obj.h listing.h bignum.h bit_fix.h $(INCDIR)/libiberty.h

gasp.new: $(GASPOBJS) ../libiberty/libiberty.a
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o gasp.new $(GASPOBJS) ../libiberty/libiberty.a $(LOADLIBES)

installcheck:
	@echo No installcheck target is available yet for the GNU assembler.

site.exp: ./Makefile
	@echo "Making a new config file..."
	-@rm -f ./tmp?
	@touch site.exp
	-@mv site.exp site.bak
	@echo "## these variables are automatically generated by make ##" > ./tmp0
	@echo "# Do not edit here. If you wish to override these values," >> ./tmp0
	@echo "# do so in the last section."			>> ./tmp0
	@echo set host_os vsta				>> ./tmp0
	@echo set host_alias i386-aout-vsta			>> ./tmp0
	@echo set host_cpu i386				>> ./tmp0
	@echo set host_vendor aout			>> ./tmp0
	@echo set target_os vsta				>> ./tmp0
	@echo set target_alias i386-aout-vsta			>> ./tmp0
	@echo set target_cpu i386			>> ./tmp0
	@echo set target_vendor aout			>> ./tmp0
	@echo set host_triplet i386-aout-vsta				>> ./tmp0
	@echo set target_triplet i386-aout-vsta			>> ./tmp0
	@echo set target_canonical i386-aout-vsta			>> ./tmp0
	@echo set srcdir ${srcdir}/testsuite			>> ./tmp0
	@echo set exec_prefix ${exec_prefix}			>> ./tmp0
	@echo set objdir `pwd`					>> ./tmp0
	@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
	@sed -e '1,/^## All variables above are.*##/ d' < site.bak >> ./tmp0
	@mv -f ./tmp0 site.exp

check:  site.exp
	if [ -d testsuite ]; then \
	  true; \
	else \
	  mkdir testsuite; \
	fi
	rm -f testsuite/site.exp
	cp site.exp testsuite/site.exp
	rootme=`pwd`; export rootme; \
	srcdir=`cd ${srcdir}; pwd` ; export srcdir ; \
	$(RPATH_ENVVAR)=$$rootme/../bfd:$$rootme/../opcodes:$$$(RPATH_ENVVAR); \
	export $(RPATH_ENVVAR); \
	cd testsuite; \
	EXPECT=${EXPECT} ; export EXPECT ; \
	if [ -f $${rootme}/../expect/expect ] ; then  \
	   TCL_LIBRARY=$${srcdir}/../tcl/library ; \
	   export TCL_LIBRARY ; fi ; \
	$(RUNTEST) --tool gas --srcdir $${srcdir}/testsuite $(RUNTESTFLAGS)

#config.status: configure
#	$(SHELL) config.status --recheck

#config.h: config-stamp
#config-stamp: Makefile conf
#	-rm -f config.new config-stamp
#	echo '/* config.h.  Generated automatically by make.  */' > config.new
#	echo '#ifndef GAS_VERSION'			>> config.new
#	echo '#define GAS_VERSION "$(VERSION)"'		>> config.new
#	echo ''						>> config.new
#	cat conf					>> config.new
#	echo '#endif /* GAS_VERSION */'			>> config.new
#	./move-if-change config.new config.h
#	touch config-stamp

# The implicit .c.o rule doesn't work for these, perhaps because of
# the variables, or perhaps because the sources are not on vpath.
$(TARG_CPU_O): $(TARG_CPU_C) $(TARG_CPU_DEP_i386)
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(TARG_CPU_C)
$(ATOF_TARG_O): $(ATOF_TARG_C)
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(ATOF_TARG_C)

# ecoff.c only has full dependencies when ECOFF_DEBUGGING is defined,
# so the automatic dependency stuff doesn't work.
ecoff.o : ecoff.c ecoff.h $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h \
	$(INCDIR)/coff/ecoff.h $(INCDIR)/coff/symconst.h \
	$(INCDIR)/aout/stab_gnu.h

# We need all these explicit rules for the multi stuff.  Because of
# these rules, we don't need one for OBJ_FORMAT_O.

obj-aout.o : $(srcdir)/config/obj-aout.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-aout.c
obj-bout.o : $(srcdir)/config/obj-bout.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-bout.c
obj-coff.o: $(srcdir)/config/obj-coff.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-coff.c
obj-ecoff.o : $(srcdir)/config/obj-ecoff.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-ecoff.c
obj-elf.o : $(srcdir)/config/obj-elf.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-elf.c
obj-evax.o : $(srcdir)/config/obj-evax.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-evax.c
obj-hp300.o : $(srcdir)/config/obj-hp300.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-hp300.c
obj-ieee.o : $(srcdir)/config/obj-ieee.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-ieee.c
obj-multi.o : $(srcdir)/config/obj-multi.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-multi.c
obj-som.o : $(srcdir)/config/obj-som.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-som.c
obj-vms.o : $(srcdir)/config/obj-vms.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/obj-vms.c

e-mipself.o : $(srcdir)/config/e-mipself.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/e-mipself.c
e-mipsecoff.o : $(srcdir)/config/e-mipsecoff.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/e-mipsecoff.c
e-i386coff.o: $(srcdir)/config/e-i386coff.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/e-i386coff.c
e-i386elf.o: $(srcdir)/config/e-i386elf.c
	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/config/e-i386elf.c

# The m68k operand parser.

# The instruction table specification lexical analyzer and parser.

itbl-lex.c: $(srcdir)/itbl-lex.l
	$(LEX) $(LEXFLAGS) $(srcdir)/itbl-lex.l
	mv -f lex.yy.c itbl-lex.c

itbl-lex.o: itbl-lex.c itbl-parse.h

itbl-parse.c: $(srcdir)/itbl-parse.y
	$(BISON) -d $(BISONFLAGS) $(srcdir)/itbl-parse.y
	mv -f y.tab.c itbl-parse.c
	mv -f y.tab.h itbl-parse.h

itbl-parse.h: itbl-parse.c

itbl-parse.o: itbl-parse.c itbl-parse.h $(srcdir)/itbl-ops.h

itbl-ops.o: $(srcdir)/itbl-ops.c $(srcdir)/itbl-ops.h itbl-parse.h

# stand-alone itbl assembler & disassembler
itbl-test-ops.o: $(srcdir)/itbl-ops.c \
	$(srcdir)/itbl-ops.h itbl-parse.h
	$(CC) -o itbl-test-ops.o -DSTAND_ALONE -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(srcdir)/itbl-ops.c

itbl-test.o: $(srcdir)/testsuite/gas/all/itbl-test.c $(srcdir)/itbl-ops.h
	$(CC) -c -DSTAND_ALONE $(ALL_CFLAGS) $(INCLUDES)\
	$(srcdir)/testsuite/gas/all/itbl-test.c

IT_TEST_OBJS= itbl-parse.o itbl-lex.o itbl-test-ops.o
itbl-test: $(IT_TEST_OBJS) itbl-test.o $(LIBDEPS)
	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o itbl-test itbl-test.o $(IT_TEST_OBJS) $(LIBS)

# CGEN interface.

cgen.o: cgen.c cgen-opc.h subsegs.h \
	$(INCDIR)/obstack.h $(INCDIR)/opcode/cgen.h \
	$(srcdir)/../opcodes/$(TARG_CPU)-opc.h

# Remake the info files.

doc: $(srcdir)/as.info

$(srcdir)/as.info: $(srcdir)/doc/as.texinfo
	@(cd doc; $(MAKE) $(FLAGS_TO_PASS) as.info; mv as.info $srcdir)	

diststuff: $(DISTSTUFF) info

clean-here:
	-rm -f $(STAGESTUFF) core stamp-mk.com
	-rm -f testsuite/*.o testsuite/*.out \
		testsuite/gas.log testsuite/gas.sum testsuite/site.exp
	-rm -rf dep.sed .tcdep .objdep .dep2 .dep1 .depa .dep .depdir

clean mostlyclean: clean-here
	@cd doc ; $(MAKE) $(FLAGS_TO_PASS) $@

# Like clean but also delete the links made to configure gas.

DISTCLEAN_HERE = config.status Makefile targ-env.h targ-cpu.h obj-format.h \
	TAGS itbl-cpu.h cgen-opc.h site.exp site.bak \
	config-stamp config.h conf config.log config.cache \
	testsuite/Makefile testsuite/config.status

distclean: clean-here
	@cd doc ; $(MAKE) $(FLAGS_TO_PASS) $@
	-rm -f $(DISTCLEAN_HERE)

maintainer-clean realclean: clean-here
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
	@cd doc ; $(MAKE) $(FLAGS_TO_PASS) $@
	-rm -rf $(DISTCLEAN_HERE) $(DISTSTUFF)

# Entry points `install', `includes' and `uninstall'.

# Copy the files into directories where they will be run.
install:
	srcroot=`cd $(srcroot); pwd`; export srcroot; \
	$(INSTALL_XFORM) as.new $(bindir)/as; \
	$(INSTALL_XFORM1) $(srcdir)/doc/as.1 $(man1dir)/as.1; \
	test -d $(tooldir) || mkdir $(tooldir); \
	test -d $(tooldir)/bin || mkdir $(tooldir)/bin; \
	n=`echo as | sed '$(program_transform_name)'`; \
	rm -f $(tooldir)/bin/as; \
	ln $(bindir)/$$n $(tooldir)/bin/as >/dev/null 2>/dev/null \
	 || $(INSTALL_PROGRAM) as.new $(tooldir)/bin/as
	srcroot=`cd $(srcroot); pwd`; export srcroot; \
	$(INSTALL_XFORM) gasp.new $(bindir)/gasp

# Cancel installation by deleting the installed files.
uninstall:
	-n=`t='$(program_transform_name)'; echo as | sed $$t`; \
	rm -f $(bindir)/$$n; \
	rm -f $(mandir)/$$n.1
	-n=`t='$(program_transform_name)'; echo gasp | sed $$t`; \
	rm -f $(bindir)/$$n; \

# These exist for maintenance purposes.

tags TAGS: force
	etags $(HFILES) $(CFILES) $(srcdir)/config/*.[hc] $(srcdir)/README $(srcdir)/Makefile.in

bootstrap: as.new force
	$(MAKE) stage1
	rm -f stage && ln -s stage1 stage
	$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new gasp.new
	$(MAKE) stage2
	rm -f stage && ln -s stage2 stage
	$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new gasp.new
	$(MAKE) comparison against=stage2

bootstrap2: force
	rm -f stage && ln -s stage1 stage
	$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new gasp.new
	$(MAKE) stage2
	rm -f stage && ln -s stage2 stage
	$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new gasp.new
	$(MAKE) comparison against=stage2

bootstrap3: force
	rm -f stage && ln -s stage2 stage
	$(MAKE) CC="$(CC)" CFLAGS="-O -Bstage/ $(CFLAGS)" libdir=$(libdir) ALLOCA= as.new gasp.new
	$(MAKE) comparison against=stage2

# Copy the object files from a particular stage into a subdirectory.
stage1: force
	-mkdir stage1
	-mv $(STAGESTUFF) stage1
	if [ -f stage1/as.new -a ! -f stage1/as ] ; then (cd stage1 ; ln -s as.new as) ; fi

stage2: force
	-mkdir stage2
	-mv $(STAGESTUFF) stage2
	if [ -f stage2/as.new -a ! -f stage2/as ] ; then (cd stage2 ; ln -s as.new as) ; fi

stage3: force
	-mkdir stage3
	-mv $(STAGESTUFF) stage3
	if [ -f stage3/as.new -a ! -f stage3/as ] ; then (cd stage3 ; ln -s as.new as) ; fi

against=stage2

# This rule is derived from corresponding code in the Makefile.in for gcc.
# The "tail +16c" is to bypass headers which may include timestamps or
# temporary assembly file names.
comparison: force
	x=0 ; \
	for file in *.o ; do \
	  tail +16c ./$$file > tmp-foo1; \
	  if tail +16c ${against}/$$file > tmp-foo2 2>/dev/null ; then \
	    if cmp tmp-foo1 tmp-foo2 ; then \
	      true ; \
	    else \
	      echo $$file differs ; \
	      x=1 ; \
	    fi ; \
	  else true; fi ; \
	done ; \
	exit $$x
	-rm -f tmp-foo*

de-stage1: force
	- (cd stage1 ; rm -f as ; mv -f * ..)
	- rmdir stage1

de-stage2: force
	- (cd stage2 ; rm -f as ; mv -f * ..)
	- rmdir stage2

de-stage3: force
	- (cd stage3 ; rm -f as ; mv -f * ..)
	- rmdir stage3

#In GNU Make, ignore whether `stage*' exists.
.PHONY: stage1 stage2 stage3 stage4 clean mostlyclean realclean distclean
.PHONY: TAGS bootstrap
