OSDN Git Service

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