# -*-Makefile-*- for vacall

#### 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 = vacall.o misc.o structcpy.o

all : $(OBJECTS) libvacall.a vacall.h $(srcdir)/vacall.3 $(srcdir)/vacall.html

vacall.h : vacall.h.mingw32
	$(RM) vacall.h
	$(LN) vacall.h.mingw32 vacall.h

config.h : config.h.mingw32
	$(RM) config.h
	$(LN) config.h.mingw32 config.h

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

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

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

misc.o : $(srcdir)/misc.c vacall.h config.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/misc.c

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

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

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

minitests.s : $(srcdir)/minitests.c vacall.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)

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

tests.s : $(srcdir)/tests.c vacall.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)

mostlyclean : clean

clean : force
	$(RM) *.o *.a core
	$(RM) vacall-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 vacall.h config.h tests.output.*

maintainer-clean : distclean

force :

