Compiling on Max OS X Lion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • camb
    Rookie
    • Oct 2011
    • 5

    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
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9647

    #2
    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.

    Comment

    • camb
      Rookie
      • Oct 2011
      • 5

      #3
      Brilliant. Yes that worked for NPP after making those changes you suggested. Thanks!

      Cameron

      Comment

      • camb
        Rookie
        • Oct 2011
        • 5

        #4
        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

        Comment

        • ghengiz
          Adept
          • Nov 2011
          • 178

          #5
          Originally posted by camb
          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

          Comment

          • Nick
            Vanilla maintainer
            • Apr 2007
            • 9647

            #6
            Originally posted by camb
            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.

            Comment

            • camb
              Rookie
              • Oct 2011
              • 5

              #7
              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

              Comment

              • camb
                Rookie
                • Oct 2011
                • 5

                #8
                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

                Comment

                • nppangband
                  NPPAngband Maintainer
                  • Dec 2008
                  • 926

                  #9
                  Originally posted by camb
                  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

                  Comment

                  • ghengiz
                    Adept
                    • Nov 2011
                    • 178

                    #10
                    Originally posted by camb
                    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?

                    Comment

                    • Nick
                      Vanilla maintainer
                      • Apr 2007
                      • 9647

                      #11
                      Originally posted by nppangband
                      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?
                      No (apart from editing the version number in Makefile.src for cosmetic reasons) - but I compiled that on Snow Leopard. I have Lion on a different machine, and had hacked Makefile.osx to work there.

                      Should I have separate makefiles and main-crb.c files with the source? Or add one for Lion?
                      I have two separate ones for my variants now - but that's really only because I compile on both operating system versions. Running isn't a problem. In your shoes, I'd be inclined to wait for V and the Cocoa port (although far be it from me to discourage you from buying a new computer - my Macbook Air that runs Lion is very nice ).
                      One for the Dark Lord on his dark throne
                      In the Land of Mordor where the Shadows lie.

                      Comment

                      • half
                        Knight
                        • Jan 2009
                        • 910

                        #12
                        I'm finally making the switch from Snow Leopard to Lion (well, Mountain Lion) courtesy of a new iMac. I installed the new Xcode (4.6.3 as opposed to 3.2.6) and downloaded the new set of command line tools (as my migration assistant didn't seem to copy the old ones across).

                        I was impressed that everything seemed to compile perfectly. However, on closer inspection, the new machine can run the new executables it produces (and the old ones), but none of my other test machines (on Lion and Snow Leopard) can run the new ones. Failure to run in this case means unexpectedly quitting immediately on startup with the following log. Any ideas as to how to fix this? Sil still uses a modified version of the old style build structure if that is relevant.

                        The log file:
                        Code:
                        Process:         launchd [2294]
                        Path:            /Users/half/Documents/Dropbox/Mine/Sil/Sil.app/Contents/MacOS/Sil
                        Identifier:      net.amirrorclear.Sil
                        Version:         ??? (???)
                        Code Type:       X86 (Native)
                        Parent Process:  launchd [125]
                        
                        Date/Time:       2013-06-15 21:52:09.214 +0100
                        OS Version:      Mac OS X 10.6.8 (10K549)
                        Report Version:  6
                        
                        Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
                        Exception Codes: KERN_INVALID_ADDRESS at 0x000000008fe01030
                        Crashed Thread:  Unknown
                        
                        Backtrace not available
                        
                        Unknown thread crashed with X86 Thread State (32-bit):
                          eax: 0x00000000  ebx: 0x00000000  ecx: 0x00000000  edx: 0x00000000
                          edi: 0x00000000  esi: 0x00000000  ebp: 0x00000000  esp: 0x00000000
                           ss: 0x0000001f  efl: 0x00010202  eip: 0x8fe01030   cs: 0x00000017
                           ds: 0x0000001f   es: 0x0000001f   fs: 0x00000000   gs: 0x00000000
                          cr2: 0x8fe01030
                        
                        Binary images description not available

                        My Makefile.osx:
                        Code:
                        # File: Makefile.osx
                        
                        # This is a (rather crude) Makefile for Mac OS X Carbon port of Sil.
                        #
                        # It was originally designed for NPPAngband
                        # It is based on Makefile.std, made separate because this port does 
                        # not use main.c.
                        #
                        # The main changes for Sil are:
                        #     removing:
                        #        quest.c / quest.o
                        #     renaming most instances of 'angband' to 'sil'
                        #        a notable exception is 'angband.h'
                        
                        # If you are able to construct "main-xxx.c" and/or "Makefile.xxx"
                        # files for a currently unsupported system, please send them to
                        # Robert Ruehlmann < [email]rr9@thangorodrim.net[/email] > for inclusion in future
                        # versions.
                        #
                        # This Makefile comes with "default" dependencies that may be obsolete.
                        
                        # Installing the Developer CD and you'll have this, as well as full
                        # set of Mac OS programming documentation (HTML and PDF)
                        CC = gcc
                        
                        # Some Developer CD tools we need - the standard installation location
                        TOOLDIR = /Developer/Tools
                        REZ = $(TOOLDIR)/Rez
                        # DEREZ = $(TOOLDIR)/DeRez
                        SETFILE = $(TOOLDIR)/SetFile
                        
                        #
                        # The "source" and "object" files.
                        #
                        
                        SRCS = \
                          z-util.c z-virt.c z-form.c z-rand.c z-term.c \
                          variable.c tables.c util.c cave.c \
                          object1.c object2.c monster1.c monster2.c \
                          xtra1.c xtra2.c spells1.c spells2.c \
                          melee1.c melee2.c save.c files.c \
                          cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c \
                          birth.c load.c squelch.c \
                          wizard1.c wizard2.c obj-info.c \
                          generate.c dungeon.c init1.c init2.c randart.c \
                          main-crb.c \
                          use-obj.c
                         
                        
                        OBJS = \
                          z-util.o z-virt.o z-form.o z-rand.o z-term.o \
                          variable.o tables.o util.o cave.o \
                          object1.o object2.o monster1.o monster2.o \
                          xtra1.o xtra2.o spells1.o spells2.o \
                          melee1.o melee2.o save.o files.o \
                          cmd1.o cmd2.o cmd3.o cmd4.o cmd5.o cmd6.o \
                          birth.o load.o squelch.o \
                          wizard1.o wizard2.o obj-info.o \
                          generate.o dungeon.o init1.o init2.o randart.o \
                          main-crb.o \
                          use-obj.o
                        
                        # Can add '-arch ppc' if needed
                        
                        CFLAGS = \
                        	-Wall -Wextra -O0 -fpascal-strings -DMACH_O_CARBON -arch i386
                        LIBS = -framework CoreFoundation -framework QuickTime -framework Carbon
                        
                        
                        #
                        # Default target.
                        #
                        all: install
                        
                        
                        #
                        # Install the game.
                        #
                        
                        # Application bundle -- a directory looking like an ordinary application
                        
                        # Name of the game
                        APPNAME = Sil.app
                        # 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.bmp for Vanilla.  Make sure setting dpi to 72, *not* preserving
                        # the actual size of image.  When you have them ready, put them in the src
                        # directory and "make install-tiles".
                        ICONFILES = Sil.icns Save.icns Edit.icns Data.icns
                        TILES = 8x8.png 16x16.png 32x32.png
                        PLIST = Sil.xml
                        RESSRCS = Sil.r
                        # RESSRCS = Sil.r Sound.r
                        RFLAGS = -i /Developer/Headers/FlatCarbon -d MACH_O_CARBON
                        
                        install: Sil $(RESSRCS) $(ICONFILES) $(PLIST)
                        	[ -d $(APPBNDL) ] || mkdir $(APPBNDL)
                        	[ -d $(APPCONT) ] || mkdir $(APPCONT)
                        	[ -d $(APPBIN) ] || mkdir $(APPBIN)
                        	[ -d $(APPRES) ] || mkdir $(APPRES)
                        	install -m 755 Sil $(APPBIN)
                        	install -m 644 $(ICONFILES) $(APPRES)
                        	$(REZ) $(RFLAGS) -o $(APPRES)/Sil.rsrc $(RESSRCS)
                        	install -m 644 $(PLIST) $(APPCONT)/Info.plist
                        	$(SETFILE) -a B $(APPBNDL)
                        
                        install-tiles: $(TILES)
                        	install -m 644 $(TILES) $(APPRES)
                        
                        
                        #
                        # Build the "Sil" program
                        #
                        
                        Sil: $(OBJS)
                        	$(CC) $(CFLAGS) $(LDFLAGS) -o Sil $(OBJS) $(LIBS)
                        
                        
                        #
                        # Clean up old junk
                        #
                        
                        clean:
                        	-rm -f *.o Sil
                        
                        
                        #
                        # Generate dependencies automatically
                        #
                        
                        depend:
                        	makedepend -D__MAKEDEPEND__ $(SRCS)
                        
                        
                        
                        #
                        # Hack -- some file dependencies
                        #
                        
                        HDRS = \
                          h-basic.h \
                          h-define.h h-type.h h-system.h h-config.h
                        
                        INCS = \
                          angband.h \
                          config.h defines.h types.h externs.h \
                          z-term.h z-rand.h z-util.h z-virt.h z-form.h $(HDRS)
                        
                        
                        birth.o: birth.c $(INCS)
                        cave.o: cave.c $(INCS)
                        cmd1.o: cmd1.c $(INCS)
                        cmd2.o: cmd2.c $(INCS)
                        cmd3.o: cmd3.c $(INCS)
                        cmd4.o: cmd4.c $(INCS)
                        cmd5.o: cmd5.c $(INCS)
                        cmd6.o: cmd6.c $(INCS)
                        dungeon.o: dungeon.c $(INCS)
                        files.o: files.c $(INCS)
                        generate.o: generate.c $(INCS)
                        init1.o: init1.c $(INCS) init.h
                        init2.o: init2.c $(INCS) init.h
                        load.o: load.c $(INCS)  init.h
                        melee1.o: melee1.c $(INCS)
                        melee2.o: melee2.c $(INCS)
                        monster1.o: monster1.c $(INCS)
                        monster2.o: monster2.c $(INCS)
                        obj-info.o: obj-info.c $(INCS)
                        object1.o: object1.c $(INCS)
                        object2.o: object2.c $(INCS)
                        randart.o: randart.c $(INCS) init.h
                        save.o: save.c $(INCS)
                        spells1.o: spells1.c $(INCS)
                        spells2.o: spells2.c $(INCS)
                        squelch.o: squelch.c $(INCS)
                        tables.o: tables.c $(INCS)
                        use-obj.o: use-obj.c $(INCS)
                        util.o: util.c $(INCS)
                        variable.o: variable.c $(INCS)
                        wizard1.o: wizard1.c $(INCS)
                        wizard2.o: wizard2.c $(INCS)
                        xtra1.o: xtra1.c $(INCS)
                        xtra2.o: xtra2.c $(INCS)
                        z-form.o: z-form.c $(HDRS) z-form.h z-util.h z-virt.h
                        z-rand.o: z-rand.c $(HDRS) z-rand.h
                        z-term.o: z-term.c $(HDRS) z-term.h z-virt.h
                        z-util.o: z-util.c $(HDRS) z-util.h
                        z-virt.o: z-virt.c $(HDRS) z-virt.h z-util.h

                        Comment

                        • takkaria
                          Veteran
                          • Apr 2007
                          • 1951

                          #13
                          Originally posted by half
                          I'm finally making the switch from Snow Leopard to Lion (well, Mountain Lion) courtesy of a new iMac. I installed the new Xcode (4.6.3 as opposed to 3.2.6) and downloaded the new set of command line tools (as my migration assistant didn't seem to copy the old ones across).

                          I was impressed that everything seemed to compile perfectly. However, on closer inspection, the new machine can run the new executables it produces (and the old ones), but none of my other test machines (on Lion and Snow Leopard) can run the new ones. Failure to run in this case means unexpectedly quitting immediately on startup with the following log. Any ideas as to how to fix this? Sil still uses a modified version of the old style build structure if that is relevant.
                          You may want to add '-mmacosx-version-min=10.5' to CFLAGS. That's what we use in V.
                          takkaria whispers something about options. -more-

                          Comment

                          • half
                            Knight
                            • Jan 2009
                            • 910

                            #14
                            Originally posted by takkaria
                            You may want to add '-mmacosx-version-min=10.5' to CFLAGS. That's what we use in V.
                            This worked perfectly.

                            Thanks! This could have driven me crazy for weeks. It is great to have such knowledgable people around.

                            Comment

                            Working...
                            😀
                            😂
                            🥰
                            😘
                            🤢
                            😎
                            😞
                            😡
                            👍
                            👎