diff options
author | Denys Fedoryshchenko <denys.f@collabora.com> | 2024-04-09 23:40:48 +0300 |
---|---|---|
committer | Denys Fedoryshchenko <denys.f@collabora.com> | 2024-04-10 01:12:50 +0300 |
commit | 410367e6851e8fb386abecb88369d6fa4e9871b9 (patch) | |
tree | 9fc9080299e423967eb716df92c04ac54680bbfc /accel-pppd | |
parent | 3668336266cb74b6d37e5b56c9c5b74761a868fc (diff) | |
download | accel-ppp-410367e6851e8fb386abecb88369d6fa4e9871b9.tar.gz accel-ppp-410367e6851e8fb386abecb88369d6fa4e9871b9.zip |
musl: Add musl compatibility
Thanks for hints Alpine Linux project and their patches:
https://git.alpinelinux.org/aports/tree/community/accel-ppp?h=master
We can adjust a bit code and cmake config files to make accel-ppp
buildable under musl "as is".
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/CMakeLists.txt | 45 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/arp.c | 2 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 2 | ||||
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 4 | ||||
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 2 |
5 files changed, 54 insertions, 1 deletions
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt index ab8a3508..d194eaa7 100644 --- a/accel-pppd/CMakeLists.txt +++ b/accel-pppd/CMakeLists.txt @@ -44,6 +44,33 @@ IF (RADIUS) ADD_SUBDIRECTORY(radius) ENDIF (RADIUS) +# define __free_fn_t in musl +INCLUDE (CheckCSourceCompiles) +CHECK_C_SOURCE_COMPILES(" +#include <stdlib.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) + + ADD_SUBDIRECTORY(triton) ADD_SUBDIRECTORY(vlan-mon) ADD_SUBDIRECTORY(ctrl) @@ -62,6 +89,12 @@ 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) @@ -123,7 +156,17 @@ ADD_EXECUTABLE(accel-pppd main.c ) -TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre) +# 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) diff --git a/accel-pppd/ctrl/ipoe/arp.c b/accel-pppd/ctrl/ipoe/arp.c index e9b55ff4..ef9d3859 100644 --- a/accel-pppd/ctrl/ipoe/arp.c +++ b/accel-pppd/ctrl/ipoe/arp.c @@ -13,7 +13,9 @@ #include <netinet/ip.h> #include <sys/socket.h> #include <sys/ioctl.h> +#ifdef HAVE_GOOD_IFARP #include <linux/if_arp.h> +#endif #include <linux/if_packet.h> #include "list.h" diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 61b7c238..95ff8568 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -15,7 +15,9 @@ #include <sys/socket.h> #include <sys/ioctl.h> #include <linux/if.h> +#ifdef HAVE_GOOD_IFARP #include <linux/if_arp.h> +#endif #include <linux/route.h> #include <pcre.h> diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 027d7100..9fc2283c 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -853,7 +853,11 @@ static void l2tp_tunnel_free_sessions(struct l2tp_conn_t *conn) void *sessions = conn->sessions; conn->sessions = NULL; +#ifdef HAVE_FREE_FN_T tdestroy(sessions, (__free_fn_t)l2tp_session_free); +#else + tdestroy(sessions, free); +#endif /* Let l2tp_session_free() handle the session counter and * the reference held by the tunnel. */ diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index 76684285..dd623acc 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -11,7 +11,9 @@ #include <net/ethernet.h> #include <netpacket/packet.h> #include <arpa/inet.h> +#ifdef HAVE_PRINTF_H #include <printf.h> +#endif #include "crypto.h" |