Makefile=Makefile.win

CL_FLAGS=-Wall -O2 -nologo -DCRCUTIL_USE_MM_CRC32=0
ICL_FLAGS=-Wall -O3 -Qdiag-disable:181 -Qdiag-disable:185 -Qdiag-disable:442 -Qdiag-disable:vec -DCRCUTIL_USE_MM_CRC32=0
INCLUDES=-Icode

all:
  @echo Please run "nmake target" where "target" is one of:
  @echo cl64  - 64-bit Microsoft compiler
  @echo cl32  - 32-bit Microsoft compiler
  @echo icl64 - 64-bit Intel compiler
  @echo icl32 - 32-bit Intel compiler


cl64:
  @call "%VCINSTALLDIR%\bin\amd64\vcvarsamd64.bat" && nmake -nologo -f $(Makefile) CC_FLAGS="$(CL_FLAGS) -Icode -Itests" CC=cl.exe configured

cl32:
  @call "%VCINSTALLDIR%\bin\vcvars32.bat" && nmake -nologo -f $(Makefile) CC_FLAGS="$(CL_FLAGS) -Icode -Itests" CC=cl.exe configured

icl64:
  @call "%ICPP_COMPILER11%bin\iclvars.bat" intel64 && nmake -nologo -f $(Makefile) CC_FLAGS="$(ICL_FLAGS) -Icode -Itests" CC=icl.exe configured

icl32:
  @call "%ICPP_COMPILER11%bin\iclvars.bat" ia32 && nmake -nologo -f $(Makefile) CC_FLAGS="$(ICL_FLAGS) -Icode -Itests" CC=icl.exe configured


clean:
  del /q *.obj *.asm *.exe *.pdb *.suo


TARGETS=unittest.exe example.exe

COMMON_CODE=\
  code/crc32c_sse4.cc \
  code/multiword_64_64_cl_i386_mmx.cc

COMMON_HEADERS=\
  code/base_types.h \
  code/crc32c_sse4.h \
  code/crc32c_sse4_intrin.h \
  code/crc_casts.h \
  code/generic_crc.h \
  code/gf_util.h \
  code/platform.h \
  code/protected_crc.h \
  code/rolling_crc.h \
  code/std_headers.h \
  code/uint128_sse2.h

UNITTEST_CODE=\
  tests/unittest.cc \
  tests/set_hi_pri.c \
  $(COMMON_CODE)

UNITTEST_HEADERS=\
  tests/aligned_alloc.h \
  tests/bob_jenkins_rng.h \
  tests/rdtsc.h \
  tests/unittest.h \
  tests/unittest_helper.h \
  $(COMMON_HEADERS)

EXAMPLE_CODE=\
  examples/usage.cc \
  examples/interface.cc \
  $(COMMON_CODE)

EXAMPLE_HEADERS=\
  examples/interface.h \
  $(COMMON_HEADERS)

configured: $(TARGETS)

unittest.exe: $(Makefile) $(UNITTEST_CODE) $(UNITTEST_HEADERS)
  $(CC) $(CC_FLAGS) $(UNITTEST_CODE)

example.exe: $(Makefile) $(EXAMPLE_CODE) $(EXAMPLE_HEADERS)
  $(CC) $(CC_FLAGS) -Iexamples $(EXAMPLE_CODE)
