# Makefile for avcall

#### Start of system configuration section. ####

HOST = @host@
CPU = @host_cpu@

# Directories used by "make":
srcdir = @srcdir@

# Directories used by "make install":
prefix = @prefix@
local_prefix = /usr/local
exec_prefix = $(prefix)
libdir = $(exec_prefix)/lib
includedir = $(local_prefix)/include
mandir = $(exec_prefix)/man

# Programs used by "make":
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
INCLUDES = -I. -I$(srcdir)
ASPFLAGS = `if test @AS_UNDERSCORE@ = true; then echo '-DUNDERSCORE'; fi`
AR = ar
AR_FLAGS = rc
RANLIB = @RANLIB@
MV = mv
LN = ln
RM = rm -f
@SET_MAKE@

# Programs used by "make install":
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

#### End of system configuration section. ####

SHELL = /bin/sh

OBJECTS = avcall.o structcpy.o

all : $(OBJECTS) libavcall.a avcall.h $(srcdir)/avcall.3 $(srcdir)/avcall.html

avcall.o : avcall-$(CPU).o
	$(RM) avcall.o
	$(LN) avcall-$(CPU).o avcall.o

avcall-i386.o : avcall-i386.s
	$(CC) -c avcall-i386.s

avcall-i386.s : $(srcdir)/avcall-i386.S
	$(CPP) $(ASPFLAGS) $(srcdir)/avcall-i386.S | grep -v '^ *#line' | grep -v '^#ident' | sed -e 's,% ,%,g' > avcall-i386.s

avcall-sparc.o : avcall-sparc.s
	$(CC) -c avcall-sparc.s

avcall-sparc.s : $(srcdir)/avcall-sparc.S
	$(CPP) $(ASPFLAGS) $(srcdir)/avcall-sparc.S > avcall-sparc.s

avcall-m68k.o : $(srcdir)/avcall-m68k.s
	$(CC) -c $(srcdir)/avcall-m68k.s

avcall-mips.o : $(srcdir)/avcall-mips.s
	$(CC) -c $(srcdir)/avcall-mips.s

avcall-alpha.o : $(srcdir)/avcall-alpha.s
	$(CC) -c $(srcdir)/avcall-alpha.s

avcall-hppa.o : $(srcdir)/avcall-hppa.s
	$(CC) -c $(srcdir)/avcall-hppa.s

avcall-arm.o : $(srcdir)/avcall-arm.s
	$(CC) -c $(srcdir)/avcall-arm.s

avcall-rs6000.o : $(srcdir)/avcall-rs6000.s
	$(CC) -c $(srcdir)/avcall-rs6000.s

avcall-m88k.o : $(srcdir)/avcall-m88k.s
	$(CC) -c $(srcdir)/avcall-m88k.s

avcall-convex.o : $(srcdir)/avcall-convex.s
	$(CC) -c $(srcdir)/avcall-convex.s

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

libavcall.a : $(OBJECTS)
	$(RM) libavcall.a
	$(AR) $(AR_FLAGS) libavcall.a $(OBJECTS)
	$(RANLIB) libavcall.a

install : all force
	if [ ! -d $(libdir) ] ; then mkdir $(libdir) ; fi
	$(INSTALL_DATA) libavcall.a $(libdir)/libavcall.a
	if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
	$(INSTALL_DATA) avcall.h $(includedir)/avcall.h
	if [ ! -d $(mandir) ] ; then mkdir $(mandir) ; fi
	if [ ! -d $(mandir)/man3 ] ; then mkdir $(mandir)/man3 ; fi
	$(INSTALL_DATA) $(srcdir)/avcall.3 $(mandir)/man3/avcall.3
	if [ ! -d $(mandir)/html ] ; then mkdir $(mandir)/html ; fi
	$(INSTALL_DATA) $(srcdir)/avcall.html $(mandir)/html/avcall.html

installdirs : force
	if [ ! -d $(libdir) ] ; then mkdir $(libdir) ; fi
	if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
	if [ ! -d $(mandir) ] ; then mkdir $(mandir) ; fi
	if [ ! -d $(mandir)/man3 ] ; then mkdir $(mandir)/man3 ; fi
	if [ ! -d $(mandir)/html ] ; then mkdir $(mandir)/html ; fi

uninstall : force
	$(RM) $(libdir)/libavcall.a
	$(RM) $(includedir)/avcall.h
	$(RM) $(mandir)/man3/avcall.3
	$(RM) $(mandir)/html/avcall.html

tests.o : $(srcdir)/tests.c avcall.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/tests.c

tests.s : $(srcdir)/tests.c avcall.h
	$(CC) $(CFLAGS) $(INCLUDES) -S $(srcdir)/tests.c

tests : tests.o $(OBJECTS)
	$(CC) $(CFLAGS) tests.o $(OBJECTS) -o tests

check : all tests
	./tests > tests.out
	uniq -u < tests.out > tests.output.$(HOST)
	test '!' -s tests.output.$(HOST)

mostlyclean : clean

clean : force
	$(RM) *.o *.a core
	$(RM) avcall-i386.s avcall-sparc.s
	$(RM) tests.o tests.s tests tests.out

distclean : clean
	$(RM) config.status config.log config.cache Makefile avcall.h tests.output.*

maintainer-clean : distclean

force :

