# Configuration Makefile # # Part of the Routino routing software. # # This file Copyright 2013-2015, 2017, 2018, 2020 Andrew M. Bishop # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Automatic operating system detection UNAME=$(shell uname) HOST=UNIX ifneq ($(findstring CYGWIN,$(UNAME)),) HOST=CYGWIN endif ifneq ($(findstring MINGW,$(UNAME)),) HOST=MINGW endif # Simplify handling of executable targets ending in .exe ifeq ($(HOST),MINGW) .EXE=.exe else .EXE= endif # Installation locations (edit if required) ifneq ($(HOST),MINGW) prefix=/usr/local bindir=$(prefix)/bin incdir=$(prefix)/include libdir=$(prefix)/lib docdir=$(prefix)/doc/routino datadir=$(prefix)/share/routino else prefix="c:/Program Files/Routino" bindir=$(prefix)/bin incdir=$(prefix)/include libdir=$(prefix)/lib docdir=$(prefix)/doc datadir=$(prefix)/xml endif # Library version for ABI compatibility SOVERSION=0 # Full library version (SOVERSION.MINOR[.RELEASE]) LIBVERSION=$(SOVERSION).0.0 # Compilation programs CC=gcc CXX=g++ LD=gcc ifdef CLANG ifeq ($(CLANG),1) CC=clang CXX=clang++ LD=clang endif endif # Maths library LDFLAGS=-lm # Language dialect selection CFLAGS=-std=c99 # Warning options CFLAGS+=-Wall -Wmissing-prototypes -Wextra -Wno-unused-parameter -pedantic ifdef CLANG ifeq ($(CLANG),1) CFLAGS+=-Wno-missing-field-initializers endif endif # Optimisation options CFLAGS+=-O3 # Fast maths option - makes test cases fail slightly CFLAGS+=-ffast-math ifdef FASTMATHS ifeq ($(FASTMATHS),0) CFLAGS+=-fno-fast-math endif endif # Optimisation option (only works if compilation and execution use exactly the same CPU architecture). #CFLAGS+=-march=native # Compile with debugging symbols CFLAGS+=-g # Option for compiling with sanitizer for debugging memory addresses and undefined behaviour ifdef SANITIZE ifeq ($(SANITIZE),1) CFLAGS+=-fsanitize=address -fsanitize=leak -fsanitize=undefined LDFLAGS+=-fsanitize=address -fsanitize=leak -fsanitize=undefined endif endif # Option for compiling with profiling for checking execution times ifdef PROFILE ifeq ($(PROFILE),1) CFLAGS+=-pg LDFLAGS+=-pg endif endif # Option for compiling with coverage for checking execution times and unused code ifdef COVERAGE ifeq ($(COVERAGE),1) CFLAGS+=--coverage LDFLAGS+=--coverage endif endif # Extra flags for compiling libroutino shared library (visibility of symbols, shared) CFLAGS_LIB=-fvisibility=hidden LDFLAGS_LIB=-shared # Extra flags for compiling libroutino shared library (position independent code) ifeq ($(HOST),UNIX) CFLAGS_LIB+=-fPIC LDFLAGS_LIB+=-fPIC endif # Extra flags for compiling libroutino shared library (SONAME) ifeq ($(HOST),UNIX) LDFLAGS_SONAME=-Wl,-soname=libroutino.so.$(SOVERSION) LDFLAGS_SLIM_SONAME=-Wl,-soname=libroutino-slim.so.$(SOVERSION) endif # Put the current directory in the shared library path for the router using libroutino LDFLAGS_LDSO=-Wl,-R. # Required for multi-threaded support (comment these two lines out if not required) CFLAGS+=-pthread -DUSE_PTHREADS LDFLAGS+=-pthread -lpthread # Required for bzip2 support (comment these two lines out if not required) ifneq ($(HOST),MINGW) CFLAGS+=-DUSE_BZIP2 LDFLAGS+=-lbz2 endif # Required for gzip support (comment these two lines out if not required) CFLAGS+=-DUSE_GZIP LDFLAGS+=-lz # Required for xz support (uncomment these two lines if required) #CFLAGS+=-DUSE_XZ #LDFLAGS+=-llzma # Required to use stdio with files > 2GiB on 32-bit system. CFLAGS+=-D_FILE_OFFSET_BITS=64 # Required to compile on Linux without a warning about pread() and pwrite() functions. ifneq ($(HOST),MINGW) CFLAGS+=-D_POSIX_C_SOURCE=200809L endif