# Makefile for avcall

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

HOST = i386-pc-win32-gcc
CPU = i386

# Directories used by "make":
srcdir = .

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

# Programs used by "make":
CC = gcc
CFLAGS = -O
CPP = gcc -E
INCLUDES = -I. -I$(srcdir)
ASPFLAGS = -DASM_UNDERSCORE
AR = ar
AR_FLAGS = rc
MV = mv
LN = cp
RM = del

# 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.h : avcall.h.mingw32
	$(RM) avcall.h
	$(LN) avcall.h.mingw32 avcall.h

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

avcall-i386.o : avcall-i386.asm
	$(CC) -c -x assembler avcall-i386.asm

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

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

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

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.exe : tests.o $(OBJECTS)
	$(CC) $(CFLAGS) tests.o $(OBJECTS) -o tests.exe

check : all tests.exe
	tests.exe > tests.out
	uniq -u < tests.out > tests.output.$(HOST)
# You have to check by hand that tests.output.$(HOST) is empty.

mostlyclean : clean

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

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

maintainer-clean : distclean

force :

