# This is the makefile for Win32 to build pdpclib using
# the mingw64 compiler and static linking. Use pdmake etc

CC=gcc -m64
#CC=x86_64-w64-mingw32-gcc
CFLAGS=-O2
COPTS=-S $(CFLAGS) -fno-common -fno-builtin -ansi -D__WIN32__ -D__STATIC__ -I . -I../src -D__64BIT__ -DNOUNDMAIN

AR=ar
#AR=x86_64-w64-mingw32-ar
AS=as --64
#AS=x86_64-w64-mingw32-as
LD=ld
#LD=x86_64-w64-mingw32-ld

all: pdptest.exe

pdptest.exe: p32start.o pdptest.o stdio.o string.o stdlib.o \
       start.o time.o errno.o assert.o signal.o locale.o \
       ctype.o setjmp.o math.o __memmgr.o x64supb.obj
#  cmd /c if exist pdpwin64.a del pdpwin64.a
  rm -f pdpwin64.a
  $(AR) r pdpwin64.a p32start.o stdio.o string.o stdlib.o x64supb.obj
  $(AR) r pdpwin64.a start.o time.o errno.o assert.o signal.o
  $(AR) r pdpwin64.a locale.o ctype.o setjmp.o math.o __memmgr.o
  $(AR) s pdpwin64.a
  $(LD) -s -nostdlib -o pdptest.exe p32start.o pdptest.o pdpwin64.a ../src/kernel32.a

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

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

clean:
  rm -rf *.o
  rm -rf pdptest.exe
