build: fix MacOS support

- Detect host OS
- Add CoreFoundation framework to linker flags
- Comment out a chdir which breaks the app on load
- Document how to work around locale building on a Mac

Fixes #3
This commit is contained in:
Ian Gilham 2020-03-09 09:31:59 +00:00
parent d6731c09d4
commit c4f3a1f936
No known key found for this signature in database
GPG Key ID: 9597F133EF2FC115
5 changed files with 28 additions and 2 deletions

3
.gitignore vendored
View File

@ -13,10 +13,12 @@ src/starfighter
aclocal.m4 aclocal.m4
autom4te.cache autom4te.cache
compile compile
config.guess
config.h config.h
config.h.in config.h.in
config.log config.log
config.status config.status
config.sub
configure configure
depcomp depcomp
install-sh install-sh
@ -28,6 +30,7 @@ config.h.in~
src/Makefile src/Makefile
src/Makefile.in src/Makefile.in
src/.deps src/.deps
src/conf
misc/Makefile misc/Makefile
misc/Makefile.in misc/Makefile.in
misc/.deps misc/.deps

View File

@ -136,6 +136,14 @@ terminal window:
The arguments to autoreconf are technically optional, but recommended. The arguments to autoreconf are technically optional, but recommended.
The Python script build.py may fail on MacOS due to a missing msgfmt
program. msgfmt is part of gettext and the version that ships on a Mac
does not include the msgfmt utility. This can be solved by using gettext
from Homebrew:
brew install gettext
export PATH="$(brew --prefix gettext)/bin:$PATH"
If for some reason you need to remove all of these files from your If for some reason you need to remove all of these files from your
directory, you can do so via the following command (requires Git): directory, you can do so via the following command (requires Git):
@ -143,4 +151,3 @@ directory, you can do so via the following command (requires Git):
Note: automatically generated files are listed in .gitignore, so you Note: automatically generated files are listed in .gitignore, so you
generally don't actually have to do this. generally don't actually have to do this.

View File

@ -20,6 +20,18 @@ AC_PROG_INSTALL
STARFIGHTER_CPPFLAGS="-DVERSION=\\\"$PACKAGE_VERSION\\\" -Wall -Wformat-truncation=0" STARFIGHTER_CPPFLAGS="-DVERSION=\\\"$PACKAGE_VERSION\\\" -Wall -Wformat-truncation=0"
# Checks for libraries. # Checks for libraries.
# Detect MacOS
AC_CANONICAL_HOST
build_mac=no
case $host_os in
darwin*) build_mac=yes
;;
esac
AM_CONDITIONAL([BUILD_MACOS], [test "$build_mac" = "yes"])
AC_SEARCH_LIBS([atanf], [m]) AC_SEARCH_LIBS([atanf], [m])
PKG_CHECK_EXISTS([SDL2_mixer], [ PKG_CHECK_EXISTS([SDL2_mixer], [

View File

@ -11,6 +11,10 @@ else
starfighter_CPPFLAGS = $(STARFIGHTER_CPPFLAGS) -DDATADIR=\"$(pkgdatadir)\" starfighter_CPPFLAGS = $(STARFIGHTER_CPPFLAGS) -DDATADIR=\"$(pkgdatadir)\"
endif endif
if BUILD_MACOS
starfighter_LDFLAGS = -framework CoreFoundation
endif
starfighter_CFLAGS = $(SDL_CFLAGS) $(PANGO_CFLAGS) starfighter_CFLAGS = $(SDL_CFLAGS) $(PANGO_CFLAGS)
starfighter_LDADD = $(SDL_LIBS) $(PANGO_LIBS) starfighter_LDADD = $(SDL_LIBS) $(PANGO_LIBS)

View File

@ -65,7 +65,7 @@ int main(int argc, char **argv)
char path[PATH_MAX]; char path[PATH_MAX];
if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{ {
chdir(path); // chdir(path);
printf("Current directory \"%s\"\n", path); printf("Current directory \"%s\"\n", path);
} }
else else