##
# Variables included by all Makefiles.
##
## Directory definitions
libdir = $(slateroot)/lib
mobiusdir = $(slateroot)/src/mobius
platformdir = $(mobiusdir)/vm/platform
pluginsdir = $(slateroot)/src/plugins
testdir = $(slateroot)/tests
benchmarkdir = $(testdir)/benchmark
prefix = /usr/local
datadir = $(prefix)/share/slate
exec_prefix = $(prefix)/bin
execname = slate
includedir = $(prefix)/include
lispdir = $(prefix)/share/emacs/site-lisp
DEVNULL := /dev/null
## Build modes. Set on command line using VERBOSE=1, DEBUG=1 or PROFILE=1
ifndef VERBOSE
VERBOSE := 0
SILENT := @
SILENT_ERRORS := 2> $(DEVNULL)
LIBTOOL_FLAGS += --silent
endif
ifdef DEBUG
MODE := debug
COPTFLAGS += -g -Wall
else
MODE := optimized
COPTFLAGS += -O2 -Wall -DNDEBUG=1
endif
ifdef PROFILE
MODE += profiled
COPTFLAGS += -pg -g
else
COPTFLAGS += -fomit-frame-pointer
endif
ifdef DEBUG_MSG
MODE += debug_msg
COPTFLAGS += -DDEBUG_MSG=1
endif
## All required executables
CC := gcc
CP := cp -f
LIBTOOL ?= libtool
ECHO := echo
WGET := wget -q --cache=off
SECHO := @$(ECHO)
INSTALL := install
TAR := tar
GZIP := gzip
ETAGS := etags
EMACS := emacs
## Platform independent definitions
INCLUDES += -I${platformdir}/includes -I. -I${slateroot}
CFLAGS += $(COPTFLAGS) $(INCLUDES) -DSLATE_DATADIR=\"$(datadir)\"
CFLAGS += -DVERSION=$(VERSION)
CFLAGS += `sdl-config --cflags`
CFLAGS += -include SDL_main.h
## Determine the host system's byte order.
## This creates a temporary test executable in the $(slateroot) directory
## since we can guarantee write permissions there on all platforms.
BYTE_ORDER := "int main(){union{long l;char c[sizeof(long)];}u;u.l=1;return(u.c[sizeof(long)-1]==1);}"
BYTE_ORDER := $(shell echo $(BYTE_ORDER) > $(slateroot)/byteorder.c)
BYTE_ORDER := $(shell $(CC) -o $(slateroot)/byteorder $(slateroot)/byteorder.c)
BYTE_ORDER := $(shell $(slateroot)/byteorder; echo $$?)
BYTE_ORDER_ := $(shell $(RM) $(slateroot)/byteorder.* $(slateroot)/byteorder 1>&2)
ifeq ($(BYTE_ORDER),0)
BYTE_ORDER := LITTLE_ENDIAN
BYTE_ORDER_PREFIX := little
else
BYTE_ORDER := BIG_ENDIAN
BYTE_ORDER_PREFIX := big
endif
## Default variables
PLATFORM := unix
VM := $(slateroot)/vm
VERSION := $(shell [ -f $(slateroot)/VERSION ] && cat $(slateroot)/VERSION)
CCVERSION := $(shell $(CC) -dumpversion)
BOOTIMG := slate.image
ALPHA_URL := http://slate.tunes.org/repos/alpha
WORD_SIZE := 32
LDFLAGS := # -avoid-version
LIBS := -lm -ldl
LIBS += `sdl-config --libs`
ANSI_PLUGINS := platform time
POSIX_PLUGINS := $(ANSI_PLUGINS) socket posix pipe
PLUGINS := smart-console/ncurses socket platform time posix pipe sdl-windows cairo
SOURCES := $(wildcard $(platformdir)/*.c) $(wildcard $(platformdir)/$(PLATFORM)/*.c) $(VM).c
OBJS := $(subst .c,.o,$(SOURCES))
ALPHAIMG := $(BYTE_ORDER_PREFIX).image
BOOTFILES := vm.c vm.h AutoLoad
HOST_SYSTEM := $(shell uname -s)
LIB_SO_EXT := .so
INSTALL_MODE := -m 644
TARKITDIR := slate-$(VERSION)
TARKITFILE := $(TARKITDIR).tar
DISTFILES := demo doc etc src tests Makefile common.mk BUGS CREDITS
DISTFILES += LICENSE NEWS README VERSION $(ALPHAIMG)
## Print the welcome banner
ifndef BANNER
BANNER := $(shell echo 1>&2 )
BANNER := $(shell echo "Welcome to Slate: Less talk, more rock!" 1>&2 )
BANNER := $(shell echo " Version: $(VERSION)" 1>&2 )
BANNER := $(shell echo " System: $(HOST_SYSTEM) [$(BYTE_ORDER_PREFIX)-endian]" 1>&2 )
BANNER := $(shell echo " Build: $(MODE)" 1>&2 )
BANNER := $(shell echo 1>&2 )
export BANNER # prevent multiple banners on recursive make calls
MAKEFLAGS += BANNER=1
endif
## Word-size:
CFLAGS += -m$(WORD_SIZE)
## Platform specific overrides. Any of the variables above may be changed here.
ifeq ($(HOST_SYSTEM), AIX)
LIB_SO_EXT := .a
PLUGINS := platform time posix pipe
endif
ifeq ($(HOST_SYSTEM), BeOS)
PLATFORM := beos
endif
ifeq ($(findstring CYGWIN,$(HOST_SYSTEM)), CYGWIN)
PLATFORM := windows
LDFLAGS += -no-undefined
LIBS := -lm
LIB_SO_EXT := .dll
# DEVNULL := NUL # Required if using cmd.exe and not bash.
endif
ifeq ($(HOST_SYSTEM), Darwin)
LIBTOOL := MACOSX_DEPLOYMENT_TARGET=10.3 glibtool
# Work around G4 crashes with GCC 4.0.
# TODO: Should be CPU specific.
COPTFLAGS := $(subst -DNDEBUG=1,,$(COPTFLAGS))
endif
ifeq ($(HOST_SYSTEM), DragonFly)
LIBS := -lm
endif
ifeq ($(HOST_SYSTEM), FreeBSD)
LIBS := -lm
endif
ifeq ($(HOST_SYSTEM), HP-UX)
LIBS := -lm -ldld
LIB_SO_EXT := .sl
PLUGINS := socket platform time posix pipe
endif
ifeq ($(HOST_SYSTEM), Linux)
endif
ifeq ($(findstring MINGW,$(HOST_SYSTEM)), MINGW)
PLATFORM := mingw
LIBS := -lm
endif
ifeq ($(HOST_SYSTEM), NetBSD)
LIBS := -lm
endif
ifeq ($(HOST_SYSTEM), SunOS)
PLUGINS := socket platform time posix pipe
# Work around GCC Ultra SPARC alignment bug
# TODO: Should be CPU specific.
COPTFLAGS := $(subst -O2,-O0, $(COPTFLAGS))
endif
Linking ./vm (optimized)
/usr/bin/ld: warning multiple definitions of symbol _Nil
./vm.o definition of _Nil in section (__TEXT,__const)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation(single module) definition of _Nil