# -*- makefile -*-
-CFLAGS = -DDARWIN -Dppc -g -Wall -O3 -no-cpp-precomp
-OS_SRC = bsd-os.c os-common.c ppc-darwin-os.c ppc-darwin-dlshim.c
+CFLAGS = -Dppc -g -Wall -O2 -no-cpp-precomp -fdollars-in-identifiers
+OS_SRC = bsd-os.c os-common.c ppc-darwin-os.c ppc-darwin-dlshim.c ppc-darwin-langinfo.c
OS_LIBS = -lSystem -lc -lm
+OS_OBJS = ppc-darwin-rospace.o
-# Avoid the dreaded gcc 3.3 prerelease tarpit of death!
-CC = gcc3
+CC = gcc
ASSEM_SRC = ppc-assem.S ldso-stubs.S
ARCH_SRC = ppc-arch.c
CPP = cpp -no-cpp-precomp
-OS_LINK_FLAGS = -dynamic -L$(HOME)/local/lib -L/sw/lib -L/opt/local/lib -L/usr/local/lib
+# KLUDGE: in OS X 10.3, Apple started putting the heap right where we
+# expect our read-only space mapped. This hack causes the linker to
+# place a zero-fill-on-demand segment in the same place and size as
+# read-only-space, which is the only thing capable of keeping malloc
+# out of this range.
+OS_LINK_FLAGS = -dynamic `cat ppc-darwin-link-flags` -twolevel_namespace -bind_at_load
GC_SRC= cheneygc.c
+CLEAN_FILES += ppc-darwin-mkrospace ppc-darwin-fix-rospace ppc-darwin-link-flags
+
+ppc-darwin-mkrospace: ppc-darwin-mkrospace.c
+ $(CC) -g -Wall -pedantic -o $@ $<
+
+ppc-darwin-fix-rospace: ppc-darwin-fix-rospace.c
+ $(CC) -g -Wall -pedantic -o $@ $<
+
+ppc-darwin-rospace.o ppc-darwin-link-flags: ppc-darwin-mkrospace
+ ./ppc-darwin-mkrospace > ppc-darwin-link-flags
+
+.PHONY: after-grovel-headers
+
+# Fix the sbcl runtime to avoid Panther placing the heap where
+# it wants read only space (in the first 32 megabytes, where it
+# can be absolute-branched to with BA.) Must be done after
+# grovel-headers, because Apple's nm is broken.
+after-grovel-headers: ppc-darwin-fix-rospace
+ ./ppc-darwin-fix-rospace
+
+# Fortunatly make-target-1.sh does a make clean all the time.
+# Otherwise we would have to make sure that sbcl gets rebuilt without
+# the readonlyspace hack before groveling headers again.