# Makefile additions for A/UX

LIB2FUNCS_EXTRA=aux-mcount.c aux-exit.c

FIXPROTO_DEFINES=-D_POSIX_SOURCE

# Only really needed for collect2
CLIB=-lld

# Needed to support builds for multiple versions of A/UX
# LDFLAGS=-static

# Make sure we get the right assembler by letting gcc choose
AS = $(GCC_FOR_TARGET) -xassembler-with-cpp -D__ASSEMBLY__ $(INCLUDES) -c

aux-mcount.c: $(srcdir)/config/m68k/aux-mcount.c
	cp $(srcdir)/config/m68k/aux-mcount.c aux-mcount.c

aux-exit.c: $(srcdir)/config/m68k/aux-exit.c
	cp $(srcdir)/config/m68k/aux-exit.c aux-exit.c

crt1.o: $(srcdir)/config/m68k/aux-crt1.c $(GCC_PASSES)
	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) -o crt1.o -c \
	  -fno-omit-frame-pointer $(srcdir)/config/m68k/aux-crt1.c

mcrt1.o: $(srcdir)/config/m68k/aux-crt1.c $(GCC_PASSES)
	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) -o mcrt1.o -c \
	  -fno-omit-frame-pointer -DMCRT1 $(srcdir)/config/m68k/aux-crt1.c

maccrt1.o: $(srcdir)/config/m68k/aux-crt1.c $(GCC_PASSES)
	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) -o maccrt1.o -c \
	  -fno-omit-frame-pointer -DMACCRT1 $(srcdir)/config/m68k/aux-crt1.c

crt2.o: $(srcdir)/config/m68k/aux-crt2.asm $(GCC_PASSES)
	$(AS) -o crt2.o $(srcdir)/config/m68k/aux-crt2.asm

crtn.o: $(srcdir)/config/m68k/aux-crtn.asm $(GCC_PASSES)
	$(AS) -o crtn.o $(srcdir)/config/m68k/aux-crtn.asm

low.gld: $(srcdir)/config/m68k/aux-low.gld
	sed -e 's|@libdir@|$(libdir)|' -e 's|@tooldir@|$(tooldir)|' \
		-e 's|@local_prefix@|$(local_prefix)|' \
		$(srcdir)/config/m68k/aux-low.gld > tmp-low.gld
	mv tmp-low.gld low.gld
