Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 1 | ### |
| 2 | # Configuration variables. |
| 3 | |
Daniel Dunbar | 866d282 | 2009-09-03 20:49:22 +0000 | [diff] [blame] | 4 | OS := $(shell uname) |
| 5 | |
Daniel Dunbar | 557a6ea | 2010-01-13 16:13:01 +0000 | [diff] [blame] | 6 | # 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 Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 8 | ProjSrcRoot := $(shell pwd) |
| 9 | ProjObjRoot := $(ProjSrcRoot) |
| 10 | |
| 11 | Configs := Debug Release Profile |
Daniel Dunbar | 866d282 | 2009-09-03 20:49:22 +0000 | [diff] [blame] | 12 | |
| 13 | # The full list of architectures we support. |
Daniel Dunbar | faf0150 | 2010-01-18 06:48:33 +0000 | [diff] [blame^] | 14 | Archs := i386 ppc x86_64 |
| 15 | # armv6 armv7 |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 16 | |
Daniel Dunbar | 866d282 | 2009-09-03 20:49:22 +0000 | [diff] [blame] | 17 | # If TargetArch is defined, only build for that architecture (and don't use |
| 18 | # -arch). |
| 19 | ifeq ($(OS), Darwin) |
| 20 | TargetArch := |
| 21 | TargetArchs := $(Archs) |
| 22 | else |
| 23 | TargetArch := i386 |
| 24 | TargetArchs := $(TargetArch) |
| 25 | endif |
| 26 | |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 27 | Common.CFLAGS := -Wall -Werror |
| 28 | |
| 29 | # These names must match the configs, see GetArgs function. |
| 30 | Debug.CFLAGS := -g |
| 31 | Release.CFLAGS := -O3 -fomit-frame-pointer |
| 32 | Profile.CFLAGS := -pg -g |
| 33 | |
Daniel Dunbar | 866d282 | 2009-09-03 20:49:22 +0000 | [diff] [blame] | 34 | # Function: GetArchArgs arch |
| 35 | # |
| 36 | # Return the compiler flags for the given arch. |
| 37 | ifeq ($(OS), Darwin) |
| 38 | GetArchArgs = -arch $(1) |
| 39 | else |
| 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 | ) |
| 44 | endif |
| 45 | |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 46 | # Function: GetArgs config arch |
| 47 | # |
| 48 | # Return the compiler flags for the given config & arch. |
Daniel Dunbar | 866d282 | 2009-09-03 20:49:22 +0000 | [diff] [blame] | 49 | GetArgs = $(if $($(1).CFLAGS), \ |
| 50 | $(Common.CFLAGS) $($(1).CFLAGS) $(call GetArchArgs,$(2)), \ |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 51 | $(error "Invalid configuration: $(1)")) |
| 52 | |
| 53 | ### |
| 54 | # Tool configuration variables. |
| 55 | |
| 56 | CC := gcc |
| 57 | # FIXME: LLVM uses autoconf/mkinstalldirs ? |
| 58 | MKDIR := mkdir -p |
| 59 | DATE := date |
| 60 | AR := ar |
| 61 | # FIXME: Remove these pipes once ranlib errors are fixed. |
| 62 | AR.Flags := cru 2> /dev/null |
| 63 | RANLIB := ranlib |
| 64 | # FIXME: Remove these pipes once ranlib errors are fixed. |
| 65 | RANLIB.Flags := 2> /dev/null |
| 66 | LIPO := lipo |
Daniel Dunbar | 866d282 | 2009-09-03 20:49:22 +0000 | [diff] [blame] | 67 | CP := cp |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 68 | |
Daniel Dunbar | a68b0e4 | 2010-01-18 06:48:12 +0000 | [diff] [blame] | 69 | VERBOSE := 0 |
Daniel Dunbar | faf0150 | 2010-01-18 06:48:33 +0000 | [diff] [blame^] | 70 | DEBUGMAKE := |
Daniel Dunbar | a68b0e4 | 2010-01-18 06:48:12 +0000 | [diff] [blame] | 71 | |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 72 | ### |
| 73 | # Automatic and derived variables. |
| 74 | |
| 75 | # Adjust settings for verbose mode |
Daniel Dunbar | a68b0e4 | 2010-01-18 06:48:12 +0000 | [diff] [blame] | 76 | ifneq ($(VERBOSE),1) |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 77 | Verb := @ |
| 78 | else |
Daniel Dunbar | 557a6ea | 2010-01-13 16:13:01 +0000 | [diff] [blame] | 79 | Verb := |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 80 | endif |
| 81 | |
| 82 | Echo := @echo |
| 83 | Archive := $(AR) $(AR.Flags) |
| 84 | Ranlib := $(RANLIB) $(RANLIB.Flags) |
| 85 | Lipo := $(LIPO) |
| 86 | ifndef Summary |
| 87 | Summary = $(Echo) |
| 88 | endif |