From c4f3a1f936bc58f03a5b8409a146be513cb2d416 Mon Sep 17 00:00:00 2001 From: Ian Gilham Date: Mon, 9 Mar 2020 09:31:59 +0000 Subject: [PATCH 1/3] 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 --- .gitignore | 3 +++ README.txt | 9 ++++++++- configure.ac | 12 ++++++++++++ src/Makefile.am | 4 ++++ src/Starfighter.c | 2 +- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ba90db0..d81d100 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,12 @@ src/starfighter aclocal.m4 autom4te.cache compile +config.guess config.h config.h.in config.log config.status +config.sub configure depcomp install-sh @@ -28,6 +30,7 @@ config.h.in~ src/Makefile src/Makefile.in src/.deps +src/conf misc/Makefile misc/Makefile.in misc/.deps diff --git a/README.txt b/README.txt index d1c643e..89b93d6 100644 --- a/README.txt +++ b/README.txt @@ -136,6 +136,14 @@ terminal window: 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 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 generally don't actually have to do this. - diff --git a/configure.ac b/configure.ac index de100ca..543da5b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,18 @@ AC_PROG_INSTALL STARFIGHTER_CPPFLAGS="-DVERSION=\\\"$PACKAGE_VERSION\\\" -Wall -Wformat-truncation=0" # 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]) PKG_CHECK_EXISTS([SDL2_mixer], [ diff --git a/src/Makefile.am b/src/Makefile.am index c4f0431..27131a6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,10 @@ else starfighter_CPPFLAGS = $(STARFIGHTER_CPPFLAGS) -DDATADIR=\"$(pkgdatadir)\" endif +if BUILD_MACOS +starfighter_LDFLAGS = -framework CoreFoundation +endif + starfighter_CFLAGS = $(SDL_CFLAGS) $(PANGO_CFLAGS) starfighter_LDADD = $(SDL_LIBS) $(PANGO_LIBS) diff --git a/src/Starfighter.c b/src/Starfighter.c index 30f3892..7e8d41a 100644 --- a/src/Starfighter.c +++ b/src/Starfighter.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) char path[PATH_MAX]; if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { - chdir(path); + // chdir(path); printf("Current directory \"%s\"\n", path); } else From 5bd2e96ece4380b9c6c8ff63cadbdf7ff17f6a96 Mon Sep 17 00:00:00 2001 From: Ian Gilham Date: Thu, 12 Mar 2020 16:59:40 +0000 Subject: [PATCH 2/3] revert commenting of chdir on macOS --- src/Starfighter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Starfighter.c b/src/Starfighter.c index 7e8d41a..30f3892 100644 --- a/src/Starfighter.c +++ b/src/Starfighter.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) char path[PATH_MAX]; if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { - // chdir(path); + chdir(path); printf("Current directory \"%s\"\n", path); } else From ced506645480a66a60f84d3646d6ae59f7522a92 Mon Sep 17 00:00:00 2001 From: Ian Gilham Date: Thu, 12 Mar 2020 17:08:26 +0000 Subject: [PATCH 3/3] document error when binary not moved after build --- README.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.txt b/README.txt index 89b93d6..6fafbdb 100644 --- a/README.txt +++ b/README.txt @@ -104,6 +104,11 @@ following from the Project: Starfighter base directory: make mv src/starfighter . +Note that you may see errors relating to 'TTF_OpenFont' failures if you did not move the binary out of the src directory. E.g: + + Current directory "/Users/yourname/code/starfighter/src" + ERROR: TTF_OpenFont: Couldn't open data/TakaoPGothic.ttf + Run "./configure --help" to see all options for compiling. ------------------------------------------------------------------------