# Makefile for production linux86 engine

# Linux includes the GNU preprocessor so nothing needs to be done.
INITIALIZE=if [ ! -f cccp ]; then ln -s /lib/cpp cccp; fi

PROCESSOR=procPentium
PLATFORM=platLinux86
GUI=X11

### Compiler switches
GCCWARNINGFLAGS=-Wall -Wno-format -Wno-unused-value
# gcc 3.2.x requires -mno-accumulate-outgoing-args
COPTS=-mno-accumulate-outgoing-args -mieee-fp -fsigned-char -g -O2 $(GCCWARNINGFLAGS) -pthread

THREADDEFS=-DNBAPI -D_REENTRANT -D_LIBC_REENTRANT -DPTHREADS
THREADLIBS=-lpthread -lrt

OPTDEFS=-DFIRENZE -DLOADABLE_GUI=1 -DOE_PROFILE
DEBUGDEFS=
BASEDEFS=-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
CDEFS=$(BASEDEFS) $(OPTDEFS) $(THREADDEFS) $(DEBUGDEFS)

LIBRARIES=-export-dynamic -L/usr/X11R6/lib $(THREADLIBS) -ldl -lX11 -lm -lz
NOGUILIBRARIES=-export-dynamic $(THREADLIBS) -ldl -lm -lz
OBJ=o
SHOBJ=so

### Linker switches
LDFLAGS=-r
LDGUILIBFLAGS=-shared -L/usr/X11R6/lib $(THREADLIBS) -ldl -lX11 -lm

CC=/usr/bin/cc

# Avoid warnings when preprocessing glue.m
PLATOPTS=CPP_MSRC='-x assembler-with-cpp'
# PLATOPTS=CPP_MSRC='-lang-asm' # Older gnu cpp

include src/makefiles/makefile.generic

SPLASH=bits-vw50-e-4.h
SPLASH_INC=src/makeplat/artwork

herald.o: src/plat/x11Splash.c $(SPLASH_INC)/$(SPLASH)
	$(CC) -c -I$(SPLASH_INC) -DSPLASH_H=\"$(SPLASH)\" -fpic \
            -o herald.o src/plat/x11Splash.c

herald.so: herald.o
	ld -o herald.so -shared herald.o

# Some gcc configurations (e.g. 3.2.3 on RedHat 7.2) generate native 387
# instructions for exp, pow, log, log10 et al, and these produce incorrect
# results for Inf arguments.  So compile with -fno-inline -minline-all-stringops
# to ensure calls on the library functions are generated.
prim.o: prFloat.o prDouble.o
prDouble.o: src/prim/prDouble.c src/include/hps.h \
  src/include/versionDefines.h src/include/platform.h \
  src/include/platNames.h src/include/procNames.h src/include/osNames.h \
  src/include/dispNames.h src/include/platLinux86.h \
  src/include/procPentium.h src/include/oop32bitsBA.h \
  src/include/bits32.h src/include/unicode.h src/include/osLinux.h \
  src/include/dispX11.h src/include/floatIEEE.h \
  src/include/mmOldAbovePerm.h src/include/exError.h src/include/oop.h \
  src/include/oop32.h src/include/sysOop.h src/include/sysOop32.h \
  src/include/mm.h src/include/mmAllocate.h src/include/pr.h \
  src/include/servRequest.h
	$(CC) -fno-inline -minline-all-stringops -Dplatform=platLinux86 $(CDEFS) -I. -Isrc/include -c src/prim/`basename $@ .$(OBJ)`.c
prFloat.o: src/prim/prFloat.c src/include/hps.h \
  src/include/versionDefines.h src/include/platform.h \
  src/include/platNames.h src/include/procNames.h src/include/osNames.h \
  src/include/dispNames.h src/include/platLinux86.h \
  src/include/procPentium.h src/include/oop32bitsBA.h \
  src/include/bits32.h src/include/unicode.h src/include/osLinux.h \
  src/include/dispX11.h src/include/floatIEEE.h \
  src/include/mmOldAbovePerm.h src/include/exError.h src/include/oop.h \
  src/include/oop32.h src/include/sysOop.h src/include/sysOop32.h \
  src/include/mm.h src/include/mmAllocate.h src/include/pr.h \
  src/include/servRequest.h
	$(CC) -fno-inline -minline-all-stringops -Dplatform=platLinux86 $(CDEFS) -I. -Isrc/include -c src/prim/`basename $@ .$(OBJ)`.c
