!IF [where /Q Makefile.auto.win]
# The file doesn't exist, so don't include it.
!ELSE
!INCLUDE Makefile.auto.win
!ENDIF

NMAKE = nmake /$(MAKEFLAGS)
CFLAGS = /O2 /EHsc

NIF_SRC=\
  nif\xnif_slice.c\
  nif\checksum_xor.c\
  nif\crc_8.c\
  nif\crc_16.c\
  nif\crc_16_ccitt.c\
  nif\crc_16_dnp.c\
  nif\crc_16_kermit.c\
  nif\crc_16_modbus.c\
  nif\crc_16_sick.c\
  nif\crc_32.c\
  nif\crc_nif.c\
  nif\crc_algorithm.c\
  nif\crc_model.c\
  nif\crc_resource.c

all: app

Makefile.auto.win:
	echo # Auto-generated as part of Makefile.win, do not modify. > $@
	erl -eval "io:format(\"~s~n\", [lists:concat([\"ERTS_INCLUDE_PATH=\", code:root_dir(), \"/erts-\", erlang:system_info(version), \"/include\"])])" -s init stop -noshell >> $@

!IFDEF ERTS_INCLUDE_PATH
app:
  $(CC) $(CFLAGS) /I"$(ERTS_INCLUDE_PATH)" /LD /MD /Fe"..\priv\crc_nif.dll" $(NIF_SRC)
!ELSE
app: Makefile.auto.win
	$(NMAKE) /F Makefile.win app
!ENDIF

clean:
  echo "Not implemented"

distclean:
  echo "Not implemented"
