# Makefile for GAS.
# Copyright (C) 1989, Free Software Foundation
# 
# This file is part of GAS, the GNU Assembler.
# 
# 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 1, or (at your option)
# any later version.
# 
# 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 GAS; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

# This makefile may be used to make the VAX, 68020, 80386, 
# SPARC, or ns32k assembler(s).

srcdir=../gas-1.36
VPATH=.:../gas-1.36
BINDIR = /usr/local/bin

# If you are on a BSD system, un-comment the next two lines, and comment out
# the lines for SystemV and HPUX below
G0 =  -I. -W
LDFLAGS = $(CFLAGS)
#
# To compile gas on a System Five machine, comment out the two lines above
# and un-comment out the next three lines
# Comment out the -lPW on the LOADLIBES line if you are using GCC.
# G0 = -g -I. -DUSG
G0 = -I. -DUSG  -O 
# LDFLAGS = $(CFLAGS)
LOADLIBES = -lbsd # -lmalloc -lPW
CC=xgcc # -fstrength-reduce -fcombine-regs # -finline-functions
#
# To compile gas for HPUX, link m-hpux.h to m68k.h , and un-comment the
# next two lines.  (If you are using GCC, comment out the alloca.o part)
# (Get alloca from the emacs distribution, or use GCC.)
# HPUX 7.0 may have a bug in setvbuf.  gas gives an error message like
# 1:"Unknown operator" -- Statement 'NO_APP' ignored
# if setvbuf is broken.  Re-compile input-file.c (and only input-file.c
# with -DVMS and the problem should go away.
#
# G0 = -g -I. -DUSG
# LOADLIBES = alloca.o
#
# To compile gas for a Sequent Symmetry, comment out all the above lines,
# and un-comment the next two lines.
# G0 = -g -I. -DUSE_SYSTEM_HDR -DEXEC_VERSION=1
# LOADLIBES = -lc /usr/att/lib/libc.a

# If you just want to compile the vax assembler, type 'make avax'

# If you just want to compile the i386 assembler, type 'make a386'

# If you just want to compile the ns32k assembler, type 'make a32k'

# If you just want to compile the sparc assembler, type 'make asparc'

# If you just want to compile the mc68020 assembler, make sure m68k.h
# is correctly set up, and type type 'make a68'  (Except on HPUX machines,
# where you will have to make the changes marked below before typing
# 'make a68'
# m68k.h should be a symbolic or hard-link to one of
# m-sun3.h , m-hpux.h or m-generic.h
# depending on which machine you want to compile the 68020 assembler for.
#
# If you want the 68k assembler to be completely compatable with the the
# SUN one, un-comment the -DSUN_ASM_SYNTAX line below.
#
# If you machine does not have vfprintf, but does have _doprnt(),
# remove the # from the -DNO_VARARGS line below.
#
# If the return-type of a signal-hander is void (instead of int),
# remove the # from the -DSIGTY line below.
#
# To include the mc68851 mmu coprocessor instructions in the 68020 assembler,
# remove the # from the -Dm68851 line below.
#
# If you want the 68020 assembler use a register prefix character, un-comment
# the REGISTER_PREFIX line, and (maybe) change the '%' to the appropriate
# character.
#
# If you want the assembler to treat .L* or ..* symbols as local, instead of
# the usual L* symbols, un-comment the DOT_LABEL_PREFIX line.
#
# If you want the 80386 assembler to correctly handle fsub/fsubr and fdiv/fdivr
# opcodes (unlike most 80386 assemblers), remove the # from
# the -DNON_BROKEN_WORDS line below.
#
# To compile 80386 Gas for the Sequent Symmetry, un-comment the -DEXEC_VERSION
# and the -DUSE_SYSTEM_HDR lines below.
#
# To compile gas for the HP 9000/300 un-comment the -DUSE_HP_HDR line below.
#
# For the ns32k, the options are 32532 or 32032 CPU and 32381 or 32081 FPU.
# To select the NS32532, remove the # from the -DNS32532 line below.
# To compile in tne NS32381 opcodes in addition to the NS32081 opcodes
# (the 32381 is a superset of the 32081), remove the # from the -DNS32381
# line below.
#
# If you want gas to produce a COFF files by default and a.out files
# optionally remove the # from the -DCOFF_OPTION=FALSE line below
#
# If you want gas to produce a.out files by default and COFF files
# optionally remove the # from the -DCOFF_OPTION=TRUE line below
#
# If you want gas to produce only a.out files, leave both -DCOFF_OPTION
# lines commented out.
#
# If you need special defines that are not anticipated by the provided 
# options, define them in SPECIAL_GLOBAL_DEFINES here, and uncomment the 
# $(SPECIAL_GLOBAL_DEFINES) in G9 below.
SPECIAL_GLOBAL_DEFINES = 
#
# If you are using a backend for a special object format (such
# as COFF, ELF, MACHO, etc) and need special options for compiling 
# that backend, define these in BACKEND_CROSS_FLAGS here, 
# and uncomment the $(BACKEND_CROSS_FLAGS) below.
BACKEND_CROSS_FLAGS =   # -finline-functions
#
# if you need any special include paths for building a cross version
# with an alternate object format backend, define BACKEND_INCDIR_SPEC 
# and uncomment BACKEND_INCDIR_SPEC in B3 below.  You would undoubtably 
# use different names than the sample shown here. 
#BACKEND_INCDIR_SPEC = -I/usr/include -I/CMS6/CDS/CDS016/pbbs5/include
#
# If you are building a coff m68k gas for use with a coff loader that does not 
# understand pc relative relocations, uncomment the -DM68K_NO_PCREL_RELOC
# below.

O1 = # -DNO_VARARGS
O2 = # -DNON_BROKEN_WORDS
O3 = # -Dm68851
O4 = # -DEXEC_VERSION=1
O5 = # -DSIGTY=void
O6 = # -DNS32532
O6 = # -DNS32381
O7 =  -DDOT_LABEL_PREFIX
O9 =  -DREGISTER_PREFIX=\'%\'

G4 = # -DUSE_SYSTEM_HDR
G5 = # -DUSE_HP_HDR
G6 = # -DSUN_ASM_SYNTAX
G8 = # $(SPECIAL_GLOBAL_DEFINES)
B1 =  -DCOFF_OPTION=FALSE
B2 = # -DCOFF_OPTION=TRUE
B3 =  $(BACKEND_INCDIR_SPEC)
B4 = # -DM68K_NO_PCREL_RELOC
OUTPUT_OPTIONS = $(B1) $(B2) $(B3) $(B4)

OPTIONS = $(O1) $(O2) $(O3) $(O4) $(O5) $(O6) $(O7) $(O8) $(O9) $(O10) $(OUTPUT_OPTIONS)

CFLAGS = $(G0) $(G4) $(G5) $(G6) $(G7) $(G8) 

#
# To make the 68020 assembler compile as the default, un-comment the next
# line, and comment out all the other lines that start with DEFAULT_GAS
DEFAULT_GAS=a68
#
# To make the VAX assembler compile as the default, un-comment the next
# line and commment out all the other lines that start with DEFAULT_GAS
#DEFAULT_GAS=avax
#
# To make the Sun 386i assembler compile as the default, un-comment the next
# line and commment out all the other lines that start with DEFAULT_GAS
#DEFAULT_GAS=asun386
#
# To make the Non-Sun 80386 assembler compile as the default, un-comment the
# next line and commment out all the other lines that start with DEFAULT_GAS
#DEFAULT_GAS=a386
#
# To make the ns32k assembler compile as the default, un-comment the next
# line and commment out all the other lines that start with DEFAULT_GAS
#DEFAULT_GAS=a32k
#
# To make the sparc assembler compile as the default, un-comment the next
# line and commment out all the other lines that start with DEFAULT_GAS
#DEFAULT_GAS=asparc

# Global Sources -------------------------------------------------------------

a =\
as.o		xrealloc.o	xmalloc.o	hash.o		hex-value.o   \
atof-generic.o	append.o	messages.o	expr.o		app.o         \
frags.o		input-file.o	input-scrub.o	output-file.o	              \
subsegs.o	symbols.o					version.o     \
flonum-const.o	flonum-copy.o	flonum-mult.o	strstr.o	bignum-copy.o \
obstack.o
#gdb.o		gdb-file.o	gdb-symbols.o	gdb-blocks.o	gdb-lines.o

a:	$(DEFAULT_GAS)
	@rm -f a
	@ln $(DEFAULT_GAS) a
#
# The explicit srcdir references below for sources whose objects will be renamed 
# are present because sun make's VPATH support is not as smart as that in GNU make.

# SPARC GAS ------------------------------------------------------------------
v = sparc.o  atof-ieee.o  write-sparc.o  read-sparc.o coff-sparc.o

V = sparc.c  sparc.h  sparc-opcode.h

atof-ieee.o:	flonum.h
sparc.o:	sparc.c sparc.h sparc-opcode.h as.h frags.h struc-symbol.h
sparc.o:	flonum.h expr.h hash.h md.h write.h read.h symbols.h
	$(CC) -c $(CFLAGS) -DSPARC $(srcdir)/sparc.c

coff-sparc.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_SPARC $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-sparc.o

write-sparc.o:	write.c
	$(CC) -c -DSPARC $(CFLAGS) $(OPTIONS) $(srcdir)/write.c
	mv write.o write-sparc.o

read-sparc.o: read.c
	$(CC) -c -DSPARC $(CFLAGS) $(srcdir)/read.c
	mv read.o read-sparc.o

asparc: $a $v
	$(CC) -o asparc $(LDFLAGS) $a $v $(LOADLIBES)

# NS32K GAS ------------------------------------------------------------------
w = ns32k.o  atof-ieee.o  write-ns32k.o  read-ns32k.o coff-ns32k.o

W = ns32k.c ns32k-opcode.h

atof-ieee.o:	flonum.h
ns32k.o:	ns32k.c as.h frags.h struc-symbol.h flonum.h expr.h md.h hash.h
ns32k.o:	write.h symbols.h ns32k-opcode.h 
	$(CC) $(CFLAGS) $(OPTIONS) -c $(srcdir)/ns32k.c

coff-ns32k.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_NS32K $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-ns32k.o

write-ns32k.o:	write.c
	$(CC) -c -DNS32K $(CFLAGS) $(OPTIONS) $(srcdir)/write.c
	mv write.o write-ns32k.o

read-ns32k.o: read.c
	$(CC) -c -DNS32K $(CFLAGS) $(srcdir)/read.c
	mv read.o read-ns32k.o

a32k: $a $w
	$(CC) -o a32k $(LDFLAGS) $a $w $(LOADLIBES)

# 80386 GAS ------------------------------------------------------------------
x = i386.o  atof-ieee.o  write.o  read.o coff-i386.o

X = i386.c  i386.h  i386-opcode.h

coff-i386.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_386 $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-i386.o

i386.o:		i386.c as.h read.h flonum.h frags.h struc-symbol.h expr.h
i386.o:		symbols.h hash.h md.h i386.h i386-opcode.h
	$(CC) $(CFLAGS) $(OPTIONS) -c $(srcdir)/i386.c

atof-ieee.o:	flonum.h

a386: $a $x
	$(CC) -o a386 $(LDFLAGS) $a $x $(LOADLIBES)

# SUN 386i GAS ------------------------------------------------------------------
xs = i386.o  atof-ieee.o  write.o  read.o coff-sun386.o

Xs = i386.c  i386.h  i386-opcode.h

coff-sun386.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_SUN386 $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-sun386.o

atof-ieee.o:	flonum.h

asun386: $a ${xs}
	$(CC) -o asun386 $(LDFLAGS) $a ${xs} $(LOADLIBES)

# 68020 GAS ------------------------------------------------------------------
y = m68k.o  atof-ieee.o write.o read.o coff-m68k.o

Y = m68k.c atof-ieee.c m68k-opcode.h m-hpux.h m-sun3.h m-generic.h

atof-ieee.o:	flonum.h

coff-m68k.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_68K $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-m68k.o

m68k.o:		m68k.c a.out.h as.h expr.h flonum.h frags.h hash.h
m68k.o:		m68k-opcode.h m68k.h md.h obstack.h struc-symbol.h
	$(CC) $(CFLAGS) $(OPTIONS) -c $(srcdir)/m68k.c

a68: $a $y
	$(CC) -o a68 $(LDFLAGS) $a $y $(LOADLIBES)

# apollo GAS ------------------------------------------------------------------
# Warning:
# The only targets in this section that I have tested are "regression_tests"
# and the targets it is dependent upon. - mb

ya = m68k.o  atof-ieee.o write.o read.o coff-apollo.o
yr = m68k.o  atof-ieee.o write.o read.o coff-regress.o
yo = m68k.o  atof-ieee.o write.o read.o coff-orig.o
YA = m68k.c atof-ieee.c m68k-opcode.h m-hpux.h m-sun3.h m-generic.h

atof-ieee.o:	flonum.h

coff-apollo.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_APOLLO $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-apollo.o

coff-regress.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_APOLLO -DREGRESSION_TEST $(CFLAGS) \
		$(OPTIONS) $(srcdir)/coff-conv.c
	mv coff-conv.o coff-regress.o

coff-orig.o:	coff-orig.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_APOLLO $(CFLAGS) -DREGRESSION_TEST \
		$(OPTIONS) $(srcdir)/coff-orig.c

a68apollo: $a ${ya}
	$(CC) -o a68apollo $(LDFLAGS) $a ${ya} $(LOADLIBES)

a68regress: $a ${yr}
	$(CC) -o a68regress $(LDFLAGS) $a ${yr} $(LOADLIBES)

a68base: $a ${yo}
	$(CC) -o a68base $(LDFLAGS) $a ${yo} $(LOADLIBES)

m68k.s: m68k.c
	$(CC) -I. $(OPTIONS) -S $(srcdir)/m68k.c

# compare results with those from old no stabs version from apollo
# If you use the "-C" option for coff, uncomment the following line: 
#C_OPTION = -C
regression_test: a68regress a68base m68k.s
	a68base -o base.o $(C_OPTION) m68k.s
	a68regress -o new.o $(C_OPTION) m68k.s
	@-echo expect no differences after byte 10:
	-cmp -l base.o new.o

# VAX GAS --------------------------------------------------------------------
z = vax.o  atof-vax.o  write.o  read.o coff-vax.o

Z = vax.c atof-vax.c vax-opcode.h vax-inst.h    make-gas.com objrecdef.h vms.c

coff-vax.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_VAX $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c
	mv coff-conv.o coff-vax.o

vax.o:		vax.c a.out.h as.h expr.h flonum.h frags.h md.h obstack.h
vax.o:		read.h struc-symbol.h symbols.h vax-inst.h vax-opcode.h
atof-vax.o:	as.h flonum.h read.h

avax:	$a $z
	$(CC) -o avax $(LDFLAGS) $a $z $(LOADLIBES)

# global files ---------------------------------------------------------------

as.o: as.c
	$(CC) $(CFLAGS) $(OPTIONS) -c $(srcdir)/as.c

write.o:	write.c
	$(CC) $(CFLAGS) $(OPTIONS) -c $(srcdir)/write.c

messages.o: messages.c
	$(CC) $(CFLAGS) $(OPTIONS) -c $(srcdir)/messages.c

hash.o:	hash.c
	$(CC) $(CFLAGS) -Derror=as_fatal -c $(srcdir)/hash.c

xmalloc.o:	xmalloc.c
	$(CC) $(CFLAGS) -Derror=as_fatal -c $(srcdir)/xmalloc.c

xrealloc.o:	xrealloc.c
	$(CC) $(CFLAGS) -Derror=as_fatal -c $(srcdir)/xrealloc.c


A =\
as.c		xrealloc.c	xmalloc.c	hash.c		hex-value.c \
atof-generic.c	append.c	messages.c	expr.c		bignum-copy.c \
frags.c		input-file.c	input-scrub.c	output-file.c	read.c \
subsegs.c	symbols.c	write.c				strstr.c \
flonum-const.c	flonum-copy.c	flonum-mult.c	app.c		version.c \
obstack.c \
#gdb.c		gdb-file.c	gdb-symbols.c	gdb-blocks.c \
#gdb-lines.c

H = \
a.out.h		as.h		bignum.h	expr.h		flonum.h \
frags.h		hash.h		input-file.h	md.h	 \
obstack.h	read.h		struc-symbol.h	subsegs.h	\
symbols.h	write.h

dist: COPYING README ChangeLog $A $H $Z $Y $X $W $V Makefile
	echo gas-`sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q < version.c` > .fname
	mkdir `cat .fname`

	ln COPYING README ChangeLog $A $H $Z $Y $X $W $V Makefile `cat .fname`
	tar cvhZf `cat .fname`.tar.Z `cat .fname`
	-rm -r `cat .fname`
	-rm .fname

COFF_ADD = `cat GASONLY` gas-1.36/Makefile

COFF_DIFFS = gas-1.36/GASDIFFS

DIST = /dca/local/gnu/gas/gas-1.36/gas-1.36

coff-diffs:
	rm -f GASDIFFS
	-diff -rc $(DIST) . >../GASDIFFS

coff-only:
	-grep '^Only' ../GASDIFFS | awk '{print "gas-1.36/" $$4 }' >../GASONLY
	-grep -v '^Only' ../GASDIFFS> GASDIFFS

coff-dist: 
	(cd .. ;tar cf gascoff.tar $(COFF_DIFFS) $(COFF_ADD) )
clean:
	rm -f a avax a68 a386 a32k asparc $a $v $w $x $y $z a core gmon.out bugs a.out

install:	a
	cp a $(BINDIR)/gas


# General .o-->.h dependencies

app.o:		as.h
as.o:		a.out.h as.h read.h struc-symbol.h write.h
atof-generic.o:	flonum.h
bignum-copy.o:	bignum.h
expr.o:		a.out.h as.h expr.h flonum.h obstack.h read.h struc-symbol.h
expr.o:		 symbols.h
flonum-const.o:	flonum.h
flonum-copy.o:	flonum.h
flonum-mult.o:	flonum.h
flonum-normal.o:flonum.h
flonum-print.o:	flonum.h
frags.o:	a.out.h as.h frags.h obstack.h struc-symbol.h subsegs.h
#gdb.o:		as.h
#gdb-blocks.o:	as.h
#gdb-lines.o:	as.h frags.h obstack.h
#gdb-symbols.o:	a.out.h as.h struc-symbol.h
hash.o:		hash.h
input-file.o:	input-file.h
input-scrub.o:	as.h input-file.h read.h
messages.o:	as.h
obstack.o:	obstack.h
read.o:		a.out.h as.h expr.h flonum.h frags.h hash.h md.h obstack.h
read.o:		read.h struc-symbol.h symbols.h
subsegs.o:	a.out.h as.h frags.h obstack.h struc-symbol.h subsegs.h write.h
symbols.o:	a.out.h as.h frags.h hash.h obstack.h struc-symbol.h symbols.h
write.o:	a.out.h as.h md.h obstack.h struc-symbol.h subsegs.h
write.o:	symbols.h write.h

flonum.h:					bignum.h

# humantussin targets:

human-vax.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_VAX $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-vax.o

human-sparc.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_SPARC $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-sparc.o

human-ns32k.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_NS32K $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-ns32k.o
human-i386.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_386 $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-i386.o
human-sun386.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_SUN386 $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-sun386.o
human-m68k.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_68K $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-m68k.o
human-apollo.o:	coff-conv.c stab.gnu.h stab.def
	$(CC) -c -DTARGET=TARGET_APOLLO $(CFLAGS) $(OPTIONS) \
		$(srcdir)/coff-conv.c -DSTANDALONE_CONV
	mv coff-conv.o human-apollo.o

HUMAN = humantussin.o xmalloc.o xrealloc.o

hvax: 		human-vax.o $(HUMAN)
	$(CC) -o hvax $(LDFLAGS) human-vax.o $(HUMAN) $(LOADLIBES)

hsparc:		human-sparc.o $(HUMAN)
	$(CC) -o hsparc $(LDFLAGS) human-sparc.o $(HUMAN) $(LOADLIBES)

hns32k: 	human-ns32k.o $(HUMAN)
	$(CC) -o hns32k $(LDFLAGS) human-ns32k.o $(HUMAN) $(LOADLIBES)

hi386: 		human-i386.o $(HUMAN)
	$(CC) -o hi386 $(LDFLAGS) human-i386.o $(HUMAN) $(LOADLIBES)

hsun386:	human-sun386.o $(HUMAN)
	$(CC) -o hsun386 $(LDFLAGS) human-sun386.o $(HUMAN) $(LOADLIBES)

hm68k: 		human-m68k.o $(HUMAN)
	$(CC) -o hm68k $(LDFLAGS) human-m68k.o $(HUMAN) $(LOADLIBES)

hapollo:	human-apollo.o $(HUMAN)
	$(CC) -o hapollo $(LDFLAGS) human-apollo.o $(HUMAN) $(LOADLIBES)

