#
# kqemu for Windows NT Makefile
# (c) Filip Navara
#
OBJECTS = kqemu-win32.o kqemu-mod-i386-win32.o
CROSS_PREFIX=i386-mingw32-

TARGET = kqemu.sys

CFLAGS = -O2 -I.

all: $(TARGET)

clean:
	make -C common clean
	rm -f kqemu-win32.o $(TARGET)

%.o: %.c
	$(CROSS_PREFIX)gcc $(CFLAGS) -c $< -o $@

%.coff: %.rc
	$(CROSS_PREFIX)windres -i $< -o $@

%.a: %.def
	$(CROSS_PREFIX)dlltool -d $< -l $@ --kill-at

$(TARGET): kqemu-win32.o
	make -C common all
	$(CROSS_PREFIX)gcc -Wl,--base-file,base.tmp -Wl,--entry,_DriverEntry@8 \
	    -nostartfiles -nostdlib -o junk.tmp $(OBJECTS) -lntoskrnl -lhal
	rm junk.tmp
	$(CROSS_PREFIX)dlltool --as=as --dllname $(TARGET) --base-file base.tmp \
	        --output-exp temp.exp 
	rm base.tmp
	$(CROSS_PREFIX)gcc -Wl,--subsystem,native -Wl,--image-base,0x10000 \
	    -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 \
	    -Wl,--entry,_DriverEntry@8  -Wl,--stack,0x40000 -Wl,temp.exp \
	    -mdll -nostartfiles -nostdlib -o $(TARGET) \
	    $(OBJECTS) -lntoskrnl -lhal
	rm temp.exp
