# -*-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 = $(prefix)/man

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

# 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-macro.S
	$(CPP) $(ASPFLAGS) $(srcdir)/avcall-i386-macro.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)

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

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

minitests.exe : minitests.o $(OBJECTS)
	$(CC) $(CFLAGS) minitests.o $(OBJECTS) -o minitests.exe

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

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

extracheck : all tests.exe
	tests.exe > tests.out
	LC_ALL=C 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) minitests.o minitests.s minitests.exe minitests.out
	$(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 :

