# 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 makefile builds 32-bit pdos.exe (aka PDOS.SYS) on Windows.
# makefile.vsp in PDPCLIB must be used before using this makefile to produce the pdos.lib.

CC=cl
CFLAGS=-O2
COPTS=-c $(CFLAGS) -U__WIN32__ -DNOVM -DNEED_AOUT -DNEED_MZ -D__PDOS386__ -D__32BIT__ -I../bios -I../pdpclib -D__XXXMSC__ -Oi- -Zl -GS- -nologo
AS=ml
AR=lib
#LD=link
LD=pdld


TARGET=pdos.exe
TEMP_ARCHIVE=os.lib
ARCHIVE_OBJS=bos.obj fat.obj ../bios/exeload.obj physmem.obj vmm.obj process.obj int21.obj uart.obj \
             int80.obj log.obj helper.obj memmgr.obj patmat.obj supportf.obj protintp.obj protintf.obj pdosf.obj
OBJS=strt32.obj pdos.obj

all: clean $(TARGET)

$(TARGET): $(OBJS) $(TEMP_ARCHIVE)
#  $(AR) s $(TEMP_ARCHIVE)
#  $(LD) --oformat binary -Map map.txt --image-base 0x20000 -o $(TARGET) $(OBJS) $(TEMP_ARCHIVE) ../pdpclib/pdos.lib
# You will get a warning from link about Win 95/98 which can be ignored
  link -map -nologo -fixed -base:0x20000 -filealign:4096 -nodefaultlib -entry:start -out:$*.tmp $(OBJS) $(TEMP_ARCHIVE) ../pdpclib/pdos.lib
  pe2bin $*.tmp $@
  rm -f $(TEMP_ARCHIVE)

$(TEMP_ARCHIVE): $(ARCHIVE_OBJS)
  rm -f $(TEMP_ARCHIVE)
  $(AR) -nologo -out:$(TEMP_ARCHIVE) $(ARCHIVE_OBJS)

.c.obj:
  $(CC) $(COPTS) -Fo$@ $<

.asm.obj:
#  as86 -f coff -o $@ $<
  ml -c -nologo -coff $<

clean:
  rm -f *.obj
  rm -f $(TARGET)
  rm -f $(TEMP_ARCHIVE)
