# This builds PDPCLIB for Linux Bigfoot using binutils

# Not sure if need to disable builtins because an ASCII/EBCDIC issue
# means that it thinks there is no '%' and can use an fputs

.SUFFIXES: .asm

CC=gccmvsa -fno-common
#CC=lingcc
COPTS=-S -Os -U__MVS__ -D__BIGFOOT__ -D__MF32__ \
    -DNOLIBALLOC -D__NOBIVA__ -I . -I../pdpclib -I../src \
    -fno-builtin -D__gnu_linux__ -I../generic -DLOGSHELL
AS=as370 -mhlasm
AR=xar
LD=pdld --emit-relocs --entry __crt0 --oformat elf
#LD=ld370 --entry __crt0 --emit-relocs
CPP=pdcc -N -D BIGFOOT

all: clean pdpclib.a

pdpclib.a: stdio.o string.o stdlib.o \
       start.o time.o errno.o assert.o signal.o locale.o \
       ctype.o setjmp.o math.o pdptest.o \
       mfsupa.o mfsupc.o
        rm -f pdpclib.a
        $(AR) r pdpclib.a stdio.o string.o stdlib.o
        $(AR) r pdpclib.a start.o time.o errno.o assert.o signal.o
        $(AR) r pdpclib.a locale.o ctype.o setjmp.o math.o
        $(AR) r pdpclib.a mfsupa.o mfsupc.o
        $(AR) s pdpclib.a
        $(LD) -o pdptest.exe mfsupa.o pdptest.o pdpclib.a

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

.asm.o:
        $(CPP) -o $*.s $<
        $(AS) -mhlasm -o $@ $*.s
        rm -f $*.s

clean:
        rm -f pdpclib.a
