#
# Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P.
#
# The really trivial win32/VC++ Makefile.  Note that atomic_ops.c defines
# only AO_pause (used by atomic_ops_stack).
# And we rely on a pre-built test_atomic_include.h and generalize-small.h,
# since we can't rely on sed.  But we don't keep test_atomic_include.h in
# the development repository any longer, so if you want to run all tests
# for the sources obtained from the repository then
# type "./autogen.sh && ./configure && make -j && make clean" in Cygwin first.
# Otherwise type "nmake -f Makefile.msft check-noautogen" to run only the
# tests not requiring the source auto-generation.
# Win32 clients only need to include the header files.
# To install, copy atomic_ops.h and the atomic_ops/... tree to your favorite
# include directory.

#!include <ntwin32.mak>

CFLAGS_EXTRA=
CFLAGS=-O2 -W3 $(CFLAGS_EXTRA)

LIB_OBJS=atomic_ops.obj atomic_ops_malloc.obj atomic_ops_stack.obj

all: libatomic_ops_gpl.lib

atomic_ops.obj:
	cl $(CFLAGS) -c atomic_ops.c

atomic_ops_stack.obj:
	cl $(CFLAGS) -c atomic_ops_stack.c

atomic_ops_malloc.obj:
	cl $(CFLAGS) -c atomic_ops_malloc.c

libatomic_ops_gpl.lib: $(LIB_OBJS)
	lib /out:libatomic_ops_gpl.lib $(LIB_OBJS)

test_atomic: ..\tests\test_atomic.c ..\tests\test_atomic_include.h
	cl $(CFLAGS) -I. ..\tests\test_atomic.c /Fo.\test_atomic

test_atomic_generalized: ..\tests\test_atomic.c ..\tests\test_atomic_include.h
	cl $(CFLAGS) -DAO_PREFER_GENERALIZED -I. ..\tests\test_atomic.c \
	    /Fo.\test_atomic_generalized

test_malloc: ..\tests\test_malloc.c libatomic_ops_gpl.lib
	cl $(CFLAGS) -I. ..\tests\test_malloc.c /Fo.\test_malloc \
	    libatomic_ops_gpl.lib

test_stack: ..\tests\test_stack.c libatomic_ops_gpl.lib
	cl $(CFLAGS) -I. ..\tests\test_stack.c /Fo.\test_stack \
	    libatomic_ops_gpl.lib

check: test_atomic test_atomic_generalized check-noautogen
	@echo "The following will print some 'Missing ...' messages"
	test_atomic
	test_atomic_generalized

check-noautogen: test_malloc test_stack
	test_malloc
	test_stack

clean:
	del *.exe *.obj libatomic_ops_gpl.lib
