Skip to content

Commit

Permalink
Updated autoconf to detect Mac OS X and set LDFLAGS accordingly.
Browse files Browse the repository at this point in the history
The OSX version of `ld` expects `-Wl,--export_dynamic` not
`-Wl,--export-dynamic`.

This helps address bug #16: #16

At least, it helps address the issue.  To build on Mac OS X with
macports you may need the following:

and finally, xnec2c is an X app so be sure to run it under XQuartz.

Big thanks to Rafal Lukawiecki EI6LA for helping troubleshoot to get
xnec2c building on OSX!
  • Loading branch information
Eric Wheeler committed Nov 18, 2022
1 parent 4cb4dd7 commit c680e14
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4 m4-include])
AM_MAINTAINER_MODE

# AC_CANONICAL_HOST is needed to access the 'host_os' variable
AC_CANONICAL_HOST

build_linux=no
build_windows=no
build_mac=no

# Detect the target system
case "${host_os}" in
linux*)
build_linux=yes
;;
cygwin*|mingw*)
build_windows=yes
;;
darwin*)
build_mac=yes
;;
*)
AC_MSG_ERROR(["OS $host_os is not supported"])
;;
esac

# Pass the conditionals to automake
AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"])

# Set CFLAGS if not set in environment
AC_MSG_CHECKING([whether configure should try to set CFLAGS])
if test "x${CFLAGS+set}" = xset; then
Expand Down
5 changes: 5 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Process this file with automake to produce Makefile.in

if OSX
AM_LDFLAGS = -Wl,-export_dynamic
else
AM_LDFLAGS = -Wl,--export-dynamic -Wl,--as-needed
endif

# Disable warnings for overlength-strings, nothing we can do about that for GTK resources.
# Maybe some compilers can't handle the length, but gcc and clang take it fine.
Expand Down

0 comments on commit c680e14

Please sign in to comment.