Codebase list i2pd / upstream/latest Makefile.linux
upstream/latest

Tree @upstream/latest (Download .tar.gz)

Makefile.linux @upstream/latestraw · history · blame

# set defaults instead redefine
CXXFLAGS ?= ${CXX_DEBUG} -Wall -Wextra -Wno-unused-parameter -pedantic -Wno-psabi
LDFLAGS ?= ${LD_DEBUG}

## NOTE: The NEEDED_CXXFLAGS are here so that custom CXXFLAGS can be specified at build time
## **without** overwriting the CXXFLAGS which we need in order to build.
## For example, when adding 'hardening flags' to the build
## (e.g. -fstack-protector-strong -Wformat -Werror=format-security), we do not want to remove
## -std=c++11. If you want to remove this variable please do so in a way that allows setting
## custom FDLAGS to work at build-time.

# detect proper flag for c++11 support by compilers
CXXVER := $(shell $(CXX) -dumpversion)
ifeq ($(shell expr match $(CXX) 'clang'),5)
	NEEDED_CXXFLAGS += -std=c++11
else ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # gcc >= 4.10
	NEEDED_CXXFLAGS += -std=c++11
else ifeq ($(shell expr match ${CXXVER} "4\.[8-9]"),3) # gcc 4.8 - 4.9
	NEEDED_CXXFLAGS += -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1
else ifeq ($(shell expr match ${CXXVER} "[5-6]"),1) # gcc 5 - 6
	NEEDED_CXXFLAGS += -std=c++11
	LDLIBS = -latomic
else ifeq ($(shell expr match ${CXXVER} "[1,7-9]"),1) # gcc >= 7
	NEEDED_CXXFLAGS += -std=c++17
	LDLIBS = -latomic
else # not supported
$(error Compiler too old)
endif

NEEDED_CXXFLAGS += -fPIC

ifeq ($(USE_STATIC),yes)
# NOTE: on glibc you will get this warning:
#   Using 'getaddrinfo' in statically linked applications requires at runtime
#   the shared libraries from the glibc version used for linking
	LIBDIR := /usr/lib/$(SYS)
	LDLIBS += $(LIBDIR)/libboost_system.a
	LDLIBS += $(LIBDIR)/libboost_date_time.a
	LDLIBS += $(LIBDIR)/libboost_filesystem.a
	LDLIBS += $(LIBDIR)/libboost_program_options.a
	LDLIBS += $(LIBDIR)/libssl.a
	LDLIBS += $(LIBDIR)/libcrypto.a
	LDLIBS += $(LIBDIR)/libz.a
ifeq ($(USE_UPNP),yes)
	LDLIBS += $(LIBDIR)/libminiupnpc.a
endif
	LDLIBS += -lpthread -ldl
else
	LDLIBS += -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread
ifeq ($(USE_UPNP),yes)
	LDLIBS += -lminiupnpc
endif
endif

# UPNP Support (miniupnpc 1.5 and higher)
ifeq ($(USE_UPNP),yes)
	NEEDED_CXXFLAGS += -DUSE_UPNP
endif

ifeq ($(USE_AESNI),yes)
ifneq (, $(findstring i386, $(SYS))$(findstring i686, $(SYS))$(findstring x86_64, $(SYS))) # only x86-based CPU supports that
	NEEDED_CXXFLAGS += -D__AES__ -maes
endif
endif