summaryrefslogtreecommitdiff
path: root/make/config.mk
blob: 43716af583531f8d3c4a4b0174af40aa18e8cbbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
###
# Configuration variables.

OS := $(shell uname)

# 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

# The full list of architectures we support.
Archs := i386 ppc x86_64 armv6 armv7

# 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

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

# 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

# Function: GetArgs config arch
#
# Return the compiler flags for the given config & arch.
GetArgs = $(if $($(1).CFLAGS), \
	        $(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \
		$(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
CP := cp

###
# 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