NHDT->ANH, in most cases
[aNetHack.git] / sys / unix / hints / macosx10.10
blobfe0b032e7a7d13a7627b524ed574ff9fbe0bc1c3
2 # NetHack 3.6  macosx10.11 $ANH-Date: 1445622451 2015/10/23 17:47:31 $  $ANH-Branch: master $:$ANH-Revision: 1.0 $
3 # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015.
4 # NetHack may be freely redistributed.  See license for details.
6 #-PRE
7 # Mac OS X (Darwin) hints file
8 # This is for Mac OS X 10.10 or later, and has been tested on 10.11
9 # (El Capitan). If this doesn't work for some other
10 # version of Mac OS X, make a new file for that OS, don't change this one.
11 # And let us know about it.
12 # Useful info: http://www.opensource.apple.com/darwinsource/index.html
14 # You'll need to obtain and install XQuartz if you want X11 support.
15 # (Attempting to run X11.app will describe where to get it.)
17 # This hints file can build several different types of installations.
18 # Edit the next section to match the type of build you need.
20 # 1. Which window system(s) should be included in this binary?
21 WANT_WIN_TTY=1
22 #WANT_WIN_X11=1
23 #WANT_WIN_QT=1
25 # 1a. What is the default window system?
26 WANT_DEFAULT=tty
27 #WANT_DEFAULT=x11
28 #WANT_DEFAULT=qt
30 # 1b. If you set WANT_WIN_QT, you need to
31 #  A) set QTDIR either here or in the environment to point to the Qt2 or Qt3
32 #     library installation root.  (Qt4 will not work; Qt3 does not presently
33 #     compile under Leopard (MacOSX 10.5) out-of-the-box.)
34 #  B) set XPMLIB to point to the Xpm library
35 ifdef WANT_WIN_QT
36 QTDIR=/Developer/Qt
37 LIBXPM= -L/opt/X11/lib -lXpm
38 endif   # WANT_WIN_QT
40 # 2. Is this a build for a binary that will be shared among different users
41 #    or will it be private to you?
42 #    If it is shared:
43 #       - it will be owned by the user and group listed
44 #       - if the user does not exist, you MUST create it before installing
45 #         NetHack
46 #       - if the group does not exist, it will be created.
47 #         NB: if the group already exists and is being used for something
48 #          besides games, you probably want to specify a new group instead
49 #         NB: the group will be created locally; if your computer is centrally
50 #          administered this may not be what you (or your admin) want.
51 #          Consider a non-shared install (WANT_SHARE_INSTALL=0) instead.
52 #       - 'make install' must be run as "sudo make install"    
53 #WANT_SHARE_INSTALL=1
54 GAMEUID  = $(USER)
55 GAMEGRP  = games
56 # build to run in the source tree - primarily for development.  Build with "make all"
57 #WANT_SOURCE_INSTALL=1
59 CC=gcc
61 # At the moment this is just for debugging, but in the future it could be
62 # useful for other things.  Requires SYSCF and an ANSI compiler.
63 #WANT_WIN_CHAIN=1
66 # You shouldn't need to change anything below here.
69 #CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN
70 CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN -ansi -pedantic
71 # As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
72 # leave it out by default.
73 #CFLAGS+=-Wunreachable-code
75 # XXX -g vs -O should go here, -I../include goes in the makefile
76 CFLAGS+=-g -I../include
77 # older binaries use NOCLIPPING, but that disables SIGWINCH
78 #CFLAGS+=-DNOCLIPPING
79 CFLAGS+= -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\"
80 CFLAGS+= -DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\" -DDLB
82 CFLAGS+= -DGREPPATH=\"/usr/bin/grep\"
84 ifdef WANT_WIN_CHAIN
85 CFLAGS+= -DWINCHAIN
86 HINTSRC=$(CHAINSRC)
87 HINTOBJ=$(CHAINOBJ)
88 endif
90 ifdef WANT_WIN_TTY
91 WINSRC = $(WINTTYSRC)
92 WINOBJ = $(WINTTYOBJ)
93 WINLIB = $(WINTTYLIB)
94 WINTTYLIB=-lncurses
95 else    # !WANT_WIN_TTY
96 CFLAGS += -DNOTTYGRAPHICS
97 endif   # !WANT_WIN_TTY
99 ifdef WANT_WIN_X11
100 WINSRC += $(WINX11SRC)
101 WINOBJ += $(WINX11OBJ)
102 WINLIB += $(WINX11LIB)
103 LFLAGS=-L/opt/X11/lib
104 VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
105 POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; (cd $(HACKDIR); mkfontdir);
106 CFLAGS += -DX11_GRAPHICS -I/opt/X11/include
107 # avoid repeated complaints about _X_NONNULL(args...) in <X11/Xfuncproto.h>
108 CFLAGS += -Wno-variadic-macros
109 endif   # WANT_WIN_X11
111 ifdef WANT_WIN_QT
112 CFLAGS += -DQT_GRAPHICS -DNOUSER_SOUNDS
113 CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
114 LINK=g++
115 WINSRC += $(WINQTSRC)
116 WINLIB += $(WINQTLIB) $(LIBXPM)
117 WINLIB += -framework Carbon -framework QuickTime -lz -framework OpenGL
118 WINLIB += -framework AGL
119 ifdef WANT_WIN_X11
120         # prevent duplicate tile.o in WINOBJ
121 WINOBJ = $(sort $(WINQTOBJ) $(WINX11OBJ))
122 ifdef WANT_WIN_TTY
123 WINOBJ += $(WINTTYOBJ)
124 endif   # WANT_WIN_TTY
125 else    # !WANT_WIN_X11
126 WINOBJ += $(WINQTOBJ)
127 endif   # !WANT_WIN_X11
129 # XXX if /Developer/qt exists and QTDIR not set, use that
130 ifndef QTDIR
131 $(error QTDIR not defined in the environment or Makefile)
132 endif   # QTDIR
133 # XXX make sure QTDIR points to something reasonable
134 else    # !WANT_WIN_QT
135 LINK=$(CC)
136 endif   # !WANT_WIN_QT
138 ifdef WANT_SHARE_INSTALL
139 # if $GAMEUID is root, we install into roughly proper Mac locations, otherwise
140 # we install into ~/nethackdir
141 ifeq ($(GAMEUID),root)
142 PREFIX:=/Library/NetHack
143 SHELLDIR=/usr/local/bin
144 HACKDIR=$(PREFIX)/nethackdir
145 CHOWN=chown
146 CHGRP=chgrp
147 # We run sgid so the game has access to both HACKDIR and user preferences.
148 GAMEPERM = 02755
149 else    # ! root
150 PREFIX:=/Users/$(GAMEUID)
151 SHELLDIR=$(PREFIX)/bin
152 HACKDIR=$(PREFIX)/Library/NetHack/nethackdir
153 CHOWN=/usr/bin/true
154 CHGRP=/usr/bin/true
155 GAMEPERM = 0500
156 endif   # ! root
157 VARFILEPERM = 0664
158 VARDIRPERM = 0775
159 ROOTCHECK= [[ `id -u` == 0 ]] || ( echo "Must run install with sudo."; exit 1)
160 # XXX it's nice we don't write over sysconf, but we've already erased it
161 # make sure we have group GAMEUID and group GAMEGRP
162 PREINSTALL= . sys/unix/hints/macosx.sh user2 $(GAMEUID); . sys/unix/hints/macosx.sh group2 $(GAMEGRP); mkdir $(SHELLDIR); chown $(GAMEUID) $(SHELLDIR)
163 POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
164 CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
165 else ifdef WANT_SOURCE_INSTALL
166 PREFIX=$(abspath $(NHSROOT))
167 # suppress nethack.sh
168 #SHELLDIR=
169 HACKDIR=$(PREFIX)/playground
170 CHOWN=/usr/bin/true
171 CHGRP=/usr/bin/true
172 GAMEPERM = 0700
173 VARFILEPERM = 0600
174 VARDIRPERM = 0700
175 # We can use "make all" to build the whole thing - but it misses some things:
176 MOREALL=$(MAKE) install
177 CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
178 else    # !WANT_SOURCE_INSTALL
179 PREFIX:=$(wildcard ~)
180 SHELLDIR=$(PREFIX)/bin
181 HACKDIR=$(PREFIX)/nethackdir
182 CHOWN=/usr/bin/true
183 CHGRP=/usr/bin/true
184 GAMEPERM = 0700
185 VARFILEPERM = 0600
186 VARDIRPERM = 0700
187 ifdef WANT_WIN_X11
188 # install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
189 PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc
190 endif   # WANT_WIN_X11
191 POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
192 CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
193 endif   # !WANT_SOURCE_INSTALL
195 INSTDIR=$(HACKDIR)
196 VARDIR=$(HACKDIR)
199 # ~/Library/Preferences/NetHack Defaults
200 # OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp
201 # OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt
203 # Install.Qt mentions a patch for macos - it's not there (it seems to be in the Qt binary
204 # package under the docs directory).
206 #-POST
207 ifdef MAKEFILE_TOP
209 ### Packaging
211 # Notes:
212 # 1) The Apple developer utilities must be installed in the default location.
213 # 2) Do a normal build before trying to package the game.
214 # 3) This matches the 3.4.3 Term package, but there are some things that should
215 #    be changed.
217 ifdef WANT_WIN_TTY
218 DEVUTIL=/Developer/Applications/Utilities
219 SVS=$(shell $(NHSROOT)/util/makedefs --svs)
220 SVSDOT=$(shell $(NHSROOT)/util/makedefs --svs .)
222 PKGROOT_UG      = PKGROOT/$(PREFIX)
223 PKGROOT_UGLN    = PKGROOT/$(HACKDIR)
224 PKGROOT_BIN     = PKGROOT/$(SHELLDIR)
225 build_tty_pkg:
226 ifneq (,$(WANT_WIN_X11)$(WANT_WIN_QT))
227         -echo build_tty_pkg only works for a tty-only build
228         exit 1
229 else
230         rm -rf NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg
231         $(MAKE) build_package_root
232         rm -rf RESOURCES
233         mkdir RESOURCES
234         #enscript --language=rtf -o - < dat/license >RESOURCES/License.rtf
235         sys/unix/hints/macosx.sh descplist > RESOURCES/Description.plist
236         sys/unix/hints/macosx.sh infoplist > Info.plist
238         mkdir PKGROOT/Applications
239         #osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \
240         #        win/macosx/NetHackRecover.applescript
241         #cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir
242         osacompile -o PKGROOT/Applications/NetHackRecover.app \
243                  win/macosx/NetHackRecover.applescript
244         cp win/macosx/recover.pl $(PKGROOT_UGLN)
246         osacompile -o PKGROOT/Applications/NetHackTerm.app \
247                  win/macosx/NetHackTerm.applescript
249         # XXX integrate into Makefile.doc
250         (cd doc; cat Guidebook.mn | ../util/makedefs --grep --input - --output - \
251         | tbl tmac.n - | groff | pstopdf -i -o Guidebook.pdf)
252         cp doc/Guidebook.pdf $(PKGROOT_UG)/doc/NetHackGuidebook.pdf
254         osacompile -o PKGROOT/Applications/NetHackGuidebook.app \
255                  win/macosx/NetHackGuidebook.applescript
257         mkdir -p PKG
258         pkgbuild --root PKGROOT --identifier org.nethack.term --scripts PKGSCRIPTS PKG/NH-Term.pkg
259         productbuild --synthesize --product Info.plist --package PKG/NH-Term.pkg Distribution.xml
260         productbuild --distribution Distribution.xml --resources RESOURCES --package-path PKG NetHack-$(SVS)-mac-Term.pkg
261         hdiutil create -verbose -srcfolder NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg
263 build_package_root:
264         cd src/..       # make sure we are at TOP
265         rm -rf PKGROOT
266         mkdir -p $(PKGROOT_UG)/lib $(PKGROOT_BIN) $(PKGROOT_UG)/man/man6 $(PKGROOT_UG)/doc $(PKGROOT_UGLN)
267         install -p src/nethack $(PKGROOT_BIN)
268         # XXX should this be called nethackrecover?
269         install -p util/recover $(PKGROOT_BIN)
270         install -p doc/nethack.6 $(PKGROOT_UG)/man/man6
271         install -p doc/recover.6 $(PKGROOT_UG)/man/man6
272         install -p doc/Guidebook $(PKGROOT_UG)/doc
273         install -p dat/nhdat $(PKGROOT_UGLN)
274         sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(PKGROOT_UGLN)/sysconf
275         cd dat; install -p $(DATNODLB) ../$(PKGROOT_UGLN)
276 # XXX these files should be somewhere else for good Mac form
277         touch $(PKGROOT_UGLN)/perm $(PKGROOT_UGLN)/record $(PKGROOT_UGLN)/logfile $(PKGROOT_UGLN)/xlogfile
278         mkdir $(PKGROOT_UGLN)/save
279 # XXX what about a news file?
281         mkdir -p PKGSCRIPTS
282         echo '#!/bin/sh'                              >  PKGSCRIPTS/postinstall
283         echo dseditgroup -o create -r '"Games Group"' -s 3600 $(GAMEGRP) >> PKGSCRIPTS/postinstall
284         echo $(CHOWN) -R $(GAMEUID) $(HACKDIR)        >> PKGSCRIPTS/postinstall
285         echo $(CHGRP) -R $(GAMEGRP) $(HACKDIR)        >> PKGSCRIPTS/postinstall
286         echo $(CHOWN) $(GAMEUID) $(SHELLDIR)/nethack  >> PKGSCRIPTS/postinstall
287         echo $(CHGRP) $(GAMEGRP) $(SHELLDIR)/nethack  >> PKGSCRIPTS/postinstall
288         echo $(CHOWN) $(GAMEUID) $(SHELLDIR)/recover  >> PKGSCRIPTS/postinstall
289         echo $(CHGRP) $(GAMEGRP) $(SHELLDIR)/recover  >> PKGSCRIPTS/postinstall
290         echo chmod $(VARDIRPERM)  $(HACKDIR)          >> PKGSCRIPTS/postinstall
291         echo chmod $(VARDIRPERM)  $(HACKDIR)/save     >> PKGSCRIPTS/postinstall
292         echo chmod $(FILEPERM)    $(HACKDIR)/license  >> PKGSCRIPTS/postinstall
293         echo chmod $(FILEPERM)    $(HACKDIR)/nhdat    >> PKGSCRIPTS/postinstall
294         echo chmod $(FILEPERM)    $(HACKDIR)/symbols  >> PKGSCRIPTS/postinstall
295         echo chmod $(VARFILEPERM) $(HACKDIR)/perm     >> PKGSCRIPTS/postinstall
296         echo chmod $(VARFILEPERM) $(HACKDIR)/record   >> PKGSCRIPTS/postinstall
297         echo chmod $(VARFILEPERM) $(HACKDIR)/logfile  >> PKGSCRIPTS/postinstall
298         echo chmod $(VARFILEPERM) $(HACKDIR)/xlogfile >> PKGSCRIPTS/postinstall
299         echo chmod $(VARFILEPERM) $(HACKDIR)/sysconf  >> PKGSCRIPTS/postinstall
300         echo chmod $(GAMEPERM)   $(SHELLDIR)/nethack  >> PKGSCRIPTS/postinstall
301         echo chmod $(EXEPERM)    $(SHELLDIR)/recover  >> PKGSCRIPTS/postinstall
302         chmod 0775 PKGSCRIPTS/postinstall
304 endif   # end of build_tty_pkg
305 endif   # WANT_WIN_TTY for packaging
307 ifdef WANT_WIN_QT
308 # XXX untested and incomplete (see below)
309 build_qt_pkg:
310 ifneq (,$(WANT_WIN_X11)$(WANT_WIN_TTY))
311         -echo build_qt_pkg only works for a qt-only build
312         exit 1
313 else
314         $(MAKE) build_package_root
315         rm -rf NetHackQt
316         mkdir -p NetHackQt/NetHackQt.app/nethackdir/save
317         mkdir NetHackQt/Documentation
318         cp doc/Guidebook.txt doc/nethack.txt doc/recover.txt NetHackQt/Documentation
320         osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \
321                  win/macosx/NetHackRecover.applescript
322         cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir
324         mkdir -p NetHackQt/NetHackQt.app/Contents/Frameworks
325         cp $(QTDIR)/libqt-mt.3.dylib NetHackQt/NetHackQt.app/Contents/Frameworks
327         mkdir NetHackQt/NetHackQt.app/Contents/MacOS
328         mv PKGROOT/nethack NetHackQt/NetHackQt.app/Contents/MacOS
330         mv PKGROOT/lib/nethackdir NetHackQt/NetHackQt.app/nethackdir
332 # XXX still missing:
333 #NetHackQt/NetHackQt.app
334 # /Contents
335 #       Info.plist
336 #       Resources/nethack.icns
337 #NetHackQt/Documentation
338 #NetHackQtRecover.txt
339 #NetHack Defaults.txt
340 #changes.patch XXX is this still needed?  why isn't it part of the tree?
341 #  doesn't go here
342         hdiutil create -verbose -srcfolder NetHackQt NetHack-$(SVS)-macosx-qt.dmg
343 endif   # end of build_qt_pkg
344 endif   # WANT_WIN_QT for packaging
345 endif   # MAKEFILE_TOP