# mingw
# CC=gcc -mno-cygwin
# CFLAGS=-g3 -I . -DNO_RUNTIME_PSEUDO_RELOC_SUPPORT

# cygwin w/o runtime pseudo reloc support
CC=gcc
CFLAGS=-g3 -I . -DNO_RUNTIME_PSEUDO_RELOC_SUPPORT

# cygwin with runtime pseudo reloc support
# CC=gcc
# CFLAGS=-g3 -I . -DRUNTIME_PSEUDO_RELOC_SUPPORT

DLL_LDFLAGS=-Wl,--export-all-symbols -Wl,--out-implib=libcrtest.dll.a
EXE_LDFLAGS=-Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc
# DEBUG_LDFLAGS=-Wl,--enable-extra-pe-debug -Wl,--verbose

all: crtest.exe crtest.dll

crtest_dll.o: crtest_dll.c
	$(CC) $(CFLAGS) -c $<

crtest.o: crtest.c
	$(CC) $(CFLAGS) -c $<

crtest.dll libcrtest.dll.a: crtest_dll.o
	$(CC) -shared -o crtest.dll $(DLL_LDFLAGS) $<

crtest.exe: crtest.o libcrtest.dll.a
	$(CC) $(EXE_LDFLAGS) $(DEBUG_LDFLAGS) -o crtest.exe crtest.o -L. -lcrtest

.PHONY: clean

clean:
	rm -f *.o *.a crtest.exe crtest.dll
