# $(dllname)            Library name
# $(exename)            Name (from Library: or Executable:)
# $(mangled-dllname)    Mangled library name
# $(mangled-exename)    Mangled library name
# $(full-dll-name)      Name (from Library: or Executable:) w/suffix ".dll"
# $(full-exe-name)      Name (from Library: or Executable:) w/suffix ".exe"
# $(full-lib-name)      Name (from Library: or Executable:) w/suffix ".lib"
# $(script)             Pathname to gnu linker script
# $(personal-lib)       $OPEN_DYLAN_USER_INSTALL/lib
# $(system-lib)         $OPEN_DYLAN_RELEASE_INSTALL/lib
# $(dylan-imp7)		dylanimp7.o
# $(libraries)          Set below
# $(dllobjs)            Object files:
#                         import fixups (except when linking Dylan itself)
#                         LID files: keyword
#                         LID c-object-files: keyword
#                         LID c-source-files: keyword
# $(dylan-support)      Path to dylan-support.obj
# $(dlllibs)            -lxxx for each library in MKF used-libraries: keyword
# $(c-libs)             Contents of LID all-c-libraries: and rtlibs: keywords
#                         (all-c-libraries: is variable-expanded)
# $(base)               From HDP base-address: keyword
# $(entry-point)	Mangled library name, with Exe0 appended
# $(exports)		Library name w/extension ".exp", or list of .exp files
#			  for libraries being unified
# $(optimization)	"/OPT:REF" for Dylan library, empty otherwise
# $(linkopts)           Variable-expanded from LID linker-options: keyword
# $(image-version)      major.minor, from LID major-version: and minor-version:
# $(libcmt)             C library, multithreaded: set below
# $(gnulibs)
#
linkdll
ld-new --base-file $(dllname).base -T $(script) --dll -o $(full-dll-name) --traditional-format $(dylan-imp7) $(dllname)imp7.o $(dlllibs) $(dllobjs) $(dylan-support) -L$(gnulibs) $(c-libs) -lkernel32 $(linkopts) --image-base $(base) -e _$(mangled-dllname)Dll@12
make-reloc $(dllname).base $(dllname).reloc
as -L -o $(dllname).exp $(dllname)exp.s $(dllname).reloc
ld-new --base-file $(dllname).base $(dllname).exp -T $(script) --dll -o $(full-dll-name) --traditional-format $(dylan-imp7) $(dllname)imp7.o $(dlllibs) $(dllobjs) $(dylan-support) -L$(gnulibs) $(c-libs) -lkernel32 $(linkopts) --image-base $(base) -e _$(mangled-dllname)Dll@12
make-reloc $(dllname).base $(dllname).reloc
as -L -o $(dllname).exp $(dllname)exp.s $(dllname).reloc
ld-new $(dllname).exp -T $(script) --dll -o $(full-dll-name) --traditional-format $(dylan-imp7) $(dllname)imp7.o $(dlllibs) $(dllobjs) $(dylan-support) -L$(gnulibs) $(c-libs) -lkernel32 $(linkopts) --image-base $(base) -e _$(mangled-dllname)Dll@12
!dllfix $(full-dll-name)

linkexe
ld-new -T $(script) -o $(full-exe-name) --traditional-format $(dylan-imp7) $(exename)imp7.o $(exelibs) $(exeobjs) $(dylan-support) --subsystem $(subsystem) -L$(gnulibs) $(c-libs) -lkernel32 $(linkopts) -e _$(entry-point)

assemble
as -L -o $(object) $(source)

ccompile
cl -c -W3 -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -D_X86_=1 -DWINVER=0x0400 -DWIN32  -D_WIN32 -D_MT -D_DLL -MD -Z7 -Od /c 

rccompile
windres --use-temp-file -DWIN32 -D_WIN32 -DWINVER=0x0400 -O res $(resource).rc $(resource).res
windres -O coff $(resource).res $(resource)-resource.obj

libcmt
-lcygwin

guilflags
--subsystem windows

guilibsmt
-lwsock32 -ladvapi32 -luser32 -lgdi32 -lcomdlg32 -lwinspool

olelibsmt
-lole32 -luuid -loleaut32 $(guilibsmt)

comctl32
-lcomctl32

ole32
-lole32

make-exports
# Create .def file from a .lib
#  extract text
!nm $(source) | find " T "  > $(destination).tmp
# extract data
!nm $(source) | find " D _" >> $(destination).tmp
!nm $(source) | find " B "  >> $(destination).tmp
# Delete first two columns
cmd /c "for /f "tokens=3 delims= " %i in ($(destination).tmp) do @echo %i>> $(destination)"
cmd /c "del $(destination).tmp"

make-imports
# Create a .import file from a .obj
# header
cmd /c echo RUNTIME> $(destination)
# undefineds
!nm --undefined-only $(source) | find /v "@" >> $(destination)

make-archive
ar -q $(archive) $(objects)

