Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old October 16, 2011, 11:43   #1
camb
Rookie
 
Join Date: Oct 2011
Posts: 5
camb is on a distinguished road
Compiling on Max OS X Lion

Hi,

Has anyone been able to compile using Xcode 4.2, specifically under Max OS X Lion? I was able to compile with XCode 3.x under Snow Leopard but it appears that Lion doesn't support XCode 3.x

The first step seems to be replace "arch -ppc arch -i386" in Makefile.osx with either "arch -i686" or "arch -x86_64" (my machine is 64 bit). This allows most of the source files to compile but has problems with main-crb.c.

Any suggestions or better yet a working Makefile?

Thanks,
Cameron
camb is offline   Reply With Quote
Old October 16, 2011, 11:56   #2
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,393
Donated: $60
Nick will become famous soon enough
This works for me for FAangband. You may need to replace occurrences of $(NAME) with Angband and $(PROG) with angband, and possibly mess with some of the files in the diet section.

Code:
# 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 = $(NAME).app
EXE = $(PROG)

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/$(NAME).icns osx/Save.icns osx/Edit.icns osx/Data.icns
PLIST = osx/$(NAME).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\$$/$(NAME)/' -e 's/\$$EXECUTABLE\$$/$(EXE)/' \
		$(PLIST) > $(APPCONT)/Info.plist

	SetFile -a B $(APPBNDL)


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



PACKAGE_NAME = $(NAME)-$(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*
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is online now   Reply With Quote
Old October 17, 2011, 22:49   #3
camb
Rookie
 
Join Date: Oct 2011
Posts: 5
camb is on a distinguished road
Brilliant. Yes that worked for NPP after making those changes you suggested. Thanks!

Cameron
camb is offline   Reply With Quote
Old December 1, 2011, 05:00   #4
camb
Rookie
 
Join Date: Oct 2011
Posts: 5
camb is on a distinguished road
Hi Nick,

Jeff has released a new beta version of NPP and the makefile you posted no longer works for it. I'm now getting the following errors:

main-crb.c:3618: error: ‘Cursor’ undeclared (first use in this function)
main-crb.c:3618: error: (Each undeclared identifier is reported only once
main-crb.c:3618: error: for each function it appears in.)
main-crb.c:3618: error: expected ‘;’ before ‘tempCursor’
main-crb.c:3619: warning: implicit declaration of function ‘SetCursor’
main-crb.c:3619: warning: implicit declaration of function ‘GetQDGlobalsArrow’
main-crb.c:3619: error: ‘tempCursor’ undeclared (first use in this function)
main-crb.c: In function ‘main’:
main-crb.c:3906: warning: implicit declaration of function ‘InitCursor’
main-crb.c:3925: warning: implicit declaration of function ‘GetCursor’
main-crb.c:3925: error: ‘watchCursor’ undeclared (first use in this function)
main-crb.c:3925: error: invalid type argument of ‘unary *’
main-crb.c:3952: error: ‘Cursor’ undeclared (first use in this function)
main-crb.c:3952: error: expected ‘;’ before ‘tempCursor’
main-crb.c:3953: error: ‘tempCursor’ undeclared (first use in this function)

Jeff added mouse support for this version, which I'm assuming is related. Any suggestions for fixing this?

Thanks,
Cameron
camb is offline   Reply With Quote
Old December 1, 2011, 09:21   #5
ghengiz
Adept
 
ghengiz's Avatar
 
Join Date: Nov 2011
Location: Roaming in Terry Pratchett's Discworld
Posts: 178
ghengiz is on a distinguished road
Quote:
Originally Posted by camb View Post
Hi,

Has anyone been able to compile using Xcode 4.2, specifically under Max OS X Lion? I was able to compile with XCode 3.x under Snow Leopard but it appears that Lion doesn't support XCode 3.x

The first step seems to be replace "arch -ppc arch -i386" in Makefile.osx with either "arch -i686" or "arch -x86_64" (my machine is 64 bit). This allows most of the source files to compile but has problems with main-crb.c.

Any suggestions or better yet a working Makefile?

Thanks,
Cameron
May I suggest you to compile the console version? if you can live without tiles and mouse, it's a solution that seems to work, with just a slightly modified makefile.std, in order to exclude X11, SDL, GTK.
Of course, now you have to launch npp from the command line, as opposed to just click on a nice icon
I just tried this on lion 10.7.2, xcode 4.2 and npp 0.5.3

The makefile to use is Makefile.std, modified as in
Code:
# File: Makefile.std
# Standard makefile for NPPAngband.
#
# This makefile probably requires GNU make.
#
# This makefile is intended for use with Unix machines running X11, gtk or 
# (n)curses.  You can choose which you want to compile for below.
#
# You can also place your alterations to a file in the src/ directory called 
# "config", in which case that file will override what is specified here.
#

#### Things you should, or could, change ####


# What systems to try.
#
# By default, this tries to compile both the X11 and "curses" terminal mode
# ports in the same executable.


# Recent, known-to-work ports

# Support X11 (main-x11.c)
# You may have to add various X11 include/library directories to the
# "CFLAGS", if your machine places files in a weird location, for example
# " -I/usr/X11R6/include", or "-L/usr/X11R6/lib" to LIBS.
#SYS_x11 = -DUSE_X11 -lX11

# Support curses console mode (main-gcu.c)
# If this fails, try the alternate below
SYS_gcu = -DUSE_GCU -DUSE_NCURSES -lncurses
#SYS_gcu = -DUSE_GCU -lcurses -ltermcap

# Support the GTK2 graphical tookit (main-gtk.c)
#SYS_gtk = -rdynamic -export-dynamic -DUSE_GTK $(shell pkg-config libglade-2.0 gtk+-2.0 --libs --cflags)

# Support SDL frontend
#SYS_sdl = -DUSE_SDL $(shell sdl-config --cflags) $(shell sdl-config --libs) -lSDL_ttf -lSDL_image




## Support SDL_mixer for sound
#SOUND_sdl = -DSOUND_SDL $(shell sdl-config --cflags) $(shell sdl-config --libs) -lSDL_mixer



# Basic compiler stuff
CC = gcc
WARNINGS = -W -Wall -Wextra -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-security -Winit-self -Wmissing-include-dirs -Wundef -Wmissing-format-attribute -Wnested-externs -Wunreachable-code
CFLAGS = -O2 $(WARNINGS)

# Add additional search directives here
# Example: -I/usr/X11R6/include -I/usr/include/ncurses
INCLUDES = -I.
# Example: -L/usr/X11R6/lib 
LIBS =


# Version info
EXE = nppangband



#### Things you probably shouldn't change, unless there is a problem ####

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


# Extract CFLAGS and LIBS from the system definitions
MODULES = $(SYS_x11) $(SYS_gcu) $(SYS_gtk) $(SYS_sdl) $(SOUND_sdl)
CFLAGS += $(patsubst -l%,,$(MODULES)) $(INCLUDES)
LIBS += $(patsubst -D%,,$(patsubst -I%,, $(MODULES)))


# Object definitions
#GTKOBJS = gtk/main-gtk.o gtk/cairo-utils.o
#MAINOBJS = main.o main-gcu.o main-x11.o main-sdl.o snd-sdl.o $(GTKOBJS)
MAINOBJS = main.o main-gcu.o $(GTKOBJS)
OBJS = $(BASEOBJS) $(MAINOBJS)




#### Targets and objects #####

# By default, copy the executable to ../ so that you don't find
# yourself debugging a stale copy.
default: install

# Makefile.inc contains an up-to-date set of object files to compile, so
# we include it
include Makefile.inc


#
# Targets
#

# Build the "Angband" program
$(EXE): $(OBJS)
	@printf "%10s %-20s\n" LINK $@
	@$(CC) $(CFLAGS) $(LDFLAGS) -o $(EXE) $(OBJS) $(LIBS)

# Install the game.
install: ../$(EXE)

docs: doc/index.html

../$(EXE): $(EXE)
	cp $(EXE) ..

# Clean up old junk
clean:
	-rm -f $(OBJS) $(EXE)
	-rm -f ../lib/data/*.raw

# make a distribution
DIRS = lib/apex lib/bone lib/data lib/edit lib/file lib/help lib/info \
       lib/pref lib/save lib/user lib/xtra/sound lib/xtra/graf lib/xtra/font

TMPDIR = ./$(EXE)-$(VERSION)
dist:
	@-rm -rf $(TMPDIR)
	@echo making directories...
	@for i in $(DIRS) ; do mkdir -p $(TMPDIR)/$$i ; done
	@echo copying files...
	@cp ../lib/edit/*.txt $(TMPDIR)/lib/edit
	@cp ../lib/file/*.txt $(TMPDIR)/lib/file
	@cp ../lib/help/*.txt ../lib/help/*.hlp $(TMPDIR)/lib/help
	@cp ../lib/pref/*.prf $(TMPDIR)/lib/pref
	@cp ../lib/xtra/font/*.txt $(TMPDIR)/lib/xtra/font
	@echo attempting to install sound and graphics
	@-cp ../lib/xtra/sound/*.wav $(TMPDIR)/lib/xtra/sound
	@-cp ../lib/xtra/graf/*.bmp $(TMPDIR)/lib/xtra/graf
	@cp ../changes.txt ../readme.txt $(TMPDIR)
	@cp $(EXE) $(TMPDIR)
	tar czf ../$(EXE)-$(VERSION).tar.gz $(TMPDIR)
	rm -rf $(TMPDIR)


#  Verify module arguments
args:
	@echo CFLAGS = $(CFLAGS)
	@echo LDFLAGS = $(LDFLAGS)
	@echo LIBS = $(LIBS)


# Generate dependencies automatically
depend:
	makedepend -D__MAKEDEPEND__ $(SRCS)


# Some file dependencies
%.o: %.c
	@printf "%10s %-20s\n" CC $<
	@$(CC) $(CFLAGS) -o $@ -c $<

# X11 dependencies
main-x11.o: $(HEADERS) main.h

# Basic dependencies for main-xxx.c, main.c
$(MAINOBJS) : main.h $(HEADERS)

# fake Dependency
doc/index.html: $(HEADERS)
	doxygen doc/doxygen.conf
ghengiz is offline   Reply With Quote
Old December 1, 2011, 10:26   #6
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,393
Donated: $60
Nick will become famous soon enough
Quote:
Originally Posted by camb View Post
Any suggestions for fixing this?
It looks like the problem is that the Cursor type and the InitCursor() function are 32-bit specific, which is bad for compiling in Lion. As I see it, your options are
  1. Follow ghengiz' advice and use console mode
  2. Find 64-bit replacements (I have failed to do this after 10 minutes of googling...)
  3. Wait for the Vanilla Cocoa port to come to NPP
  4. Don't try to compile on Lion

Sorry I can't be more helpful.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is online now   Reply With Quote
Old December 1, 2011, 12:59   #7
camb
Rookie
 
Join Date: Oct 2011
Posts: 5
camb is on a distinguished road
Thanks guys.

I can certainly live without mouse support, but have grown rather fond of the tiles.

I might see if I can hack out the mouse-related code.

Cameron
camb is offline   Reply With Quote
Old December 1, 2011, 13:13   #8
camb
Rookie
 
Join Date: Oct 2011
Posts: 5
camb is on a distinguished road
Success!

Simply removing the few lines in main-crb.c that highlight the cursor on the player allowed compilation, without disabling the new mouse functions.

Many thanks.

Cameron
camb is offline   Reply With Quote
Old December 1, 2011, 14:11   #9
nppangband
NPPAngband Maintainer
 
Join Date: Dec 2008
Location: Stat Gain, Angband
Posts: 926
nppangband is on a distinguished road
Quote:
Originally Posted by camb View Post
Hi Nick,

Jeff has released a new beta version of NPP and the makefile you posted no longer works for it. I'm now getting the following errors:


Jeff added mouse support for this version, which I'm assuming is related. Any suggestions for fixing this?
That's the part that is throwing me off. All of the code for mouse support already existed, it just wasn't used very often. I just call those functions much more often now, but I didn't modify anything that should affect how the game needs to be compiled.

In theory, the game should compile and work exactly the same as before, and if it doesn't I want to correct it so it does.

Nick - Beta 1 should compile the exact same as the Competition 114 version. Did you have to make any changes to get teh NPPComp114 version working?

Should I have separate makefiles and main-crb.c files with the source? Or add one for Lion?

Or maybe I should just buy that notebook pro I have had my eyes on for the last year or so.
__________________
NPPAngband current home page: http://nppangband.bitshepherd.net/
Source code repository:
https://github.com/nppangband/NPPAngband_QT
Downloads:
https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57
nppangband is offline   Reply With Quote
Old December 1, 2011, 15:42   #10
ghengiz
Adept
 
ghengiz's Avatar
 
Join Date: Nov 2011
Location: Roaming in Terry Pratchett's Discworld
Posts: 178
ghengiz is on a distinguished road
Quote:
Originally Posted by camb View Post
Success!

Simply removing the few lines in main-crb.c that highlight the cursor on the player allowed compilation, without disabling the new mouse functions.

Many thanks.

Cameron
I'd be glad to confirm this works on a fresh install. Which function did you edit exactly?
ghengiz is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Max Depth... Fendell Orcbane Vanilla 13 March 3, 2018 16:30
Max stats prh182 Vanilla 0 September 23, 2011 16:01
Max amount of spells? steeg1234321 Vanilla 11 April 4, 2008 14:28
Max Blows Conker AAR 2 November 9, 2007 04:40
Max hitpoint variance Conker Vanilla 5 August 12, 2007 00:55


All times are GMT +1. The time now is 12:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.