# Makefile for sigsegv

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

# Flags that can be set on the nmake command line:
#   MFLAGS={-ML|-MT|-MD} for defining the compilation model
#     MFLAGS=-ML (the default)  Single-threaded, statically linked - libc.lib
#     MFLAGS=-MT                Multi-threaded, statically linked  - libcmt.lib
#     MFLAGS=-MD                Multi-threaded, dynamically linked - msvcrt.lib
#   DEBUG=1   for compiling with debugging information
# Note that nmake command line flags are automatically passed to subdirectory
# Makefiles. Therefore we don't need to pass them explicitly to subdirectory
# Makefiles, but the subdirectory Makefiles need to have the same defaults.
# Building as a DLL not supported yet.
DLL=0
!if !defined(DEBUG)
DEBUG=0
!endif
!if !defined(MFLAGS)
!if !$(DLL)
MFLAGS=
!else
MFLAGS=-MD
!endif
!endif

!if $(DEBUG)
OPTIMFLAGS = -Od -Z7
!else
OPTIMFLAGS = -D_NDEBUG -O1
!endif

# 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

# Programs used by "make":
CC = cl
CFLAGS = $(MFLAGS) $(OPTIMFLAGS)
CPP = cl -E
INCLUDES = -I. -I$(srcdir)
AR = lib
AR_FLAGS = /out:
MV = ren
CP = copy
LN = copy
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 = handler.obj dispatcher.obj

all : sigsegv.lib

sigsegv.h :
	$(CP) $(srcdir)\sigsegv.h.in sigsegv.h

handler.obj : $(srcdir)/handler.c sigsegv.h
	$(CC) $(CFLAGS) -c $(srcdir)/handler.c

dispatcher.obj : $(srcdir)/dispatcher.c sigsegv.h
	$(CC) $(CFLAGS) -c $(srcdir)/dispatcher.c

!if !$(DLL)
sigsegv.lib : $(OBJECTS)
	$(RM) sigsegv.lib
	$(AR) $(AR_FLAGS)sigsegv.lib $(OBJECTS)
!else
# sigsegv.dll and sigsegv.lib are created together.
sigsegv.lib : $(OBJECTS)
	$(CC) $(MFLAGS) -LD $(OBJECTS) -Fesigsegv.dll
!endif

test1.exe : $(srcdir)/test1.c sigsegv.h sigsegv.lib
	$(CC) $(CFLAGS) $(srcdir)/test1.c sigsegv.lib /Fetest1

test2.exe : $(srcdir)/test2.c sigsegv.h sigsegv.lib
	$(CC) $(CFLAGS) $(srcdir)/test2.c sigsegv.lib /Fetest2

test3.exe : $(srcdir)/test3.c sigsegv.h sigsegv.lib
	$(CC) $(CFLAGS) $(srcdir)/test3.c sigsegv.lib /Fetest3

check : all test1.exe test2.exe test3.exe
	test1.exe
	test2.exe
	test3.exe

mostlyclean : clean

clean : force
	$(RM) sigsegv.h *.obj *.lib *.exp *.dll core
	$(RM) test1.exe test2.exe test3.exe

distclean : clean
	$(RM) config.status config.log config.cache Makefile config.h

maintainer-clean : distclean

force :

