Skip to content

Commit

Permalink
fix i18n compilation on brew/MacOS
Browse files Browse the repository at this point in the history
When using brew, <libintl.h> and the associated library are installed
under /opt/brew/{include,lib}.  Our configure script did not check
these locations, the files were not found and thus i18n was
unavailable and disabled.

I've added the internal variables EXTRA_INCLUDEDIRS_TO_CHECK and
EXTRA_LIBDIRS_TO_CHECK to the configure script.  They expand the
directories checked by check_include() and find_lib() and can be set
depending on the build environment so we don't need to check these
directories on every non-brew/MacOS build.

We also need to use the extra include directories when building our
test targets: util.test includes "common.h" which in turn includes
<libintl.h> which needs extra flags as described above.
Because using all $GBSCFLAGS messes up our test build, we filter
only for the -I include paths.
  • Loading branch information
mmitch committed Jan 26, 2025
1 parent e6bbe5c commit 7a637e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
gbsplay HISTORY


2024/04/17 - unreleased
2024/xx/xx - unreleased
~~~~~~~~~~~~~~~~~~~~~~~~~

Bugfixes:

- gbsplay
- don't mess up the screen with underrun errors from the ALSA plugout
when resuming from a pause
- build process:
- fix i18n on brew/MaOS

Enhancements:

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ config.mk: configure

%.test: %.c
@echo TEST $<
$(Q)$(HOSTCC) -DENABLE_TEST=1 -o $@$(binsuffix) $< -lm
$(Q)$(HOSTCC) $(filter -I%,$(GBSCFLAGS)) -DENABLE_TEST=1 -o $@$(binsuffix) $< -lm
$(Q)./$@$(binsuffix)
$(Q)rm ./$@$(binsuffix)

Expand Down
9 changes: 7 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ hostalias=
windows_build=
windows_libprefix=

EXTRA_INCLUDEDIRS_TO_CHECK=
EXTRA_LIBDIRS_TO_CHECK=

## define sane environment
unset LC_ALL LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \
Expand Down Expand Up @@ -84,7 +87,7 @@ die()
check_include()
{
local include="$1"
local includedirs="${2-} /usr/local/include /opt/local/include"
local includedirs="${2-} /usr/local/include /opt/local/include ${EXTRA_INCLUDEDIRS_TO_CHECK}"
local extraline="${3-}"
local includename="$(echo "$include" | sed -e 's@[/\.-]@_@g')"
eval "value=\${have_${includename}-}"
Expand Down Expand Up @@ -115,7 +118,7 @@ find_lib()
local INFILE="$TEMPDIR/fl.c"
local lib="$1"
local libname="$(echo "$lib" | sed -e 's@[/\.-]@_@g')"
local libdirs="${2-} /usr/local/lib /opt/local/lib"
local libdirs="${2-} /usr/local/lib /opt/local/lib ${EXTRA_LIBDIRS_TO_CHECK}"

cat > "$INFILE"

Expand Down Expand Up @@ -622,6 +625,8 @@ case "$BUILDOS" in
Darwin)
setdefault build_test yes
append_nodupe CFLAGS "-D_DARWIN_C_SOURCE=1"
EXTRA_INCLUDEDIRS_TO_CHECK=/opt/homebrew/include
EXTRA_LIBDIRS_TO_CHECK=/opt/homebrew/lib
;;

MSYS_*)
Expand Down

0 comments on commit 7a637e7

Please sign in to comment.