# -*- Mode: makefile -*-
PATH1 = ../../src/lisp
vpath %.h $(PATH1)
vpath %.c $(PATH1)
vpath %.S $(PATH1)
CC = gcc -m32
LD = ld
CPP = cpp
# Enable support for :linkage-table feature.

ifdef FEATURE_LINKAGE_TABLE
LINKAGE = -DLINKAGE_TABLE
endif

# Enable support for generational GC
ifdef FEATURE_GENCGC
GENCGC = -DGENCGC
GC_SRC = gencgc.c
endif

RUNTIME = $(GENCGC) $(LINKAGE)
# __NO_CTYPE so builds on glibc 2.3 will run on (some) older glibc's.
ifneq (,$(filter 2% 3%, $(shell $(CC) -dumpversion)))
CPPFLAGS = -D__NO_CTYPE -D_GNU_SOURCE -I. -I$(PATH1) -I- $(RUNTIME)
else
CPPFLAGS = -D__NO_CTYPE -D_GNU_SOURCE -iquote. -iquote $(PATH1) $(RUNTIME)
endif

CFLAGS = -rdynamic -Wstrict-prototypes -Wall -O2 -g $(RUNTIME)
ASFLAGS = -g $(GENCGC) $(LINKAGE_TABLE)
NM = $(PATH1)/linux-nm
UNDEFSYMPATTERN = -Xlinker -u -Xlinker &
ASSEM_SRC = x86-assem.S linux-stubs.S
ARCH_SRC = x86-arch.c
OS_SRC = Linux-os.c os-common.c elf.c e_rem_pio2.c k_rem_pio2.c
OS_LINK_FLAGS = -rdynamic -Xlinker --export-dynamic -Xlinker -Map -Xlinker foo
OS_LIBS = -ldl
#GC_SRC = gencgc.c

# e_rem_pio2.c has strict aliasing issues.  Compile this with
# strict-aliasing rules turned off.  To see this failure, try
# computing (cos (expt 2d0 120)).  This should be near
# -0.92587902285....  If not, then e_rem_pio2 has been miscompiled.
#
# Use -ffloat-store to make sure we get double-float arithmetic
# instead of extended.
e_rem_pio2.o : e_rem_pio2.c
	$(CC) -c -fno-strict-aliasing -ffloat-store $(CFLAGS)  $<

