blob: 903424d01b3dedf38dfe50b6886b9090ce21ad40 [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 Dunbarfaf01502010-01-18 06:48:33 +000014Archs := i386 ppc x86_64
15# armv6 armv7
Daniel Dunbarb3a69012009-06-26 16:47:03 +000016
Daniel Dunbar866d2822009-09-03 20:49:22 +000017# If TargetArch is defined, only build for that architecture (and don't use
18# -arch).
19ifeq ($(OS), Darwin)
20 TargetArch :=
21 TargetArchs := $(Archs)
22else
23 TargetArch := i386
24 TargetArchs := $(TargetArch)
25endif
26
Daniel Dunbarb3a69012009-06-26 16:47:03 +000027Common.CFLAGS := -Wall -Werror
28
29# These names must match the configs, see GetArgs function.
30Debug.CFLAGS := -g
31Release.CFLAGS := -O3 -fomit-frame-pointer
32Profile.CFLAGS := -pg -g
33
Daniel Dunbar866d2822009-09-03 20:49:22 +000034# Function: GetArchArgs arch
35#
36# Return the compiler flags for the given arch.
37ifeq ($(OS), Darwin)
38 GetArchArgs = -arch $(1)
39else
40 # Check that we are only trying to build the target arch.
41 GetArchArgs = $(if $(subst $(TargetArch),,$(1)), \
42 $(error "Invalid configuration, no -arch support: $(1)"), \
43 )
44endif
45
Daniel Dunbarb3a69012009-06-26 16:47:03 +000046# Function: GetArgs config arch
47#
48# Return the compiler flags for the given config & arch.
Daniel Dunbar866d2822009-09-03 20:49:22 +000049GetArgs = $(if $($(1).CFLAGS), \
50 $(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \
Daniel Dunbarb3a69012009-06-26 16:47:03 +000051 $(error "Invalid configuration: $(1)"))
52
53###
54# Tool configuration variables.
55
56CC := gcc
57# FIXME: LLVM uses autoconf/mkinstalldirs ?
58MKDIR := mkdir -p
59DATE := date
60AR := ar
61# FIXME: Remove these pipes once ranlib errors are fixed.
62AR.Flags := cru 2> /dev/null
63RANLIB := ranlib
64# FIXME: Remove these pipes once ranlib errors are fixed.
65RANLIB.Flags := 2> /dev/null
66LIPO := lipo
Daniel Dunbar866d2822009-09-03 20:49:22 +000067CP := cp
Daniel Dunbarb3a69012009-06-26 16:47:03 +000068
Daniel Dunbara68b0e42010-01-18 06:48:12 +000069VERBOSE := 0
Daniel Dunbarfaf01502010-01-18 06:48:33 +000070DEBUGMAKE :=
Daniel Dunbara68b0e42010-01-18 06:48:12 +000071
Daniel Dunbarb3a69012009-06-26 16:47:03 +000072###
73# Automatic and derived variables.
74
75# Adjust settings for verbose mode
Daniel Dunbara68b0e42010-01-18 06:48:12 +000076ifneq ($(VERBOSE),1)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000077 Verb := @
78else
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000079 Verb :=
Daniel Dunbarb3a69012009-06-26 16:47:03 +000080endif
81
82Echo := @echo
83Archive := $(AR) $(AR.Flags)
84Ranlib := $(RANLIB) $(RANLIB.Flags)
85Lipo := $(LIPO)
86ifndef Summary
87 Summary = $(Echo)
88endif