blob: d2c614c9a21b170eae06d76b8bbca90a7598dd44 [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 Dunbarb3a69012009-06-26 16:47:03 +00006# Assume make is always run from top-level of source directory. Note
7# than an Apple style build overrides these variables later in the
8# makefile.
9ProjSrcRoot := $(shell pwd)
10ProjObjRoot := $(ProjSrcRoot)
11
12Configs := Debug Release Profile
Daniel Dunbar866d2822009-09-03 20:49:22 +000013
14# The full list of architectures we support.
Daniel Dunbarb3a69012009-06-26 16:47:03 +000015Archs := i386 ppc x86_64
16
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
69###
70# Automatic and derived variables.
71
72# Adjust settings for verbose mode
73ifndef VERBOSE
74 Verb := @
75else
76 Verb :=
77endif
78
79Echo := @echo
80Archive := $(AR) $(AR.Flags)
81Ranlib := $(RANLIB) $(RANLIB.Flags)
82Lipo := $(LIPO)
83ifndef Summary
84 Summary = $(Echo)
85endif