summaryrefslogtreecommitdiff
path: root/accel-pppd/CMakeLists.txt
blob: 496fbdca2f0f74658c9767b596da7c40b273eb5a (plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
ADD_DEFINITIONS(-DPTHREAD_SPINLOCK)

include(GNUInstallDirs)

INCLUDE_DIRECTORIES(include)

IF (MEMDEBUG)
	ADD_DEFINITIONS(-DMEMDEBUG)
	IF (VALGRIND)
		ADD_DEFINITIONS(-DVALGRIND)
	ENDIF (VALGRIND)
ENDIF (MEMDEBUG)

IF (SESSIONID_LEN)
	ADD_DEFINITIONS(-DAP_SESSIONID_LEN=${SESSIONID_LEN})
ELSE (SESSIONID_LEN)
	ADD_DEFINITIONS(-DAP_SESSIONID_LEN=16)
ENDIF (SESSIONID_LEN)

#IF (BACKUP)
#	ADD_DEFINITIONS(-DUSE_BACKUP)
#	ADD_SUBDIRECTORY(backup)
#ENDIF (BACKUP)

IF (NOT DEFINED RADIUS)
	SET(RADIUS TRUE)
ENDIF (NOT DEFINED RADIUS)

IF (LUA)
	IF (LUA STREQUAL "TRUE")
		include(FindLua51)
	ELSE ()
		find_package("Lua" ${LUA})
	ENDIF ()
	IF (NOT DEFINED LUA_VERSION_STRING)
		MESSAGE(FATAL_ERROR "lua not found")
	ENDIF ()
	ADD_SUBDIRECTORY(lua)
ENDIF (LUA)

IF (RADIUS)
	ADD_DEFINITIONS(-DRADIUS)
	ADD_SUBDIRECTORY(radius)
ENDIF (RADIUS)

# define __free_fn_t in musl
INCLUDE (CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
#include <stdlib.h>
#include <search.h>
int main(void)
{
	__free_fn_t *f;
	return 0;
}" HAVE_FREE_FN_T)
IF (HAVE_FREE_FN_T)
	ADD_DEFINITIONS(-DHAVE_FREE_FN_T)
ENDIF (HAVE_FREE_FN_T)

INCLUDE (CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
#include <linux/if_arp.h>
#include <net/ethernet.h>
int main(void)
{
	return 0;
}" HAVE_GOOD_IFARP)

IF (HAVE_GOOD_IFARP)
	ADD_DEFINITIONS(-DHAVE_GOOD_IFARP)
ENDIF (HAVE_GOOD_IFARP)

INCLUDE (CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
#include <utmp.h>
int main(void)
{
	logwtmp(\"\", \"\", \"\");
	return 0;
}" HAVE_LOGWTMP)

IF (HAVE_LOGWTMP)
	ADD_DEFINITIONS(-DHAVE_LOGWTMP)
ENDIF (HAVE_LOGWTMP)


ADD_SUBDIRECTORY(triton)
ADD_SUBDIRECTORY(vlan-mon)
ADD_SUBDIRECTORY(ctrl)
ADD_SUBDIRECTORY(auth)
ADD_SUBDIRECTORY(logs)
ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(ipv6)

IF (NOT DEFINED SHAPER)
	SET(SHAPER TRUE)
ENDIF (NOT DEFINED SHAPER)

IF (SHAPER)
	ADD_SUBDIRECTORY(shaper)
ENDIF (SHAPER)

INCLUDE(CheckIncludeFile)
CHECK_INCLUDE_FILE("linux/netfilter/ipset/ip_set.h" HAVE_IPSET)
# MUSL does not have printf.h
CHECK_INCLUDE_FILE("printf.h" HAVE_PRINTF_H)
IF (HAVE_PRINTF_H)
	ADD_DEFINITIONS(-DHAVE_PRINTF_H)
ENDIF (HAVE_PRINTF_H)


INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(setns HAVE_SETNS)

INCLUDE (CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
#include <linux/if_link.h>
int main(void)
{
	return IFLA_VRF_UNSPEC+IFLA_VRF_TABLE;
}" HAVE_VRF)

ADD_EXECUTABLE(accel-pppd
	memdebug.c
	session.c
	session_backup.c
	ifcfg.c
	net.c

	backup/backup.c

	ppp/ppp.c
	ppp/ppp_fsm.c
	ppp/ppp_lcp.c
	ppp/lcp_opt_mru.c
	ppp/lcp_opt_magic.c
	ppp/lcp_opt_pcomp.c
	ppp/lcp_opt_accomp.c
	ppp/ppp_auth.c
	ppp/ppp_ipcp.c
	ppp/ipcp_opt_ipaddr.c
	ppp/ipcp_opt_dns.c
	ppp/ipcp_opt_wins.c
	ppp/ipv6cp_opt_intfid.c
	ppp/ppp_ipv6cp.c
	ppp/ppp_ccp.c	
	ppp/ccp_mppe.c

	cli/std_cmd.c
	cli/show_sessions.c
	cli/telnet.c
	cli/tcp.c
	cli/cli.c
	
	libnetlink/libnetlink.c
	libnetlink/iputils.c
	libnetlink/genl.c
	libnetlink/ipset.c

	pwdb.c
	ipdb.c

	iprange.c

	utils.c
	rbtree.c

	log.c
	main.c
)

# check if we have getcontext/setcontext
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(getcontext HAVE_GETCONTEXT)
CHECK_FUNCTION_EXISTS(setcontext HAVE_SETCONTEXT)

IF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
	TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre)
ELSE (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
	TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre ucontext)
ENDIF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)

set_property(TARGET accel-pppd PROPERTY CMAKE_SKIP_BUILD_RPATH FALSE)
set_property(TARGET accel-pppd PROPERTY CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set_property(TARGET accel-pppd PROPERTY INSTALL_RPATH_USE_LINK_PATH FALSE)
set_property(TARGET accel-pppd PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/accel-ppp)

INSTALL(TARGETS accel-pppd
	RUNTIME DESTINATION sbin
)

INSTALL(FILES accel-ppp.conf.5 DESTINATION share/man/man5)

IF (NOT DEFINED CPACK_TYPE)
	INSTALL(FILES accel-ppp.conf DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}" RENAME accel-ppp.conf.dist)

	INSTALL(DIRECTORY DESTINATION "${CMAKE_INSTALL_LOCALSTATEDIR}/log/accel-ppp")
	INSTALL(DIRECTORY DESTINATION "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/accel-ppp")
ENDIF (NOT DEFINED CPACK_TYPE)