# Makefile for callback

#### 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)
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 trampoline.o

all : all-subdirs callback.h vacall_r.h trampoline_r.h libcallback.a $(srcdir)/callback.3 $(srcdir)/callback.html

all-subdirs : force
	$(MAKE) -C vacall_r -f Makefile.mingw32 all
	$(MAKE) -C trampoline_r -f Makefile.mingw32 all

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

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

libcallback.a : vacall_r/libvacall.a trampoline_r/libtrampoline.a
	$(RM) libcallback.a
	$(AR) x vacall_r/libvacall.a
	$(AR) x trampoline_r/libtrampoline.a
	$(AR) $(AR_FLAGS) libcallback.a $(OBJECTS)
	$(RM) $(OBJECTS)

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

tests.exe : tests.o libcallback.a
	$(CC) $(CFLAGS) tests.o libcallback.a -o tests.exe

check-subdirs : force
	$(MAKE) -C vacall_r -f Makefile.mingw32 check
	$(MAKE) -C trampoline_r -f Makefile.mingw32 check

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

mostlyclean : force
	$(MAKE) -C vacall_r -f Makefile.mingw32 mostlyclean
	$(MAKE) -C trampoline_r -f Makefile.mingw32 mostlyclean

clean-subdirs : force
	$(MAKE) -C vacall_r -f Makefile.mingw32 clean
	$(MAKE) -C trampoline_r -f Makefile.mingw32 clean

clean : clean-subdirs
	$(RM) $(OBJECTS) *.a core
	$(RM) vacall_r.h trampoline_r.h libcallback.a
	$(RM) tests.o tests.s tests.exe tests.out

distclean-subdirs : clean
	$(MAKE) -C vacall_r -f Makefile.mingw32 distclean
	$(MAKE) -C trampoline_r -f Makefile.mingw32 distclean

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

maintainer-clean : clean distclean-subdirs
	$(RM) config.status config.log config.cache Makefile

force :

