TONPPAMF

The Official NPPAngband And NPPMoria Forum

You are not logged in.

Announcement

November 28, 2016 - NPPAngband forum has been migrated to a new host. SSL has been enabled so please use https:// if possible.

#1 2012-09-22 12:29:11

camb
Member
Registered: 2006-01-29
Posts: 707

[0.6.0] Still problems compiling for Mac

Version 0.6.0 has the same problems compiling for Mac that started appearing about a year ago. The Makefile.osx provided with the distribution is still broken, and requires the following steps to compile on Mac:

1. Replace Makefile.osx with the one I sent you a while ago (I think derived from FAngband).
2. In main-crb.c, remove the lines of code involving Cursor that cause errors (3926, 3953 and 3954).

Appended below is the Makefile.osx that works for me.

Cameron

================================================================

# File: Makefile.osx

# This is a (rather crude) Makefile for Mac OS X Carbon port of Angband.
#
# Based on Makefile.std, made separate because this port does not uses
# main.c.

# default target
all: install

# settings
CC = gcc
LD = ld
OPT ?= -O2

ARCH = -arch i386
WARNINGS = -W -Wall -Wno-unused-parameter -Wno-missing-field-initializers
JUST_C = -std=c99 -Wdeclaration-after-statement
OBJ_CFLAGS = -std=c99 -x objective-c -mmacosx-version-min=10.0
CFLAGS = -g -I. $(WARNINGS) $(OPT) -DMACH_O_CARBON -DHAVE_MKSTEMP \
    -DPRIVATE_USER_PATH=\"~/Library/Preferences\" -DUSE_PRIVATE_PATHS \
    -fno-stack-protector $(ARCH)
LIBS = -framework CoreFoundation -framework QuickTime -framework Carbon \
    -framework Cocoa

# Import user prefs
# If you don't want to edit this file, put your module redefinitions
# and build flags in "./config"
-include config

#
# Provide a CFLAGS override so that older versions of OS X can continue to
# compile their own builds.  The default CFLAGS provide a backwards-compatible
# binary, but will error when building on <10.3.9.
#

# -DALLOW_BORG is required for all .o files in a borg build
ifneq (,$(findstring borg, $(MAKECMDGOALS)))
CFLAGS += -DALLOW_BORG
endif

# Check for autoconf.h; do not warn on nonexistence
autoconf= $(wildcard autoconf.h)
ifneq ($(autoconf),)
CFLAGS += -DHAVE_CONFIG_H
endif



include Makefile.inc

APPNAME = Angband.app
EXE = angband

BOBJS = borg1.o borg2.o borg3.o borg4.o borg5.o borg6.o borg7.o borg8.o borg9.o
OBJS = $(BASEOBJS)
OSX_OBJS = main-crb.o



#
# Build the "Angband" program
#


$(EXE).o: $(OBJS)
    $(LD) -r -arch i386 -o $@.i386 $(OBJS)
    lipo -arch i386 $@.i386 -create -output $(EXE).o

$(EXE): $(EXE).o $(OSX_OBJS)
    $(CC) $(CFLAGS) $(LDFLAGS) -o $(EXE) $(EXE).o $(OSX_OBJS) $(LIBS)

borg: $(OBJS) $(BOBJS)
    $(CC) $(CFLAGS) $(LDFLAGS) -o $(EXE) $(OBJS) $(BOBJS) $(LIBS)

#
# Clean up old junk
#

clean:
    -rm -f $(OBJS) $(EXE) $(EXE).o.i386 $(EXE).o $(OSX_OBJS)


#
# Basic build rules and dependencies
#

main-crb.o : main-crb.c
    @printf "%10s %-20s (objective-c)\n" CC $<
    @$(CC) $(CFLAGS) $(OBJ_CFLAGS) -c -o $@ $<
%.o : %.c
    @printf "%10s %-20s\n" CC $<
    @$(CC) $(JUST_C) $(CFLAGS) -c -o $@ $<


main-crb.o: osx/osx_tables.h


#
# Installation.
# Application bundle -- a directory looking like an ordinary application
#

# Bundle of the game (it must be a directory whose name ends in ".app")
APPBNDL = ../$(APPNAME)

# A bundle must have these subdirectories
APPCONT = $(APPBNDL)/Contents
APPBIN = $(APPCONT)/MacOS
APPRES = $(APPCONT)/Resources

# Auxiliary files. Please note that it still uses resouce fork based
# resources for menus, dialogues and sounds, so that it isn't safe to use
# utilities that doesn't understand them (virtually all Un*x commands) to
# copy or archive the application.
#
# The graphics tiles have been moved out of the resource fork, but, again,
# it isn't generally safe just to convert GIF or BMP files to PNG, because
# the Mac OS takes dpi values stored in various images quite seriously.
# Almost all tilesets for *band requires adjustment, with the sole exception
# of 8x8.png for Vanilla.  Make sure setting dpi to 72, *not* preserving
# the actual size of image.  When you have them ready, put them in
# the lib/xtra/graf directory and rebuild.
ICONFILES = osx/Angband.icns osx/Save.icns osx/Edit.icns osx/Data.icns
PLIST = osx/Angband.xml

GRAPHSRC=../lib/xtra/graf/
TILES = $(GRAPHSRC)8x8.png $(GRAPHSRC)8x16.png $(GRAPHSRC)16x16.png $(GRAPHSRC)32x32.png

LIBFILES = \
  ../lib/edit/*.txt \
  ../lib/file/*.txt \
  ../lib/help/*.txt \
  ../lib/help/*.hlp \
  ../lib/pref/*.prf \

install: $(EXE) $(ICONFILES) $(PLIST) $(LIBFILES)
    @echo making directories...
    @mkdir -p $(APPBNDL)
    @mkdir -p $(APPCONT)
    @mkdir -p $(APPBIN)
    @mkdir -p $(APPRES)
    @mkdir -p $(APPRES)/English.lproj/main.nib
    @mkdir -p $(APPRES)/lib/edit
    @mkdir -p $(APPRES)/lib/file
    @mkdir -p $(APPRES)/lib/help
    @mkdir -p $(APPRES)/lib/pref
    @mkdir -p $(APPRES)/lib/script
    @mkdir -p $(APPRES)/lib/xtra/graf
    @mkdir -p $(APPRES)/lib/xtra/sound

    @echo copying files...
    @cp ../lib/edit/*.txt $(APPRES)/lib/edit
    @cp ../lib/file/*.txt $(APPRES)/lib/file
    @cp ../lib/help/*.txt $(APPRES)/lib/help
    @cp ../lib/help/*.hlp $(APPRES)/lib/help
    @cp ../lib/pref/*.prf $(APPRES)/lib/pref

    # 'optionally' install sound and graphics tiles, if present
    -cp $(TILES) $(APPRES)/lib/xtra/graf
    -cp ../lib/xtra/sound/*.wav $(APPRES)/lib/xtra/sound
    -cp ../lib/xtra/sound/sound.cfg $(APPRES)/lib/xtra/sound

    install -m 755 $(EXE) $(APPBIN)
    install -m 644 $(ICONFILES) $(APPRES)
    cp osx/English.lproj/main.nib/*ib $(APPRES)/English.lproj/main.nib
    sed -e 's/\$$VERSION\$$/$(VERSION)/' -e 's/\$$COPYRIGHT\$$/$(COPYRIGHT)/' \
        -e 's/\$$NAME\$$/Angband/' -e 's/\$$EXECUTABLE\$$/$(EXE)/' \
        $(PLIST) > $(APPCONT)/Info.plist

    SetFile -a B $(APPBNDL)


vars:
    @echo LDFLAGS = $(LDFLAGS)
    @echo CFLAGS = $(CFLAGS)
    @echo BASEOBJS = $(BASEOBJS)



PACKAGE_NAME = Angband-$(VERSION)

# In the unlikely event that tar+zip isn't enough...

dist: install
    @rm -rf disttemp*
    mkdir -p disttemp/Docs
    cp ../copying.txt disttemp/Docs
    cp -R -p "$(APPBNDL)" disttemp
    SetFile -a B disttemp/$(APPNAME)

    @-rm ../"$(PACKAGE_NAME)-osx.dmg"

    hdiutil create -quiet -fs HFS+ -volname $(PACKAGE_NAME) -srcfolder disttemp disttemp.dmg
    hdiutil convert disttemp.dmg -quiet -format UDZO -imagekey zlib-level=6 -o ../"$(PACKAGE_NAME)-osx.dmg"

    rm -rf disttemp*

Last edited by camb (2012-09-22 12:33:06)

Offline

#2 2012-10-02 02:42:06

camb
Member
Registered: 2006-01-29
Posts: 707

Re: [0.6.0] Still problems compiling for Mac

Every time I download and compile new code for Mac, I have to comment out several lines in main-crb.c to remove errors caused by the use of Cursor.

Is there a #define that indicates whether the build is a Mac build or not, so I exclude these lines from Mac builds?

Cameron

Offline

#3 2012-10-05 07:34:45

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: [0.6.0] Still problems compiling for Mac

I replaced the osx makefile with this one.

Offline

#4 2012-10-05 13:38:29

camb
Member
Registered: 2006-01-29
Posts: 707

Re: [0.6.0] Still problems compiling for Mac

Great, thanks. One subtlety is that this Makefile compiles to "Angband" rather than "NPPAngband", which I believe creates problems for players who want to play both games. Hopefully anyone doing an official Mac build will have the skills to sort this out.

Cameron

Offline

#5 2012-10-05 14:06:16

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: [0.6.0] Still problems compiling for Mac

Changing these two lines to nppangband should do it:

APPNAME = Angband.app
EXE = angband

Offline

#6 2012-10-07 16:42:59

camb
Member
Registered: 2006-01-29
Posts: 707

Re: [0.6.0] Still problems compiling for Mac

NPPAngband wrote:

I replaced the osx makefile with this one.

Doesn't work, it gives the following error message:
"Makefile.osx:53: *** missing separator.  Stop."

Cameron

Offline

#7 2012-10-07 16:49:31

NPPAngband
NPPAngband Maintainer
Registered: 2004-07-01
Posts: 1,647
Website

Re: [0.6.0] Still problems compiling for Mac

That's must be a tab/.return issue.  Makefiles don't recognize most standard spacing.  So me copying it from the post above probably produces a defective file.  If you e-mail the file to me, I will include it in future releases.

(Also note I am about to post a fix to wilderness quests that cause them to crash.  If you are going to do wilderness quests, you probably want the latest source form github.)

Offline

Board footer

Powered by FluxBB