#
# 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.  To run all the tests, type:
# nmake -f Makefile.msft check
# To install, copy atomic_ops.h and the atomic_ops/... tree to your favorite
# include directory.

#!include <ntwin32.mak>

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

LIB_OBJS=atomic_ops.obj
LIB_GPL_OBJS=atomic_ops_malloc.obj atomic_ops_stack.obj

all-disable-gpl: atomic_ops.lib

all: all-disable-gpl atomic_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) /wd4127 -c atomic_ops_malloc.c

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

atomic_ops_gpl.lib: $(LIB_GPL_OBJS)
	lib /out:atomic_ops_gpl.lib $(LIB_GPL_OBJS)

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

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

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

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

check-deps: check-noautogen-deps ..\tests\test_atomic \
        ..\tests\test_atomic_generalized

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

check-noautogen-deps: ..\tests\test_malloc ..\tests\test_stack

check-noautogen: check-noautogen-deps
	..\tests\test_malloc
	..\tests\test_stack

clean:
	del *.obj atomic_ops*.lib ..\tests\*.obj ..\tests\*.exe
