# Generated automatically from Makefile.in by configure.
# --------------------------------------------------------------------------
# Makefile for Hugs
#
# The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
# Yale Haskell Group, and the OGI School of Science & Engineering at OHSU,
# 1994-2003, All rights reserved.  It is distributed as
# free software under the license in the file "License", which is
# included in the distribution.
# --------------------------------------------------------------------------

# Targets:
#
# <default>:   	  make hugs.exe and runhugs.exe
# install:	  make and install programs/libraries
# hugs.exe:	  make minimal working system
# runhugs.exe:	  make batch-mode version of Hugs
# hugsscript.dll: make DLL version of Hugs
# clean:       	  delete files not required in running system
# distclean:      delete files that can be regenerated using C compiler
# veryclean:      delete all machine generated files 
#                   (you need perl, bison/yacc, etc to rebuild these files)
# check:	  run regression tests
# TAGS:           build emacs TAGS table

# This rule goes first to make it the default choice
default		:: hugs.exe runhugs.exe ffihugs.exe hugsscript.dll

CC		= cl /nologo
VERSTR          = -DMONTH_YEAR="\"Nov 2003\""
CFLAGS          = -MD $(VERSTR)
# When debugging:
#CFLAGS		= -MDd -Zi $(VERSTR)
OPTFLAGS	= -O2

LD		= ld
LDFLAGS    	= 
# When debugging:
#LDFLAGS	= -Zi
DLL_FLAGS	= /LD
PIC_FLAGS	= 
LIBS		=  kernel32.lib advapi32.lib

YACC		= bison
RM		= -del
CP		= xcopy /Y
EXE		= .exe
OBJ		= .obj

FPTOOLS		= ../../fptools

BUILD_DIR	= ..\\hugsdir

# a file created by make libraries
LIBRARIES	= $(BUILD_DIR)/libraries/Prelude.hs

# a file created by make include
INCLUDES	= $(BUILD_DIR)/include/HsFFI.h

.SUFFIXES	:
.SUFFIXES	: .c .h .obj
HFILES		= HsFFI.h builtin.h command.h config.h connect.h errors.h \
		  evaluator.h goal.h machdep.h module.h observe.h options.h \
		  opts.h output.h prelude.h script.h server.h storage.h \
		  strutil.h subst.h
CFILES		= hugs.c runhugs.c server.c edit.c observe.c \
		  builtin.c compiler.c errors.c evaluator.c \
		  ffi.c goal.c input.c machdep.c machine.c \
		  module.c opts.c output.c plugin.c script.c \
		  static.c storage.c strutil.c subst.c \
		  type.c version.c
INCFILES	= array.c bignums.c dirprim.c interns.c iomonad.c \
		  preds.c printer.c scc.c timeprim.c timer.c
YFILES		= parser.y
SOURCES		= $(HFILES) $(CFILES) $(INCFILES) $(YFILES) 
OBJECTS		= builtin.obj compiler.obj errors.obj evaluator.obj \
		  ffi.obj goal.obj input.obj machdep.obj machine.obj \
		  module.obj opts.obj output.obj plugin.obj script.obj \
		  static.obj storage.obj strutil.obj subst.obj \
		  type.obj version.obj
IOBJECTS	= hugs.obj edit.obj observe.obj hugs.res $(OBJECTS)
PRELUDE		= config.h options.h prelude.h script.h

HEADERS		= HsFFI.h config.h unix\\MachDeps.h unix\\template-hsc.h

TOOLSDIR        = ..\\tools
TOOLS		= ..\\tools\\Package.hs ..\\tools\\ParsePkgConf.hs \
		  ..\\tools\\get_pkg_field

################################################################
# Hugs interpreter and standalone evaluator
################################################################

hugs.exe	: $(IOBJECTS)
		  $(CC) $(LDFLAGS) $(IOBJECTS)  $(LIBS) -o hugs.exe 
		  

SERVER_OBJECTS	= server.obj runhugs.res $(OBJECTS) 
runhugs.exe	: runhugs.obj $(SERVER_OBJECTS)
		  $(CC) $(LDFLAGS) runhugs.obj $(SERVER_OBJECTS) $(LIBS) -o runhugs.exe

ffihugs.exe	: ffihugs.obj $(SERVER_OBJECTS)
		  $(CC) $(LDFLAGS) ffihugs.obj $(SERVER_OBJECTS) $(LIBS) -o ffihugs.exe

ffihugs.obj	: runhugs.obj
		  $(CC) -c $(CFLAGS) $(OPTFLAGS) -DFFI_COMPILER runhugs.c /Foffihugs.obj

hugsscript.obj  : hugsscript.c
hugsscript.dll  : $(SERVER_OBJECTS) hugsscript.obj
		  $(CC) $(DLL_FLAGS) $(LDFLAGS) $(SERVER_OBJECTS) hugsscript.obj $(LIBS) -o hugsscript.dll

################################################################
# Libraries, converted from raw sources out of the fptools tree
################################################################

CONVERTERS	= unix/convert_libraries unix/hugs-package

libraries	:: $(LIBRARIES) 

$(LIBRARIES)	: runhugs.exe ffihugs.exe ../libraries/Hugs/*.* $(CONVERTERS) $(TOOLS) $(INCLUDES)
		  -mkdir $(BUILD_DIR)\\tools
		  $(CP) $(TOOLSDIR)\*.* $(BUILD_DIR)\\tools
		  -mkdir $(BUILD_DIR)\\libraries
		  -mkdir $(BUILD_DIR)\\libraries/Hugs
		  $(CP) ..\libraries\Hugs\*.* $(BUILD_DIR)\\libraries\\Hugs
		  cd unix && sh convert_libraries $(FPTOOLS) ../../hugsdir

$(INCLUDES)	: $(HEADERS)
		  -mkdir $(BUILD_DIR)\\include
		  $(CP) HsFFI.h $(BUILD_DIR)\\include
		  $(CP) config.h $(BUILD_DIR)\\include
		  $(CP) unix\\MachDeps.h $(BUILD_DIR)\\include
		  $(CP) unix\\template-hsc.h $(BUILD_DIR)\\include

################################################################
# Library modules that use the Foreign Function Interface
################################################################

FFI_LIBRARIES	= $(BUILD_DIR)/libraries/Hugs/Storable.dll

ffi_libraries	: $(FFI_LIBRARIES)

BUILD_FFI = env HUGSDIR='$(BUILD_DIR)' HUGSFLAGS='' ./ffihugs +G

#
# Create all the FFI extension DLLs.
#
FFIHUGS=ffihugs.exe
FFIHUGS_OPTS=+G -98 -P../hugsdir/libraries +L-I../hugsdir/include

.PHONY: ffi-dlls

ffi-dlls: $(FFIHUGS)
	$(FFIHUGS) $(FFIHUGS_OPTS) +L../libraries/Hugs/Storable_aux.c Hugs.Storable
	$(FFIHUGS) $(FFIHUGS_OPTS) Foreign.Marshal.Alloc
	$(FFIHUGS) $(FFIHUGS_OPTS) Foreign.Marshal.Utils
	$(FFIHUGS) $(FFIHUGS_OPTS) +L../hugsdir/libraries/Foreign/C/Error.c Foreign.C.Error
#	$(FFIHUGS) $(FFIHUGS_OPTS) +L../libraries/Network/initWinSock.c +L../libraries/Network/winSockErr.c +Lwsock32.lib Network.Socket
#	$(FFIHUGS) $(FFIHUGS_OPTS) +Lwsock32.lib Network.BSD

################################################################
# Clean, distclean, veryclean, TAGS
################################################################

clean		::
		  $(RM) hugs.exe
		  $(RM) runhugs.exe
		  $(RM) ffihugs.exe
		  $(RM) *.o
		  $(RM) *.O
		  $(RM) *.obj
		  $(RM) *.OBJ
		  $(RM) *.LIB
		  $(RM) *.DEF
		  $(RM) *.RES
		  $(RM) *.EXP
		  $(RM) *.ILK
		  $(RM) *.PDB
		  $(RM) *.TD2
		  $(RM) *.MAP
		  $(RM) *.CSM
		  $(RM) *.TR2
		  $(RM) *.DSW
		  $(RM) *.RES
		  $(RM) *.aux
		  $(RM) *.hp
distclean	:: clean
distclean	::
		  $(RM) hugs.exe
		  $(RM) runhugs.exe
		  $(RM) *.pdf
		  $(RM) TAGS
		  $(RM) *~
veryclean	:: distclean
veryclean	::
		  $(RM) config.h
		  $(RM) options.h
TAGS		::
		  etags *.[ych]

################################################################
# C and Yacc rules
################################################################

.c.obj	:
		  $(CC) -c $(CFLAGS) $(OPTFLAGS) $<

# These are compiled with less optimisation to avoid optimisation bugs in
# certain compilers.  This may be overly conservative on some compilers.
compiler.obj	: compiler.c
		  $(CC) -c $(CFLAGS) compiler.c
static.obj	: static.c
		  $(CC) -c $(CFLAGS) static.c

parser.c	: parser.y
		  -$(YACC) parser.y
		  mv parser.tab.c parser.c

# veryclean	::
# 		  $(RM) parser.c

hugs.res	: msc\hugs.rc ..\icons\hugsicon.ico
		rc /imsc /i..\icons /r /fo hugs.res msc\hugs.rc 

runhugs.res	: msc\runhugs.rc ..\icons\hsxicon.ico
		rc /imsc /i..\icons /r /fo runhugs.res msc\runhugs.rc 

################################################################
# Object dependencies (Don't change or delete this line)
################################################################

hugs$(OBJ): hugs.c prelude.h config.h options.h storage.h HsFFI.h command.h \
  connect.h errors.h script.h opts.h strutil.h evaluator.h machdep.h \
  output.h module.h
runhugs$(OBJ): runhugs.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h machdep.h observe.h builtin.h evaluator.h errors.h server.h \
  HugsAPI.h
server$(OBJ): server.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h script.h machdep.h evaluator.h opts.h strutil.h errors.h \
  server.h HugsAPI.h
edit$(OBJ): edit.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  errors.h opts.h strutil.h machdep.h
observe$(OBJ): observe.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h command.h errors.h machdep.h builtin.h output.h observe.h
builtin$(OBJ): builtin.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h machdep.h builtin.h bignums.c printer.c iomonad.c \
  timeprim.c dirprim.c array.c
compiler$(OBJ): compiler.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h goal.h output.h opts.h
errors$(OBJ): errors.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h output.h opts.h goal.h evaluator.h
evaluator$(OBJ): evaluator.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h script.h output.h strutil.h opts.h machdep.h \
  evaluator.h
ffi$(OBJ): ffi.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  errors.h output.h strutil.h
goal$(OBJ): goal.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  errors.h machdep.h opts.h goal.h
input$(OBJ): input.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  command.h errors.h module.h script.h opts.h goal.h machdep.h parser.c
machdep$(OBJ): machdep.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h opts.h strutil.h machdep.h evaluator.h
machine$(OBJ): machine.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h opts.h
module$(OBJ): module.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h module.h output.h
opts$(OBJ): opts.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  errors.h machdep.h strutil.h opts.h
output$(OBJ): output.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h output.h
plugin$(OBJ): plugin.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h
script$(OBJ): script.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h machdep.h opts.h strutil.h script.h
static$(OBJ): static.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h machdep.h errors.h output.h subst.h module.h opts.h goal.h \
  scc.c
storage$(OBJ): storage.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h opts.h errors.h machdep.h evaluator.h strutil.h output.h
strutil$(OBJ): strutil.c prelude.h config.h options.h storage.h HsFFI.h \
  connect.h errors.h strutil.h
subst$(OBJ): subst.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  errors.h output.h opts.h subst.h
type$(OBJ): type.c prelude.h config.h options.h storage.h HsFFI.h connect.h \
  errors.h output.h subst.h goal.h opts.h preds.c scc.c
version$(OBJ): version.c prelude.h config.h options.h

################################################################
# End of object dependencies (Don't change or delete this line)
################################################################

################################################################
# Regression tests (none supplied)
################################################################

check		:


################################################################
# End of Makefile
################################################################
