1
+ TOP ?= $(shell pwd)
2
+
1
3
SUBDIRS = src tests samples
2
4
3
5
bad :
4
6
@echo " Please 'make' one of: release, debug, all, or clean."
5
7
6
- # CXX=clang
7
- # CXX=/usr/lib/gcc-snapshot/bin/g++
8
- CXX =g++-4.8
8
+ UNAME_S := $(shell uname -s)
9
+ ifeq ($(UNAME_S ) ,Linux)
10
+ UNAME=LINUX
11
+ CXX=g++-4.8
12
+ endif
13
+ ifeq ($(UNAME_S ) ,Darwin)
14
+ UNAME=APPLE
15
+ CXX =clang++
16
+ endif
17
+
18
+ export UNAME
9
19
export CXX
10
20
11
21
mk_out_dir :
@@ -18,45 +28,70 @@ release: mk_out_dir tests samples
18
28
19
29
debug : OPTIMIZATION_LEVEL = -O0 -g -ggdb
20
30
debug : MODE = Debug$(shell getconf LONG_BIT)
21
- debug : OUTPUT_DIR = $(PWD ) /../Binaries/$(MODE )
31
+ debug : OUTPUT_DIR = $(TOP ) /../Binaries/$(MODE )
22
32
debug : mk_out_dir tests samples
23
33
24
34
clean : RMODE = Release$(shell getconf LONG_BIT)
25
35
clean : DMODE = Debug$(shell getconf LONG_BIT)
26
- clean : ROUTPUT_DIR = $(PWD ) /../Binaries/$(RMODE )
27
- clean : DOUTPUT_DIR = $(PWD ) /../Binaries/$(DMODE )
36
+ clean : ROUTPUT_DIR = $(TOP ) /../Binaries/$(RMODE )
37
+ clean : DOUTPUT_DIR = $(TOP ) /../Binaries/$(DMODE )
28
38
29
39
export MODE
30
40
31
41
WARNINGS =-Wall -Wextra -Wunused-parameter -Wcast-align -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls -Wunreachable-code
32
- SUPPRESSIONS =-Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-unused-function -Wno-char-subscripts -Wno-switch -Wno-unused-but-set-parameter -Wno-deprecated -Wno-unused-value -Wno-unused-local-typedefs
33
42
43
+ ifeq ($(UNAME ) ,LINUX)
44
+ SUPPRESSIONS =-Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-unused-function -Wno-char-subscripts -Wno-switch -Wno-unused-but-set-parameter -Wno-deprecated -Wno-unused-value -Wno-unused-local-typedefs
34
45
# C++11 excludes GCC < 4.7, which is desired anyway
35
46
OTHER_OPTIONS=-std =c++11 -fno-strict-aliasing
47
+ endif
48
+ ifeq ($(UNAME ) ,APPLE)
49
+ SUPPRESSIONS =-Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-unused-function -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage
50
+ OTHER_OPTIONS=-stdlib =libc++ -std=c++11 -fno-strict-aliasing
51
+ endif
36
52
37
53
STRICT_BASE_CXXFLAGS =$(OPTIMIZATION_LEVEL ) $(OTHER_OPTIONS ) $(WARNINGS ) $(SUPPRESSIONS ) -Werror -pedantic
38
54
export STRICT_BASE_CXXFLAGS
39
55
40
56
BASE_CXXFLAGS =$(OPTIMIZATION_LEVEL ) $(OTHER_OPTIONS ) $(WARNINGS ) $(SUPPRESSIONS ) -Werror
41
57
export BASE_CXXFLAGS
42
58
43
- LAX_BASE_CXXFLAGS =$(OPTIMIZATION_LEVEL ) $(SUPPRESSIONS ) $(OTHER_OPTIONS ) -fpermissive
59
+ LAX_BASE_CXXFLAGS =$(OPTIMIZATION_LEVEL ) $(SUPPRESSIONS ) $(OTHER_OPTIONS )
44
60
export LAX_BASE_CXXFLAGS
45
61
46
- BASE_LDFLAGS =-Wl,-z,defs
62
+ # Disallows undefined symbols in object files (not supported on MacOS)
63
+ ifeq ($(UNAME ) ,LINUX)
64
+ BASE_LDFLAGS =-Wl,-z,defs
65
+ endif
47
66
export BASE_LDFLAGS
48
67
49
68
export OUTPUT_DIR
50
69
51
- CASABLANCA_INCLUDE_DIR =$(PWD ) /include/
70
+ CASABLANCA_INCLUDE_DIR =$(TOP ) /include/
52
71
export CASABLANCA_INCLUDE_DIR
53
72
54
- CASABLANCA_DIR =$(PWD ) /
73
+ CASABLANCA_DIR =$(TOP ) /
55
74
export CASABLANCA_DIR
56
75
57
- CASABLANCA_TESTS_DIR =$(PWD ) /tests
76
+ CASABLANCA_TESTS_DIR =$(TOP ) /tests
58
77
export CASABLANCA_TESTS_DIR
59
78
79
+ # boost libraries: use '-mt' suffix for Apple
80
+ ifeq ($(UNAME ) ,LINUX)
81
+ export BOOST_SYSTEM =boost_system
82
+ export BOOST_THREAD =boost_thread
83
+ export BOOST_LOCALE =boost_locale
84
+ export BOOST_REGEX =boost_regex
85
+ export BOOST_FILE_SYSTEM =boost_filesystem
86
+ endif
87
+ ifeq ($(UNAME ) ,APPLE)
88
+ export BOOST_SYSTEM =boost_system-mt
89
+ export BOOST_THREAD =boost_thread-mt
90
+ export BOOST_LOCALE =boost_locale-mt
91
+ export BOOST_REGEX =boost_regex-mt
92
+ export BOOST_FILE_SYSTEM =boost_filesystem-mt
93
+ endif
94
+
60
95
tests : src
61
96
samples : src
62
97
0 commit comments