1# 2# NetHack 3.7 macosx10.10-qt $NHDT-Date: 1597704795 2020/08/17 22:53:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.63 $ 3# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. 4# NetHack may be freely redistributed. See license for details. 5# 6#-PRE 7# Mac OS X (Darwin) hints file 8# This is for the Qt interface on Mac OS X 10.10 through 10.13, and has 9# been tested on 10.11 (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 13 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.) 16 17# This hints file can build several different types of installations. 18# Edit the next section to match the type of build you need. 19 20# 1. Which window system(s) should be included in this binary? 21WANT_WIN_TTY=1 22#WANT_WIN_X11=1 23WANT_WIN_QT=1 24 25# 1a. What is the default window system? 26#WANT_DEFAULT=tty 27#WANT_DEFAULT=X11 28WANT_DEFAULT=Qt 29 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 Qt5 32# library installation root. (Qt2 or Qt3 will not work.) 33ifdef WANT_WIN_QT 34# Qt installed via homebrew 35QTDIR=$(shell brew --prefix)/opt/qt 36# Qt installed via macports (qt511 package; 5.13 requires OSX 10.12 or later) 37#QTDIR=/opt/local/libexec/qt5 38endif # WANT_WIN_QT 39 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 54GAMEUID = $(USER) 55GAMEGRP = games 56# build to run in the source tree - primarily for development. Build with "make all" 57#WANT_SOURCE_INSTALL=1 58 59CC=clang 60CXX=clang++ -std=gnu++11 61 62# At the moment this is just for debugging, but in the future it could be 63# useful for other things. Requires SYSCF and an ANSI compiler. 64#WANT_WIN_CHAIN=1 65 66# 67# You shouldn't need to change anything below here. 68# 69 70ifdef WANT_WIN_QT 71LINK = $(CXX) 72else 73LINK = $(CC) 74endif 75 76#CFLAGS+=-W -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -DGCC_WARN 77CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings -DGCC_WARN 78ifndef WANT_WIN_QT 79# these are normally used when compiling nethack's core 80CFLAGS+=-ansi -pedantic -Wno-long-long 81# but -ansi -pendantic forces C90 sematics and win/Qt/qt_*.cpp trigger 82#In file included from .../qt5/include/QtCore/qglobal.h:105: 83#.../qt5/include/QtCore/qcompilerdetection.h:561:6: 84# error Qt requires a C++11 compiler and yours does not seem to be that. 85# so we suppress them when the build includes Qt 86endif 87# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so 88# leave it out by default. 89#CFLAGS+=-Wunreachable-code 90 91# XXX -g vs -O should go here, -I../include goes in the makefile 92CFLAGS+=-g -I../include 93# older binaries use NOCLIPPING, but that disables SIGWINCH 94#CFLAGS+=-DNOCLIPPING 95CFLAGS+= -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\" 96CFLAGS+= -DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\" -DDLB 97 98CFLAGS+= -DGREPPATH=\"/usr/bin/grep\" 99 100ifdef WANT_WIN_CHAIN 101CFLAGS+= -DWINCHAIN 102HINTSRC=$(CHAINSRC) 103HINTOBJ=$(CHAINOBJ) 104endif 105 106WINSRC = 107WINOBJ0 = 108WINLIB = 109VARDATND = 110 111ifdef WANT_WIN_TTY 112WINSRC += $(WINTTYSRC) 113WINOBJ0 += $(WINTTYOBJ) 114WINLIB += $(WINTTYLIB) 115WINTTYLIB=-lncurses 116else # !WANT_WIN_TTY 117CFLAGS += -DNOTTYGRAPHICS 118endif # !WANT_WIN_TTY 119 120ifdef WANT_WIN_X11 121WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11 122VARDATND0 = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm 123# -x: if built without dlb, some versions of mkfontdir think *.lev are fonts 124POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev ); 125CFLAGS += -DX11_GRAPHICS 126# separate from CFLAGS so that we don't pass it to every file 127X11CFLAGS = -I/opt/X11/include 128# avoid repeated complaints about _X_NONNULL(args...) in <X11/Xfuncproto.h> 129X11CFLAGS += -Wno-variadic-macros 130ifdef USE_XPM 131CFLAGS += -DUSE_XPM 132WINX11LIB += -lXpm 133VARDATND0 += rip.xpm 134endif 135WINSRC += $(WINX11SRC) 136WINOBJ0 += $(WINX11OBJ) 137WINLIB += $(WINX11LIB) 138LFLAGS=-L/opt/X11/lib 139endif # WANT_WIN_X11 140 141ifdef WANT_WIN_QT 142CFLAGS += -DQT_GRAPHICS -DNOUSER_SOUNDS 143QTCXXFLAGS += -Wno-deprecated-declarations 144QTCXXFLAGS += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags) 145WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs) 146WINSRC += $(WINQTSRC) 147WINOBJ0 += $(WINQTOBJ) 148VARDATND0 = nhtiles.bmp rip.xpm nhsplash.xpm 149MOC = moc 150 151# XXX if /Developer/qt exists and QTDIR not set, use that 152ifndef QTDIR 153$(error QTDIR not defined in the environment or Makefile) 154endif # QTDIR 155# XXX make sure QTDIR points to something reasonable 156endif # WANT_WIN_QT 157 158# prevent duplicate tile.o in WINOBJ 159WINOBJ = $(sort $(WINOBJ0)) 160# also prevent duplicate data files if both X11 and Qt are being supported 161VARDATND+= $(sort $(VARDATND0)) 162 163ifdef WANT_SHARE_INSTALL 164# if $GAMEUID is root, we install into roughly proper Mac locations, otherwise 165# we install into ~/nethackdir 166ifeq ($(GAMEUID),root) 167PREFIX:=/Library/NetHack 168SHELLDIR=/usr/local/bin 169HACKDIR=$(PREFIX)/nethackdir 170CHOWN=chown 171CHGRP=chgrp 172# We run sgid so the game has access to both HACKDIR and user preferences. 173GAMEPERM = 02755 174else # ! root 175PREFIX:=/Users/$(GAMEUID) 176SHELLDIR=$(PREFIX)/bin 177HACKDIR=$(PREFIX)/Library/NetHack/nethackdir 178CHOWN=/usr/bin/true 179CHGRP=/usr/bin/true 180GAMEPERM = 0500 181endif # ! root 182VARFILEPERM = 0664 183VARDIRPERM = 0775 184ROOTCHECK= [[ `id -u` == 0 ]] || ( echo "Must run install with sudo."; exit 1) 185# XXX it's nice we don't write over sysconf, but we've already erased it 186# make sure we have group GAMEUID and group GAMEGRP 187PREINSTALL= . sys/unix/hints/macosx.sh user2 $(GAMEUID); . sys/unix/hints/macosx.sh group2 $(GAMEGRP); mkdir $(SHELLDIR); chown $(GAMEUID) $(SHELLDIR) 188POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf; 189CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE 190else ifdef WANT_SOURCE_INSTALL 191PREFIX=$(abspath $(NHSROOT)) 192# suppress nethack.sh 193#SHELLDIR= 194HACKDIR=$(PREFIX)/playground 195CHOWN=/usr/bin/true 196CHGRP=/usr/bin/true 197GAMEPERM = 0700 198VARFILEPERM = 0600 199VARDIRPERM = 0700 200POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; 201# We can use "make all" to build the whole thing - but it misses some things: 202MOREALL=$(MAKE) install 203CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE 204else # !WANT_SOURCE_INSTALL 205PREFIX:=$(wildcard ~) 206SHELLDIR=$(PREFIX)/bin 207HACKDIR=$(PREFIX)/nethackdir 208CHOWN=/usr/bin/true 209CHGRP=/usr/bin/true 210GAMEPERM = 0700 211VARFILEPERM = 0600 212VARDIRPERM = 0700 213ifdef WANT_WIN_X11 214# install nethack.rc as ~/.xnethackrc if no ~/.xnethackrc exists 215PREINSTALL= cp -n win/X11/nethack.rc ~/.xnethackrc || true 216endif # WANT_WIN_X11 217POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; chmod $(VARFILEPERM) $(HACKDIR)/sysconf; 218CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE 219endif # !WANT_SOURCE_INSTALL 220 221INSTDIR=$(HACKDIR) 222VARDIR=$(HACKDIR) 223 224 225# ~/Library/Preferences/NetHack Defaults 226# OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp 227# OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt 228# 229# Install.Qt mentions a patch for macos - it's not there (it seems to be in the Qt binary 230# package under the docs directory). 231 232#-POST 233ifdef MAKEFILE_TOP 234### 235### Packaging 236### 237# Notes: 238# 1) The Apple developer utilities must be installed in the default location. 239# 2) Do a normal build before trying to package the game. 240# 3) This matches the 3.4.3 Term package, but there are some things that should 241# be changed. 242 243ifdef WANT_WIN_TTY 244DEVUTIL=/Developer/Applications/Utilities 245SVS=$(shell $(NHSROOT)/util/makedefs --svs) 246SVSDOT=$(shell $(NHSROOT)/util/makedefs --svs .) 247 248PKGROOT_UG = PKGROOT/$(PREFIX) 249PKGROOT_UGLN = PKGROOT/$(HACKDIR) 250PKGROOT_BIN = PKGROOT/$(SHELLDIR) 251build_tty_pkg: 252ifneq (,$(WANT_WIN_X11)$(WANT_WIN_QT)) 253 -echo build_tty_pkg only works for a tty-only build 254 exit 1 255else 256 rm -rf NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg 257 $(MAKE) build_package_root 258 rm -rf RESOURCES 259 mkdir RESOURCES 260 #enscript --language=rtf -o - < dat/license >RESOURCES/License.rtf 261 sys/unix/hints/macosx.sh descplist > RESOURCES/Description.plist 262 sys/unix/hints/macosx.sh infoplist > Info.plist 263 264 mkdir PKGROOT/Applications 265 #osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \ 266 # win/macosx/NetHackRecover.applescript 267 #cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir 268 osacompile -o PKGROOT/Applications/NetHackRecover.app \ 269 win/macosx/NetHackRecover.applescript 270 cp win/macosx/recover.pl $(PKGROOT_UGLN) 271 272 osacompile -o PKGROOT/Applications/NetHackTerm.app \ 273 win/macosx/NetHackTerm.applescript 274 275 # XXX integrate into Makefile.doc 276 (cd doc; cat Guidebook.mn | ../util/makedefs --grep --input - --output - \ 277 | tbl tmac.n - | groff | pstopdf -i -o Guidebook.pdf) 278 cp doc/Guidebook.pdf $(PKGROOT_UG)/doc/NetHackGuidebook.pdf 279 280 osacompile -o PKGROOT/Applications/NetHackGuidebook.app \ 281 win/macosx/NetHackGuidebook.applescript 282 283 mkdir -p PKG 284 pkgbuild --root PKGROOT --identifier org.nethack.term --scripts PKGSCRIPTS PKG/NH-Term.pkg 285 productbuild --synthesize --product Info.plist --package PKG/NH-Term.pkg Distribution.xml 286 productbuild --distribution Distribution.xml --resources RESOURCES --package-path PKG NetHack-$(SVS)-mac-Term.pkg 287 hdiutil create -verbose -srcfolder NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg 288 289build_package_root: 290 cd src/.. # make sure we are at TOP 291 rm -rf PKGROOT 292 mkdir -p $(PKGROOT_UG)/lib $(PKGROOT_BIN) $(PKGROOT_UG)/man/man6 $(PKGROOT_UG)/doc $(PKGROOT_UGLN) 293 install -p src/nethack $(PKGROOT_BIN) 294 # XXX should this be called nethackrecover? 295 install -p util/recover $(PKGROOT_BIN) 296 install -p doc/nethack.6 $(PKGROOT_UG)/man/man6 297 install -p doc/recover.6 $(PKGROOT_UG)/man/man6 298 install -p doc/Guidebook $(PKGROOT_UG)/doc 299 install -p dat/nhdat $(PKGROOT_UGLN) 300 sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(PKGROOT_UGLN)/sysconf 301 cd dat; install -p $(DATNODLB) ../$(PKGROOT_UGLN) 302# XXX these files should be somewhere else for good Mac form 303 touch $(PKGROOT_UGLN)/perm $(PKGROOT_UGLN)/record $(PKGROOT_UGLN)/logfile $(PKGROOT_UGLN)/xlogfile 304 mkdir $(PKGROOT_UGLN)/save 305# XXX what about a news file? 306 307 mkdir -p PKGSCRIPTS 308 echo '#!/bin/sh' > PKGSCRIPTS/postinstall 309 echo dseditgroup -o create -r '"Games Group"' -s 3600 $(GAMEGRP) >> PKGSCRIPTS/postinstall 310 echo $(CHOWN) -R $(GAMEUID) $(HACKDIR) >> PKGSCRIPTS/postinstall 311 echo $(CHGRP) -R $(GAMEGRP) $(HACKDIR) >> PKGSCRIPTS/postinstall 312 echo $(CHOWN) $(GAMEUID) $(SHELLDIR)/nethack >> PKGSCRIPTS/postinstall 313 echo $(CHGRP) $(GAMEGRP) $(SHELLDIR)/nethack >> PKGSCRIPTS/postinstall 314 echo $(CHOWN) $(GAMEUID) $(SHELLDIR)/recover >> PKGSCRIPTS/postinstall 315 echo $(CHGRP) $(GAMEGRP) $(SHELLDIR)/recover >> PKGSCRIPTS/postinstall 316 echo chmod $(VARDIRPERM) $(HACKDIR) >> PKGSCRIPTS/postinstall 317 echo chmod $(VARDIRPERM) $(HACKDIR)/save >> PKGSCRIPTS/postinstall 318 echo chmod $(FILEPERM) $(HACKDIR)/license >> PKGSCRIPTS/postinstall 319 echo chmod $(FILEPERM) $(HACKDIR)/nhdat >> PKGSCRIPTS/postinstall 320 echo chmod $(FILEPERM) $(HACKDIR)/symbols >> PKGSCRIPTS/postinstall 321 echo chmod $(VARFILEPERM) $(HACKDIR)/perm >> PKGSCRIPTS/postinstall 322 echo chmod $(VARFILEPERM) $(HACKDIR)/record >> PKGSCRIPTS/postinstall 323 echo chmod $(VARFILEPERM) $(HACKDIR)/logfile >> PKGSCRIPTS/postinstall 324 echo chmod $(VARFILEPERM) $(HACKDIR)/xlogfile >> PKGSCRIPTS/postinstall 325 echo chmod $(VARFILEPERM) $(HACKDIR)/sysconf >> PKGSCRIPTS/postinstall 326 echo chmod $(GAMEPERM) $(SHELLDIR)/nethack >> PKGSCRIPTS/postinstall 327 echo chmod $(EXEPERM) $(SHELLDIR)/recover >> PKGSCRIPTS/postinstall 328 chmod 0775 PKGSCRIPTS/postinstall 329 330endif # end of build_tty_pkg 331endif # WANT_WIN_TTY for packaging 332 333ifdef WANT_WIN_QT 334# XXX untested and incomplete (see below) 335build_qt_pkg: 336ifneq (,$(WANT_WIN_X11)$(WANT_WIN_TTY)) 337 -echo build_qt_pkg only works for a qt-only build 338 exit 1 339else 340 $(MAKE) build_package_root 341 rm -rf NetHackQt 342 mkdir -p NetHackQt/NetHackQt.app/nethackdir/save 343 mkdir NetHackQt/Documentation 344 cp doc/Guidebook.txt doc/nethack.txt doc/recover.txt NetHackQt/Documentation 345 346 osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \ 347 win/macosx/NetHackRecover.applescript 348 cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir 349 350 mkdir -p NetHackQt/NetHackQt.app/Contents/Frameworks 351 cp $(QTDIR)/libqt-mt.3.dylib NetHackQt/NetHackQt.app/Contents/Frameworks 352 353 mkdir NetHackQt/NetHackQt.app/Contents/MacOS 354 mv PKGROOT/nethack NetHackQt/NetHackQt.app/Contents/MacOS 355 356 mv PKGROOT/lib/nethackdir NetHackQt/NetHackQt.app/nethackdir 357 358# XXX still missing: 359#NetHackQt/NetHackQt.app 360# /Contents 361# Info.plist 362# Resources/nethack.icns 363#NetHackQt/Documentation 364#NetHackQtRecover.txt 365#NetHack Defaults.txt 366#changes.patch XXX is this still needed? why isn't it part of the tree? 367# doesn't go here 368 hdiutil create -verbose -srcfolder NetHackQt NetHack-$(SVS)-macosx-qt.dmg 369endif # end of build_qt_pkg 370endif # WANT_WIN_QT for packaging 371endif # MAKEFILE_TOP 372