# This builds 32-bit Windows ARM (PE/coff) executables
# with static linking using Microsoft's C compiler

# makek32.mar needs to be run in src first

# Note that if you generate assembler using -Fa
# you will need to comment out things like .drectve
# in order for armasm to be able to assemble it

#CC=gccprm
CC=cl

#COPTS=-S -O0 -msoft-float -fno-common -mapcs-32 \
#    -I../src -fno-leading-underscore \
#    -D__ARM__ -D__USEBIVA__ -I. -D__WIN32__ \
#    -D__STATIC__ -DNOUNDMAIN -D__GENSHELL__ \
#    -D__NOSPECBIVA__

COPTS=-c -I../src -D__ARM__ -I. -D__WIN32__ -D__STATIC__ \
    -DNOUNDMAIN -D__GENSHELL__ -D__MSC__ -nologo -GS- -Zl -O2 -Oi-

#AR=arprm
AR=lib
LD=pdld --no-insert-timestamp
#LD=link
AS=armasm

TARGET=pdptest.exe
OBJS=p32start.obj stdio.obj string.obj stdlib.obj start.obj time.obj errno.obj \
    assert.obj signal.obj locale.obj ctype.obj math.obj fpfuncsa.obj

$(TARGET): clean pdptest.obj $(OBJS) armsupb.obj
  rm -f pdpwin32.lib
#  $(AR) r pdpwin32.lib $(OBJS)
#  $(AR) s pdpwin32.lib
  $(AR) -nologo -out:pdpwin32.lib $(OBJS)
  $(LD) -s -nostdlib -o pdptest.exe p32start.obj pdptest.obj armsupb.obj pdpwin32.lib ../src/kernel32.lib
#  $(LD) -nologo -out:pdptest.exe -fixed:no p32start.obj pdptest.obj armsupb.obj pdpwin32.lib ../src/kernel32.lib

.c.obj:
#  $(CC) $(COPTS) -o $*.s $<
#  $(AS) -o $*.obj $*.s
#  rm -f $*.s
  $(CC) $(COPTS) $<

armsupb.obj: armsupb.asm
# we don't need an explicit -16
  armasm -nologo -o armsupb.obj armsupb.asm

.asm.obj:
  $(AS) -nologo -16 -o $@ $<

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