# Standard build for OS/2 2.0+

# Define USE_MEMMGR if you are using pdas or anything
# else that makes a huge number of small requests, as
# OS/2 seems to give up at 74,000 or less.

CC=gccwin
COPTS=-DXUSE_MEMMGR -U__WIN32__ -D__HAVESYS__=_System -O2 -fno-common -ansi -D__OS2__ -D__32BIT__ -D__NOBIVA__ -S -I. -I../src
AR=xar

pdptest.exe: os2strt.obj pdptest.obj stdio.obj string.obj stdlib.obj \
       start.obj time.obj errno.obj assert.obj signal.obj locale.obj \
       ctype.obj setjmp.obj math.obj __memmgr.obj fpfuncsw.obj winsupa.obj
  as86 -DOS220 -o needpdos.obj ..\src\needpdos.asm
  ld86 -e top --oformat msdos-mz -o needpdos.exe needpdos.obj
  rm -f pdpos2.lib
  $(AR) r pdpos2.lib os2strt.obj stdio.obj string.obj stdlib.obj
  $(AR) r pdpos2.lib start.obj time.obj errno.obj assert.obj signal.obj
  $(AR) r pdpos2.lib locale.obj ctype.obj setjmp.obj math.obj __memmgr.obj
  $(AR) r pdpos2.lib fpfuncsw.obj winsupa.obj
  $(AR) s pdpos2.lib
  rm -f os2.lib
  genimp doscalls.wat os2.lib
# executable needs to be marked fullscreen if the app uses setvbuf
# otherwise VIO (default) works too
  pdld -s --oformat lx --stub needpdos.exe -o pdptest.exe os2strt.obj pdptest.obj pdpos2.lib os2.lib

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

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

clean:
  rm -f *.obj
  rm -f pdptest.exe
