Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackery to get udpgw building on Mac #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Makefile
CMakeFiles
*.a
*.cmake
CMakeCache.txt
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ else ()
set(BADVPN_THREADWORK_USE_PTHREAD 1)
add_definitions(-DBADVPN_THREADWORK_USE_PTHREAD)
add_definitions(-DBADVPN_THREAD_SAFE=1)
add_definitions(-DBADVPN_USE_KEVENT)

link_libraries(rt pthread)
link_libraries(pthread)

if (EMSCRIPTEN)
add_definitions(-DBADVPN_EMSCRIPTEN)
Expand Down Expand Up @@ -215,7 +216,6 @@ else ()
if (NOT HAVE_KQUEUE)
message(FATAL_ERROR "kqueue is required")
endif ()
add_definitions(-DBADVPN_USE_KEVENT)
endif ()

if (NOT DEFINED BADVPN_WITHOUT_CRYPTODEV)
Expand Down
13 changes: 13 additions & 0 deletions compile-udpgw-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Unclear how many of these are necessary
export CPPFLAGS="-I/usr/local/opt/openssl@3/include -I/usr/local/opt/nss/include"
export CFLAGS="-I/usr/local/opt/openssl@3/include -I/usr/local/opt/nss/include"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/nss/lib"

cmake . -DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_UDPGW=1

# This will fail, but whatever
make

# This should work
cd udpgw
make
2 changes: 1 addition & 1 deletion compile-udpgw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ for f in $SOURCES; do
OBJS=( "${OBJS[@]}" "${obj}" )
done

"${CC}" ${LDFLAGS} "${OBJS[@]}" -o udpgw -lrt -lpthread
"${CC}" ${LDFLAGS} "${OBJS[@]}" -o udpgw -lpthread
2 changes: 2 additions & 0 deletions system/BDatagram_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define _GNU_SOURCE
#endif

#define __APPLE_USE_RFC_2292

#include <stddef.h>
#include <string.h>
#include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions system/BDatagram_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#define BDATAGRAM_SEND_LIMIT 2
#define BDATAGRAM_RECV_LIMIT 2
#define __APPLE_USE_RFC_2292

struct BDatagram_s {
BReactor *reactor;
Expand Down
2 changes: 1 addition & 1 deletion udpgw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_executable(badvpn-udpgw
udpgw.c
)
target_link_libraries(badvpn-udpgw system flow flowextra)
target_link_libraries(badvpn-udpgw system flow flowextra resolv)

install(
TARGETS badvpn-udpgw
Expand Down
Binary file added udpgw/badvpn-udpgw
Binary file not shown.