Skip to content

Commit

Permalink
Change dynamic linker to Linux only to correctly support FreeBSD and …
Browse files Browse the repository at this point in the history
…OpenBSD (#3069)

* Change dynamic linker to Linux only to correctly support FreeBSD and OpenBSD
* Add OpenBSD support to 'configure'
  • Loading branch information
abraunegg authored Jan 13, 2025
1 parent a402d1e commit 04a3ab3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ curl_LIBS = @curl_LIBS@
sqlite_LIBS = @sqlite_LIBS@
notify_LIBS = @notify_LIBS@
bsd_inotify_LIBS = @bsd_inotify_LIBS@
dynamic_linker_LIBS = @dynamic_linker_LIBS@
COMPLETIONS = @COMPLETIONS@
BASH_COMPLETION_DIR = @BASH_COMPLETION_DIR@
ZSH_COMPLETION_DIR = @ZSH_COMPLETION_DIR@
Expand Down Expand Up @@ -108,7 +109,7 @@ onedrive: $(SOURCES)
else \
echo $(version) > version ; \
fi
$(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) $(addprefix -L,$(bsd_inotify_LIBS)) -L-ldl $(SOURCES) -of$@
$(DC) $(DCFLAGS) $(addprefix -L,$(curl_LIBS)) $(addprefix -L,$(sqlite_LIBS)) $(addprefix -L,$(notify_LIBS)) $(addprefix -L,$(bsd_inotify_LIBS)) $(addprefix -L,$(dynamic_linker_LIBS)) $(SOURCES) -of$@

install: all
mkdir -p $(DESTDIR)$(bindir)
Expand Down
21 changes: 19 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ COMPLETIONS
NOTIFICATIONS
notify_LIBS
bsd_inotify_LIBS
dynamic_linker_LIBS
notify_CFLAGS
HAVE_SYSTEMD
systemduserunitdir
Expand Down Expand Up @@ -680,6 +681,7 @@ sqlite_LIBS
notify_CFLAGS
notify_LIBS
bsd_inotify_LIBS
dynamic_linker_LIBS
bashcompdir'


Expand Down Expand Up @@ -1324,6 +1326,8 @@ Some influential environment variables:
notify_CFLAGS C compiler flags for GUI notifications, overriding pkg-config
notify_LIBS linker flags for GUI notifications, overriding pkg-config
bsd_inotify_LIBS linker flags for inotify support on BSD
dynamic_linker_LIBS
dynamic linker flags for Linux
bashcompdir value of completionsdir for bash-completion, overriding
pkg-config
Expand Down Expand Up @@ -2509,7 +2513,7 @@ else
fi
NOTIFICATIONS=$enable_notifications
# Check if Linux or BSD Platform
# Check if Linux or BSD Platform to configure the inotify libraries
case "$(uname -s)" in
Linux)
bsd_inotify_LIBS=""
Expand All @@ -2518,7 +2522,7 @@ case "$(uname -s)" in
bsd_inotify_LIBS="-L/usr/local/lib -linotify"
;;
OpenBSD)
bsd_inotify_LIBS=""
bsd_inotify_LIBS="-L/usr/local/lib/inotify -linotify"
;;
*)
bsd_inotify_LIBS=""
Expand All @@ -2528,6 +2532,19 @@ esac
# Export the variable for use in the script
export bsd_inotify_LIBS
# Check if Linux or BSD Platform to configure the dynamic linker libraries
case "$(uname -s)" in
Linux)
dynamic_linker_LIBS="-ldl"
;;
*)
dynamic_linker_LIBS=""
;;
esac
# Export the variable for use in the script
export dynamic_linker_LIBS
# Check whether --enable-completions was given.
if test "${enable_completions+set}" = set; then :
enableval=$enable_completions;
Expand Down
22 changes: 22 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,40 @@ AC_SUBST([NOTIFICATIONS],$enable_notifications)
dnl
dnl iNotify Support
AC_CANONICAL_HOST

# Conditionally set bsd_inotify_LIBS based on the platform
case "$host_os" in
freebsd*)
bsd_inotify_LIBS="-linotify"
;;
openbsd*)
bsd_inotify_LIBS="-linotify"
;;
*)
bsd_inotify_LIBS=""
;;
esac

AC_SUBST([bsd_inotify_LIBS])

dnl
dnl Dynamic Linker Support

# Conditionally set dynamic_linker_LIBS based on the platform
case "$host_os" in
freebsd*)
dynamic_linker_LIBS=""
;;
openbsd*)
dynamic_linker_LIBS=""
;;
*)
dynamic_linker_LIBS="-ldl"
;;
esac

AC_SUBST([dynamic_linker_LIBS])

dnl
dnl Completion support
dnl First determine whether completions are requested, pass that to Makefile
Expand Down

0 comments on commit 04a3ab3

Please sign in to comment.