# Released to the public domain.
#
# Anyone and anything may copy, edit, publish,
# use, compile, sell and distribute this work
# and all its parts in any form for any purpose,
# commercial and non-commercial, without any restrictions,
# without complying with any conditions
# and by any means.

# This is the standard for 32-bit

# Note that even if you intend to use gccwin_l64 in pdpclib
# later, you don't need to use here, because the interfaces
# shouldn't be using "long" (and if they were, it wouldn't
# work as it needs to match actual Windows)

VPATH=../pdpclib

CC=gccwin
CFLAGS=-O2 -ansi
COPTS=$(CFLAGS) -S -D__WIN32__ -I ../pdpclib -I . -DNOLIBALLOC
AS=pdas
#LD=pdld
LD=pdld --implib-compat
#LD=slink --oformat pe-i386

EXPORT_OBJS=dllcrt.obj kernel32.obj
OBJS=pdossupc.obj pos.obj string.obj supportf.obj


ifeq "$(tgtchs)" "ebcdic"
COPTS:=$(COPTS) -funsigned-char
endif

all: clean kernel32.dll

kernel32.dll: $(EXPORT_OBJS) $(OBJS)
  $(LD) -s -o kernel32.dll --shared --kill-at --out-implib kernel32.lib $(EXPORT_OBJS) $(OBJS)

dllcrt.obj: ../pdpclib/dllcrt.c
  $(CC) $(COPTS) -D__EXPORT__ -o $*.s $<
  $(AS) -o $@ --oformat coff $*.s
  rm -f $*.s

kernel32.obj: kernel32.c
  $(CC) $(COPTS) -D__EXPORT__ -o $*.s $<
  $(AS) -o $@ --oformat coff $*.s
  rm -f $*.s

.c.obj:
  $(CC) $(COPTS) -D__32BIT__ -o $*.s $<
  $(AS) -o $@ --oformat coff $*.s
  rm -f $*.s

.asm.obj:
  as86 -o $@ -f coff $<
#  sasm -o $@ -f coff $<

clean:
  rm -f *.obj
  rm -f kernel32.dll
  rm -f kernel32.lib
