# -----------------------------------------------------------------------------=
#
# (c) The GHC Team 1997-2000
#

TOP = ..
include $(TOP)/mk/boilerplate.mk

PACKAGE = win32
PACKAGE_DEPS = lang

HS_SRCS		  = $(wildcard *.hs)
HS_OBJS           = $(patsubst %.hs, %.o, $(HS_SRCS))

# _stub.o files are a side-effect from compiling .hs files that
# contain 'foreign export' declarations.
EXTRA_C_OBJS      = Win32Dialogue_stub.o Win32Window_stub.o

# Note: due to the presence of the HSwin32.o rule below,
# it is crucial that we define LIBOBJS here and don't
# rely on the default definition that target.mk provides
# for LIBOBJS. It is identical to our defn here, _but_
# by defining it here we can use the variable as a pre-req
# for a rule. This is all a bit too subtle..
#
LIBOBJS           = $(HS_OBJS)
STUBOBJS         += $(filter-out $(EXTRA_C_OBJS), $(patsubst %.c, %.o, $(C_SRCS))) $(EXTRA_C_OBJS)

# GCDIR		  = ../../green-card
# GCLIBDIR          = $(GCDIR)/lib/ghc

HI_FILES          = $(addsuffix .$(way_)hi,  $(basename $(HS_SRCS)))

SRC_CC_OPTS      += -DTARGET_GHC
SRC_HC_OPTS      += -cpp -fvia-C -optc-DTARGET_GHC -fglasgow-exts 

# SRC_GC_OPTS  	 += --target ffi --include-dir $(GCLIBDIR)
# SRC_BLD_DLL_OPTS += -luser32 -lgdi32 -ladvapi32 Win32Dialogue_stub.o Win32Window_stub.o

# ifeq "$(DEBUG)" "YES"
# SRC_GC_OPTS      += --stub-debug
# SRC_CC_OPTS      += -DDEBUG -O
# SRC_HC_OPTS      += -optc-DWIN32_LIB_DEBUG
# endif

# Split into two -- see LIBOBJS comment above.
HSwin32.o :: $(LIBOBJS) $(STUBOBJS)
	ld -r -x -o HSwin321.o $(filter     Win32M% Win32N% Win32R% Win32W%, $^)
	ld -r -x -o HSwin322.o $(filter-out Win32M% Win32N% Win32R% Win32W%, $^)

Win32Dialogue_stub.o : Win32Dialogue.o
	@:
Win32Window_stub.o : Win32Window.o
	@:

# Hard-wired dependencies
errors.o  : errors.c
dumpBMP.o : dumpBMP.c
WndProc.o : WndProc.c WndProc.h

include $(TOP)/mk/target.mk
