BUILD: Makefile: shorten default settings declaration

By using a "default_opts" function we can enumerate at once all the
settings we want to enable by default for each platform instead of
individually assigning each variable. Doing this removed 46 lines
in the makefile.
This commit is contained in:
Willy Tarreau 2019-03-27 11:30:47 +01:00
parent 05fd82da76
commit f6bf8e9ead

112
Makefile
View File

@ -287,6 +287,7 @@ use_opts = USE_EPOLL USE_KQUEUE USE_MY_EPOLL USE_MY_SPLICE USE_NETFILTER \
# options string. They may be set to any value, but are historically set to # options string. They may be set to any value, but are historically set to
# "implicit" which eases debugging. You should not have to change anything # "implicit" which eases debugging. You should not have to change anything
# there unless you're adding support for a new platform. # there unless you're adding support for a new platform.
default_opts = $(foreach name,$(1),$(eval $(name)=implicit))
# poll() is always supported, unless explicitly disabled by passing USE_POLL="" # poll() is always supported, unless explicitly disabled by passing USE_POLL=""
# on the make command line. # on the make command line.
@ -297,137 +298,90 @@ USE_POLL = default
ifeq ($(TARGET),generic) ifeq ($(TARGET),generic)
# generic system target has nothing specific # generic system target has nothing specific
USE_POLL = implicit $(call default_opts,USE_POLL USE_TPROXY)
USE_TPROXY = implicit
else else
ifeq ($(TARGET),haiku) ifeq ($(TARGET),haiku)
# For Haiku # For Haiku
TARGET_LDFLAGS = -lnetwork TARGET_LDFLAGS = -lnetwork
USE_POLL = implicit $(call default_opts,USE_POLL USE_TPROXY)
USE_TPROXY = implicit
else else
ifeq ($(TARGET),linux22) ifeq ($(TARGET),linux22)
# This is for Linux 2.2 # This is for Linux 2.2
USE_POLL = implicit $(call default_opts, \
USE_TPROXY = implicit USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT)
USE_LIBCRYPT = implicit
USE_DL = implicit
USE_RT = implicit
else else
ifeq ($(TARGET),linux24) ifeq ($(TARGET),linux24)
# This is for standard Linux 2.4 with netfilter but without epoll() # This is for standard Linux 2.4 with netfilter but without epoll()
USE_NETFILTER = implicit $(call default_opts, \
USE_POLL = implicit USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER)
USE_TPROXY = implicit
USE_CRYPT_H = implicit
USE_LIBCRYPT = implicit
USE_DL = implicit
USE_RT = implicit
else else
ifeq ($(TARGET),linux24e) ifeq ($(TARGET),linux24e)
# This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21 # This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21
USE_NETFILTER = implicit $(call default_opts, \
USE_POLL = implicit USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \
USE_EPOLL = implicit USE_EPOLL USE_MY_EPOLL)
USE_MY_EPOLL = implicit
USE_TPROXY = implicit
USE_CRYPT_H = implicit
USE_LIBCRYPT = implicit
USE_DL = implicit
USE_RT = implicit
else else
ifeq ($(TARGET),linux26) ifeq ($(TARGET),linux26)
# This is for standard Linux 2.6 with netfilter and standard epoll() # This is for standard Linux 2.6 with netfilter and standard epoll()
USE_NETFILTER = implicit $(call default_opts, \
USE_POLL = implicit USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \
USE_EPOLL = implicit USE_EPOLL USE_FUTEX)
USE_TPROXY = implicit
USE_CRYPT_H = implicit
USE_LIBCRYPT = implicit
USE_FUTEX = implicit
USE_DL = implicit
USE_RT = implicit
else else
ifeq ($(TARGET),linux2628) ifeq ($(TARGET),linux2628)
# This is for standard Linux >= 2.6.28 with netfilter, epoll, tproxy and splice # This is for standard Linux >= 2.6.28 with netfilter, epoll, tproxy and splice
USE_NETFILTER = implicit $(call default_opts, \
USE_POLL = implicit USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \
USE_EPOLL = implicit USE_CPU_AFFINITY USE_THREAD USE_EPOLL USE_FUTEX USE_LINUX_TPROXY \
USE_TPROXY = implicit USE_ACCEPT4 USE_LINUX_SPLICE ASSUME_SPLICE_WORKS)
USE_CRYPT_H = implicit
USE_LIBCRYPT = implicit
USE_LINUX_SPLICE= implicit
USE_LINUX_TPROXY= implicit
USE_ACCEPT4 = implicit
USE_FUTEX = implicit
USE_CPU_AFFINITY= implicit
ASSUME_SPLICE_WORKS= implicit
USE_DL = implicit
USE_RT = implicit
USE_THREAD = implicit
else else
ifeq ($(TARGET),solaris) ifeq ($(TARGET),solaris)
# This is for Solaris 8 # This is for Solaris 8
# We also enable getaddrinfo() which works since solaris 8. # We also enable getaddrinfo() which works since solaris 8.
USE_POLL = implicit $(call default_opts, \
USE_POLL USE_TPROXY USE_LIBCRYPT USE_CRYPT_H USE_GETADDRINFO USE_THREAD)
TARGET_CFLAGS = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ TARGET_CFLAGS = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT -D_XOPEN_SOURCE=500 -D__EXTENSIONS__
TARGET_LDFLAGS = -lnsl -lsocket TARGET_LDFLAGS = -lnsl -lsocket
USE_TPROXY = implicit
USE_LIBCRYPT = implicit
USE_CRYPT_H = implicit
USE_GETADDRINFO = implicit
USE_THREAD = implicit
else else
ifeq ($(TARGET),freebsd) ifeq ($(TARGET),freebsd)
# This is for FreeBSD # This is for FreeBSD
USE_POLL = implicit $(call default_opts, \
USE_KQUEUE = implicit USE_POLL USE_TPROXY USE_LIBCRYPT USE_THREAD USE_CPU_AFFINITY USE_KQUEUE \
USE_TPROXY = implicit USE_CLOSEFROM)
USE_LIBCRYPT = implicit
USE_THREAD = implicit
USE_CPU_AFFINITY= implicit
USE_CLOSEFROM = implicit
else else
ifeq ($(TARGET),osx) ifeq ($(TARGET),osx)
# This is for Mac OS/X # This is for Mac OS/X
USE_POLL = implicit $(call default_opts, \
USE_KQUEUE = implicit USE_POLL USE_TPROXY USE_KQUEUE)
USE_TPROXY = implicit
EXPORT_SYMBOL = -export_dynamic EXPORT_SYMBOL = -export_dynamic
else else
ifeq ($(TARGET),openbsd) ifeq ($(TARGET),openbsd)
# This is for OpenBSD >= 5.7 # This is for OpenBSD >= 5.7
USE_POLL = implicit $(call default_opts, \
USE_KQUEUE = implicit USE_POLL USE_TPROXY USE_THREAD USE_KQUEUE USE_ACCEPT4)
USE_TPROXY = implicit
USE_ACCEPT4 = implicit
USE_THREAD = implicit
else else
ifeq ($(TARGET),netbsd) ifeq ($(TARGET),netbsd)
# This is for NetBSD # This is for NetBSD
USE_POLL = implicit $(call default_opts, \
USE_KQUEUE = implicit USE_POLL USE_TPROXY USE_KQUEUE)
USE_TPROXY = implicit
else else
ifeq ($(TARGET),aix51) ifeq ($(TARGET),aix51)
# This is for AIX 5.1 # This is for AIX 5.1
USE_POLL = implicit $(call default_opts, \
USE_LIBCRYPT = implicit USE_POLL USE_LIBCRYPT)
TARGET_CFLAGS = -Dss_family=__ss_family TARGET_CFLAGS = -Dss_family=__ss_family
DEBUG_CFLAGS = DEBUG_CFLAGS =
else else
ifeq ($(TARGET),aix52) ifeq ($(TARGET),aix52)
# This is for AIX 5.2 and later # This is for AIX 5.2 and later
USE_POLL = implicit $(call default_opts, \
USE_LIBCRYPT = implicit USE_POLL USE_LIBCRYPT)
TARGET_CFLAGS = -D_MSGQSUPPORT TARGET_CFLAGS = -D_MSGQSUPPORT
DEBUG_CFLAGS = DEBUG_CFLAGS =
else else
ifeq ($(TARGET),cygwin) ifeq ($(TARGET),cygwin)
# This is for Cygwin # This is for Cygwin
# Cygwin adds IPv6 support only in version 1.7 (in beta right now). # Cygwin adds IPv6 support only in version 1.7 (in beta right now).
USE_POLL = implicit $(call default_opts,USE_POLL USE_TPROXY)
USE_TPROXY = implicit
TARGET_CFLAGS = $(if $(filter 1.5.%, $(shell uname -r)), -DUSE_IPV6 -DAF_INET6=23 -DINET6_ADDRSTRLEN=46, ) TARGET_CFLAGS = $(if $(filter 1.5.%, $(shell uname -r)), -DUSE_IPV6 -DAF_INET6=23 -DINET6_ADDRSTRLEN=46, )
endif # cygwin endif # cygwin
endif # aix52 endif # aix52