blob: f0663aa7f4fedb9b85a80295cbdfc63ed8b38ead [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001###
2# Configuration variables.
3
Daniel Dunbar866d2822009-09-03 20:49:22 +00004OS := $(shell uname)
5
Daniel Dunbar557a6ea2010-01-13 16:13:01 +00006# Assume make is always run from top-level of source directory. Note than an
7# Apple style build overrides these variables later in the makefile.
Daniel Dunbarb3a69012009-06-26 16:47:03 +00008ProjSrcRoot := $(shell pwd)
9ProjObjRoot := $(ProjSrcRoot)
10
11Configs := Debug Release Profile
Daniel Dunbar866d2822009-09-03 20:49:22 +000012
13# The full list of architectures we support.
Daniel Dunbar01f9de52009-09-10 23:50:10 +000014Archs := i386 ppc x86_64 armv6 armv7
Daniel Dunbarb3a69012009-06-26 16:47:03 +000015
Daniel Dunbar866d2822009-09-03 20:49:22 +000016# If TargetArch is defined, only build for that architecture (and don't use
17# -arch).
18ifeq ($(OS), Darwin)
19 TargetArch :=
20 TargetArchs := $(Archs)
21else
22 TargetArch := i386
23 TargetArchs := $(TargetArch)
24endif
25
Daniel Dunbarb3a69012009-06-26 16:47:03 +000026Common.CFLAGS := -Wall -Werror
27
28# These names must match the configs, see GetArgs function.
29Debug.CFLAGS := -g
30Release.CFLAGS := -O3 -fomit-frame-pointer
31Profile.CFLAGS := -pg -g
32
Daniel Dunbar866d2822009-09-03 20:49:22 +000033# Function: GetArchArgs arch
34#
35# Return the compiler flags for the given arch.
36ifeq ($(OS), Darwin)
37 GetArchArgs = -arch $(1)
38else
39 # Check that we are only trying to build the target arch.
40 GetArchArgs = $(if $(subst $(TargetArch),,$(1)), \
41 $(error "Invalid configuration, no -arch support: $(1)"), \
42 )
43endif
44
Daniel Dunbarb3a69012009-06-26 16:47:03 +000045# Function: GetArgs config arch
46#
47# Return the compiler flags for the given config & arch.
Daniel Dunbar866d2822009-09-03 20:49:22 +000048GetArgs = $(if $($(1).CFLAGS), \
49 $(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \
Daniel Dunbarb3a69012009-06-26 16:47:03 +000050 $(error "Invalid configuration: $(1)"))
51
52###
53# Tool configuration variables.
54
55CC := gcc
56# FIXME: LLVM uses autoconf/mkinstalldirs ?
57MKDIR := mkdir -p
58DATE := date
59AR := ar
60# FIXME: Remove these pipes once ranlib errors are fixed.
61AR.Flags := cru 2> /dev/null
62RANLIB := ranlib
63# FIXME: Remove these pipes once ranlib errors are fixed.
64RANLIB.Flags := 2> /dev/null
65LIPO := lipo
Daniel Dunbar866d2822009-09-03 20:49:22 +000066CP := cp
Daniel Dunbarb3a69012009-06-26 16:47:03 +000067
68###
69# Automatic and derived variables.
70
71# Adjust settings for verbose mode
72ifndef VERBOSE
73 Verb := @
74else
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000075 Verb :=
Daniel Dunbarb3a69012009-06-26 16:47:03 +000076endif
77
78Echo := @echo
79Archive := $(AR) $(AR.Flags)
80Ranlib := $(RANLIB) $(RANLIB.Flags)
81Lipo := $(LIPO)
82ifndef Summary
83 Summary = $(Echo)
84endif