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
|
#/
# @license Apache-2.0
#
# Copyright (c) 2018 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/
# VARIABLES #
ifndef VERBOSE
QUIET := @
endif
# Specify the path to Boost:
BOOST ?=
# Determine the OS:
#
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
# [2]: http://stackoverflow.com/a/27776822/2225624
OS ?= $(shell uname)
ifneq (, $(findstring MINGW,$(OS)))
OS := WINNT
else
ifneq (, $(findstring MSYS,$(OS)))
OS := WINNT
else
ifneq (, $(findstring CYGWIN,$(OS)))
OS := WINNT
endif
endif
endif
# Define the program used for compiling C++ source files:
ifdef CXX_COMPILER
CXX := $(CXX_COMPILER)
else
CXX := g++
endif
# Define the command-line options when compiling C++ files:
CXXFLAGS ?= \
-std=c++11 \
-O3 \
-Wall \
-pedantic
# Determine whether to generate [position independent code][1]:
#
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
ifeq ($(OS), WINNT)
fPIC ?=
else
fPIC ?= -fPIC
endif
# List of C++ targets:
cxx_targets := runner.out
# TARGETS #
# Default target.
#
# This target is the default target.
all: $(cxx_targets)
.PHONY: all
# Compile C++ source.
#
# This target compiles C++ source files.
$(cxx_targets): %.out: %.cpp $(BOOST)
$(QUIET) $(CXX) $(CXXFLAGS) $(fPIC) -I $(BOOST) -o $@ $< -lm
# Generate test fixtures.
#
# This target generates test fixtures.
run: $(cxx_targets)
$(QUIET) ./$<
.PHONY: run
# Perform clean-up.
#
# This target removes generated files.
clean:
$(QUIET) -rm -f *.o *.out
.PHONY: clean
# Remove fixtures.
#
# This target removes fixture data.
clean-fixtures:
$(QUIET) -rm -f *.json
.PHONY: clean-fixtures
|