# Makefile for callback

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

HOST = i386-pc-win32-msvc
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 = cl
CFLAGS = -O1
CPP = cl -E
INCLUDES = -I. -I$(srcdir)
AR = lib
AR_FLAGS = /out:
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_r/vacall.obj vacall_r/misc.obj vacall_r/structcpy.obj trampoline_r/trampoline.obj

all : $(OBJECTS) callback.h vacall_r.h trampoline_r.h callback.lib $(srcdir)/callback.3 $(srcdir)/callback.html

callback.h : $(srcdir)/callback.h.in
	-$(LN) $(srcdir)/callback.h.in callback.h

vacall_r.h : vacall_r/vacall_r.h
	$(LN) vacall_r/vacall_r.h vacall_r.h

vacall_r/vacall_r.h : vacall_r/vacall_r.h.msvc
	$(RM) vacall_r/vacall_r.h
	$(LN) vacall_r/vacall_r.h.msvc vacall_r/vacall_r.h

vacall_r/config.h : vacall_r/config.h.msvc
	$(RM) vacall_r/config.h
	$(LN) vacall_r/config.h.msvc vacall_r/config.h

vacall_r/vacall.obj : vacall_r/vacall-$(CPU).obj
	$(RM) vacall_r/vacall.obj
	$(LN) vacall_r/vacall-$(CPU).obj vacall_r/vacall.obj

vacall_r/vacall-i386.obj : $(srcdir)/vacall_r/vacall-i386-msvc.c vacall_r/vacall_r.h
	$(RM) vacall_r/vacall-i386.obj
	$(CC) -c $(srcdir)/vacall_r/vacall-i386-msvc.c /Fovacall_r/vacall-i386.obj

vacall_r/misc.obj : $(srcdir)/vacall_r/misc.c vacall_r/vacall_r.h vacall_r/config.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/vacall_r/misc.c /Fovacall_r/misc.obj

vacall_r/structcpy.obj : $(srcdir)/vacall_r/structcpy.c
	$(CC) $(CFLAGS) -c $(srcdir)/vacall_r/structcpy.c /Fovacall_r/structcpy.obj

trampoline_r.h : trampoline_r/trampoline_r.h
	$(LN) trampoline_r/trampoline_r.h trampoline_r.h

trampoline_r/trampoline_r.h : $(srcdir)/trampoline_r/trampoline_r.h.in
	-$(LN) $(srcdir)/trampoline_r/trampoline_r.h.in trampoline_r/trampoline_r.h

trampoline_r/config.h : $(srcdir)/trampoline_r/config.h.msvc
	-$(LN) $(srcdir)/trampoline_r/config.h.msvc trampoline_r/config.h

trampoline_r/trampoline.obj : $(srcdir)/trampoline_r/trampoline.c trampoline_r/trampoline_r.h trampoline_r/config.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/trampoline_r/trampoline.c /Fotrampoline_r/trampoline.obj

callback.lib : $(OBJECTS)
	$(RM) callback.lib
	$(AR) $(AR_FLAGS)callback.lib $(OBJECTS)

test1.obj : $(srcdir)/trampoline_r/test1.c trampoline_r/trampoline_r.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/trampoline_r/test1.c

test1.exe : test1.obj callback.lib
	$(RM) test1.ilk
	$(CC) $(CFLAGS) test1.obj callback.lib /Fetest1.exe

test2.obj : $(srcdir)/trampoline_r/test2.c trampoline_r/trampoline_r.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/trampoline_r/test2.c

test2.exe : test2.obj callback.lib
	$(RM) test2.ilk
	$(CC) $(CFLAGS) test2.obj callback.lib /Fetest2.exe

tests.obj : $(srcdir)/tests.c callback.h vacall_r.h trampoline_r.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/tests.c

tests.s : $(srcdir)/tests.c callback.h vacall_r.h trampoline_r.h
	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/tests.c /FAs /Fatests.s

tests.exe : tests.obj callback.lib
	$(CC) $(CFLAGS) tests.obj callback.lib /Fetests.exe

check1 : all test1.exe
	test1.exe

check2 : all test1.exe test2.exe
	test1.exe
	test2.exe

check : all test1.exe test2.exe tests.exe
	test1.exe
	test2.exe
	tests.exe > tests.out
	uniq -u < tests.out > tests.output.$(HOST)

mostlyclean : clean

clean : force
	$(RM) $(OBJECTS) vacall_r/vacall-i386.obj callback.lib core
	$(RM) test1.obj test1.exe test2.obj test2.exe
	$(RM) tests.obj tests.s tests.exe tests.out

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

maintainer-clean : distclean

force :

