2009-06-27 00:47:03 +08:00
|
|
|
###
|
|
|
|
# Configuration variables.
|
|
|
|
|
2009-09-04 04:49:22 +08:00
|
|
|
OS := $(shell uname)
|
|
|
|
|
2009-06-27 00:47:03 +08:00
|
|
|
# Assume make is always run from top-level of source directory. Note
|
|
|
|
# than an Apple style build overrides these variables later in the
|
|
|
|
# makefile.
|
|
|
|
ProjSrcRoot := $(shell pwd)
|
|
|
|
ProjObjRoot := $(ProjSrcRoot)
|
|
|
|
|
|
|
|
Configs := Debug Release Profile
|
2009-09-04 04:49:22 +08:00
|
|
|
|
|
|
|
# The full list of architectures we support.
|
2009-09-11 07:50:10 +08:00
|
|
|
Archs := i386 ppc x86_64 armv6 armv7
|
2009-06-27 00:47:03 +08:00
|
|
|
|
2009-09-04 04:49:22 +08:00
|
|
|
# If TargetArch is defined, only build for that architecture (and don't use
|
|
|
|
# -arch).
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
TargetArch :=
|
|
|
|
TargetArchs := $(Archs)
|
|
|
|
else
|
|
|
|
TargetArch := i386
|
|
|
|
TargetArchs := $(TargetArch)
|
|
|
|
endif
|
|
|
|
|
2009-06-27 00:47:03 +08:00
|
|
|
Common.CFLAGS := -Wall -Werror
|
|
|
|
|
|
|
|
# These names must match the configs, see GetArgs function.
|
|
|
|
Debug.CFLAGS := -g
|
|
|
|
Release.CFLAGS := -O3 -fomit-frame-pointer
|
|
|
|
Profile.CFLAGS := -pg -g
|
|
|
|
|
2009-09-04 04:49:22 +08:00
|
|
|
# Function: GetArchArgs arch
|
|
|
|
#
|
|
|
|
# Return the compiler flags for the given arch.
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
GetArchArgs = -arch $(1)
|
|
|
|
else
|
|
|
|
# Check that we are only trying to build the target arch.
|
|
|
|
GetArchArgs = $(if $(subst $(TargetArch),,$(1)), \
|
|
|
|
$(error "Invalid configuration, no -arch support: $(1)"), \
|
|
|
|
)
|
|
|
|
endif
|
|
|
|
|
2009-06-27 00:47:03 +08:00
|
|
|
# Function: GetArgs config arch
|
|
|
|
#
|
|
|
|
# Return the compiler flags for the given config & arch.
|
2009-09-04 04:49:22 +08:00
|
|
|
GetArgs = $(if $($(1).CFLAGS), \
|
|
|
|
$(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \
|
2009-06-27 00:47:03 +08:00
|
|
|
$(error "Invalid configuration: $(1)"))
|
|
|
|
|
|
|
|
###
|
|
|
|
# Tool configuration variables.
|
|
|
|
|
|
|
|
CC := gcc
|
|
|
|
# FIXME: LLVM uses autoconf/mkinstalldirs ?
|
|
|
|
MKDIR := mkdir -p
|
|
|
|
DATE := date
|
|
|
|
AR := ar
|
|
|
|
# FIXME: Remove these pipes once ranlib errors are fixed.
|
|
|
|
AR.Flags := cru 2> /dev/null
|
|
|
|
RANLIB := ranlib
|
|
|
|
# FIXME: Remove these pipes once ranlib errors are fixed.
|
|
|
|
RANLIB.Flags := 2> /dev/null
|
|
|
|
LIPO := lipo
|
2009-09-04 04:49:22 +08:00
|
|
|
CP := cp
|
2009-06-27 00:47:03 +08:00
|
|
|
|
|
|
|
###
|
|
|
|
# Automatic and derived variables.
|
|
|
|
|
|
|
|
# Adjust settings for verbose mode
|
|
|
|
ifndef VERBOSE
|
|
|
|
Verb := @
|
|
|
|
else
|
|
|
|
Verb :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
Echo := @echo
|
|
|
|
Archive := $(AR) $(AR.Flags)
|
|
|
|
Ranlib := $(RANLIB) $(RANLIB.Flags)
|
|
|
|
Lipo := $(LIPO)
|
|
|
|
ifndef Summary
|
|
|
|
Summary = $(Echo)
|
|
|
|
endif
|