forked from usnistgov/libbiomeval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.mk
153 lines (135 loc) · 5.23 KB
/
common.mk
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#
# This software was developed at the National Institute of Standards and
# Technology (NIST) by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code, this software is not subject to copyright protection
# and is in the public domain. NIST assumes no responsibility whatsoever for
# its use by other parties, and makes no guarantees, expressed or implied,
# about its quality, reliability, or any other characteristic.
#
# This set of directories is where the header files, libraries, programs,
# and man pages are to be installed.
PREFIX := /usr/local
INCPATH := $(PREFIX)/include
LIBPATH := $(PREFIX)/lib
BINPATH := $(PREFIX)/bin
MANPATH := $(PREFIX)/man/man1
#
# The NBIS library to be used by the framework. Can be either the 'real'
# NBIS installed in the system, or the locally built subset.
NBISEVALNAME = biomeval_nbis
NBISEVALFILE = lib$(NBISEVALNAME).a
#
# Files and directories that are created during the build process, that
# are to be removed during 'make clean'.
DISPOSABLEFILES = *.o *.exe .gdb_history
DISPOSABLEDIRS = *.dSYM
CP := cp -f
RM := rm -f
PWD := $(shell pwd)
OS := $(shell uname -s)
ARCH := $(shell uname -m)
ifeq ($(OS),Darwin)
CC = clang
CXX = clang++
OSX_MAJOR = $(shell sw_vers -productVersion | cut -d. -f1)
OSX_MINOR = $(shell sw_vers -productVersion | cut -d. -f2)
OSX_PATCH = $(shell sw_vers -productVersion | cut -d. -f3)
MACOSX_DEPLOYMENT_TARGET = $(OSX_MAJOR).$(OSX_MINOR)
else
CC = gcc
CXX = g++
endif
MPICXX=mpicxx
#
# Determine if CXX can handle C++11 (-std=c++11 flag)
#
CXX_BASENAME := $(shell basename $(CXX))
ifeq ($(CXX_BASENAME),g++)
CXX_MAJOR := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.`)
CXX_MINOR := $(shell expr `$(CXX) -dumpversion | cut -f2 -d.`)
# -std=c++11 first present in G++ 4.7
SUPPORTS_CXX11 := $(shell [ $(CXX_MAJOR) -ge 5 -o \( $(CXX_MAJOR) -eq 4 -a $(CXX_MINOR) -ge 7 \) ] && echo true)
else
ifeq ($(CXX_BASENAME),clang++)
CXX_MAJOR := $(shell $(CXX) --version | tr '\n' ' ' | sed 's/.*version\ \([[:digit:]]*\)\.[[:digit:]]*.*/\1/')
CXX_MINOR := $(shell $(CXX) --version | tr '\n' ' ' | sed 's/.*version\ [[:digit:]]*\.\([[:digit:]]*\).*/\1/')
ifeq ($(OS),Darwin)
# Apple changes clang++ version to match Xcode,
# so require Xcode 4.2
SUPPORTS_CXX11 := $(shell [ $(CXX_MAJOR) -ge 5 -o \( $(CXX_MAJOR) -eq 4 -a $(CXX_MINOR) -ge 2 \) ] && echo true)
else
# Require clang++ 3.1
SUPPORTS_CXX11 := $(shell [ $(CXX_MAJOR) -ge 4 -o \( $(CXX_MAJOR) -eq 3 -a $(CXX_MINOR) -ge 1 \) ] && echo true)
endif
EXTRA_CXXFLAGS += -stdlib=libc++
else
ifeq ($(CXX_BASENAME),icpc)
CXX_MAJOR := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.`)
CXX_MINOR := $(shell expr `$(CXX) -dumpversion | cut -f2 -d.`)
# Tested with C++11 compatibility in version 15 and later
SUPPORTS_CXX11 := $(shell [ $(CXX_MAJOR) -ge 15 ] && echo true)
else
$(warning CXX=$(CXX) is untested. I assume you know what you are doing...)
SUPPORTS_CXX11 := true
endif
endif
endif
ifneq ($(SUPPORTS_CXX11),true)
$(error This compiler (CXX=$(CXX)) version does not support -std=c++11)
endif
ifeq ($(findstring CYGWIN,$(OS)), CYGWIN)
ROOT = Administrator
OS = CYGWIN
else
ROOT = root
endif
ifeq ($(findstring x86_64,$(ARCH)), x86_64)
ifneq ($(findstring CYGWIN,$(OS)), CYGWIN)
ARCHOPT = -fPIC
endif
endif
#
# If there are any 'non-standard' include or lib directories that need to
# be searched prior to the 'standard' libraries, add the to the CFLAGS
# variable.
CFLAGS := -Wall -pedantic -std=c99 -D$(OS) $(ARCHOPT) $(COMMONINCOPT) -I$(LOCALINC) -I$(INCPATH)
CXXFLAGS := -Wall -pedantic -D$(OS) $(ARCHOPT) $(COMMONINCOPT) -I$(LOCALINC) -I$(INCPATH)
LDFLAGS := -L$(LOCALLIB) -L$(LIBPATH)
# Enable C++11 support.
ifeq ($(findstring CYGWIN,$(OS)), CYGWIN)
# Cygwin's g++ currently requires the GNU dialect
CXXFLAGS += -std=gnu++11
# Cygwin's newlib does not define long double versions of many core C
# functions, which are ultimately required for C++11's std::to_string,
# and will instead cast long doubles to doubles when _LDBL_EQ_DBL is
# defined.
CXXFLAGS += -D_GLIBCXX_USE_C99 -D_LDBL_EQ_DBL
else
CXXFLAGS += -std=c++11
endif
# Enable debugging symbols when DEBUG=1, true, or yes
ifdef DEBUG
CFLAGS += $(if $(or $(findstring 1, $(DEBUG)), $(findstring true, $(DEBUG))m $(findstring yes, $(DEBUG))),-g)
CXXFLAGS += $(if $(or $(findstring 1, $(DEBUG)), $(findstring true, $(DEBUG))m $(findstring yes, $(DEBUG))),-g)
endif
# Force 64-bit compilation when 64=1, true, or yes
ifdef 64
CFLAGS += $(if $(or $(findstring 1, $(64)), $(findstring true, $(64)), $(findstring yes, $(64))),-m64)
CXXFLAGS += $(if $(or $(findstring 1, $(64)), $(findstring true, $(64)), $(findstring yes, $(64))),-m64)
endif
# Force 32-bit compilation when 32=1, true, or yes
ifdef 32
CFLAGS += $(if $(or $(findstring 1, $(32)), $(findstring true, $(32)), $(findstring yes, $(32))),-m32)
CXXFLAGS += $(if $(or $(findstring 1, $(32)), $(findstring true, $(32)), $(findstring yes, $(32))),-m32)
endif
# Add additional flags on build/link without editing this file
ifdef EXTRA_CFLAGS
CFLAGS += $(EXTRA_CFLAGS)
endif
ifdef EXTRA_CXXFLAGS
CXXFLAGS += $(EXTRA_CXXFLAGS)
endif
ifdef EXTRA_LDFLAGS
LDFLAGS += $(EXTRA_LDFLAGS)
endif