Building on MacOS
This is related to #97 (closed). I wanted to get a running commentary going here so people could see what I found. This may help decide how the build process should be structured. I don't mean to confuse the issue by adding two tickets. So if we feel that's the case, we can delete one or the other.
The short story here is I did get frotz-2.45 to compile in all cases that I tried, including SDL. This ticket shows what that process was like.
I tried to go from basics here. I downloaded both frotz-2.44 (from the IFArchive) and a fresh copy of frotz-2.45 (from GitLab). Then I ran various make commands to see what happened with each.
===========================================================================
frotz-2.44
make frotz
and make dfrotz
Both work right way.
make sdl
You get this error:
src/sdl/sf_images.c:97:21: error: incomplete definition of type 'struct png_struct_def'
if (setjmp(png_ptr->jmpbuf))
In checking, that seems to mean an issue with the library version of libpng. So I did brew install libpng
. That should (according to sources) also take care of any linking problems. It turns out I alread had it and was running 1.6.35 of libpng. An upgrade got me 1.6.36. That however did not fix the issue. I decided to stop here since 2.45 is current anyway. Note, however, with 2.44 things do progress pretty nicely.
===========================================================================
frotz-2.45
make frotz
Immediate errors. Notice how this differs from 2.44. The errors were:
ux_init.c:223:9: error: use of undeclared identifier 'SIGWINCH'
signal(SIGWINCH, sigwinch_handler);
^
ux_init.c:1003:12: error: use of undeclared identifier 'SIGWINCH'
signal(SIGWINCH, sigwinch_handler);
I changed line 16 in the root Makefile to this:
CFLAGS += -g -D_DARWIN_C_SOURCE
That works and generates a frotz executable.
make dfrotz
This just worked out of the box. (It may be due to the changes I made above.)
make sdl
This gets you the following:
sf_util.c:8:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
From what I can see, however, you always should have one of these: <SDL/SDL.h> or <SDL2/SDL.h>.
Make that change and you get the following errors:
sf_util.c:892:36: error: function definition is not allowed here
unsigned myin( void *d, byte **b){return 0;}
^
sf_util.c:894:2: error: function definition is not allowed here
{
^
sf_util.c:908:24: error: use of undeclared identifier 'myin'
st = inflateBack( &z, myin, NULL, myout, NULL);
^
sf_util.c:908:36: error: use of undeclared identifier 'myout'
st = inflateBack( &z, myin, NULL, myout, NULL);
This was already discussed in the previous ticket. The changes in merge request 83 seem to handle that. Fixing that gets you:
sf_ftype.c:7:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
And this is the interesting one. This seems to be freetype even though I definitely have it.
$ locate ft2build.h
/Library/Frameworks/Mono.framework/Versions/5.12.0/include/ft2build.h
/Library/Frameworks/Mono.framework/Versions/5.16.0/include/ft2build.h
/usr/local/Cellar/freetype/2.9.1/include/freetype2/ft2build.h
$ pkg-config --cflags freetype2
-I/usr/local/opt/freetype/include/freetype2
So I dealt with the Makefile in the sdl directory. First I tried a path for pkg-config:
$ which pkg-config
/usr/local/bin/pkg-config
I changed this line:
CFLAGS += `pkg-config $(SDL_PKGS) --cflags`
to:
CFLAGS += `/usr/local/bin/pkg-config $(SDL_PKGS) --cflags`
Same problem, however. So I applied the fix from the previous ticket (and included both the location from locate and from pgk-config):
CFLAGS += -D_THREAD_SAFE
-I/usr/local/Cellar/libpng/1.6.35/include/libpng16
-I/usr/local/Cellar/jpeg/9c/include
-I/usr/local/include/SDL2
-I/usr/local/opt/freetype/include/freetype2
-I/usr/local/Cellar/freetype/2.9.1/include/freetype2
Same problem.
So then I tried putting that above CFLAGS addition in the root Makefile -- not the one in the sdl directory.
AH HA! That works. Then we get the exhaust() errors which are handled by merge request 83. With those fixes in place, you get:
In file included from sf_sig.c:49:
/usr/include/ucontext.h:43:2: error: The deprecated ucontext routines require _XOPEN_SOURCE to be defined
#error The deprecated ucontext routines require _XOPEN_SOURCE to be defined
I add this at the top of sf_sig.c:
#define _XOPEN_SOURCE 600
Then: it compiles!
===========================================================================
So in the end I do get frotz
, dfrotz
, and sfrotz
executables.
Note that when you run sfrotz you might get messages like this:
Class SDLApplication is implemented in both
/usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib (0x1005601c0)
and
/usr/local/lib/libSDL2-2.0.0.dylib (0x100368108).
One of the two will be used. Which one is undefined.
But it does seem to work. I'm able to load up z-code files in all versions of Frotz that I compiled.