add new macOS target 'bundle'
This creates a new target 'bundle' for make on macOS, when using
sys/hints/macOS.370.
The 'bundle' recipe:
- creates a subdirectory of src called 'bundle', and creates
a bundle (nethack.app/ etc) below that.
- the executable that is placed inside the bundle
(bundle/nethack.app/Contents/MacOS/nethack) will find resources
within the bundle, including the sounds, so a manual placement
of the sounds into your '~/Library/Sounds' is no longer
required when using the executable that's inside the bundle.
- the sounds are included in the bundle if a soundlib option is
chose at build time (for example 'make WANT_MACSOUND=1'), such
that the bundled executable supports sounds.
- the executable inside the bundle seems to find the resources
it needs, even if invoked through a symlink elsewhere that points
to the executable that's inside the bundle (only limited testing of that
has been done).
- at some point, its probably appropriate to add a
'mv bundle/nethack.app <proper location>', possibly under
a subsequent 'make install' step.
- right now, the bundle step has a dependency on 'update'. I don't
know if that's the right ordering or not, yet.
make WANT_MACSOUND=1 update
make WANT_MACSOUND=1 bundle
or, you can probably get away with:
make WANT_MACSOUND=1 bundle
if the nethack bundle is the goal anyway.
make clean
will clear the bundle subdirectory and everything below it.
This commit is contained in:
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@@ -27,4 +27,5 @@ objtty/*
|
||||
objutil/*
|
||||
objlua/*
|
||||
objpdc/*
|
||||
bundle/*
|
||||
|
||||
|
||||
@@ -461,8 +461,9 @@ AT = $(AT_V$(QUIETCC))
|
||||
# verbosity-adjacent; these will already have 'real' values if hints have
|
||||
# set up cross-compiling, in which case these assignments will be no-ops
|
||||
PREGAME=@true
|
||||
CLEANMORE=@true
|
||||
PACKAGE=@true
|
||||
# Other hints add to this without an override, so don't completely overwrite it
|
||||
CLEANMORE+= true;
|
||||
|
||||
|
||||
MAKEDEFS = ../util/makedefs
|
||||
|
||||
@@ -252,7 +252,7 @@ GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
|
||||
endif
|
||||
ifdef GIT_BRANCH
|
||||
GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef WANT_LIBNH
|
||||
CFLAGS += -DSHIM_GRAPHICS -DNOTTYGRAPHICS -DNOSHELL -DLIBNH
|
||||
@@ -284,8 +284,11 @@ override LUA2NHTOP = ../..
|
||||
override LUAMAKEFLAGS=$(LUAFLAGS)
|
||||
endif # GITSUBMODULES
|
||||
|
||||
WANT_BUNDLE=1
|
||||
ifdef WANT_SHARE_INSTALL
|
||||
|
||||
#ifdef MAKEFILE_SRC
|
||||
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARE_INSTALL = $(WANT_SHARE_INSTALL))
|
||||
#endif
|
||||
# if $GAMEUID is root, we install into roughly proper Mac locations, otherwise
|
||||
# we install into ~/nethackdir
|
||||
ifeq ($(GAMEUID),root)
|
||||
@@ -319,6 +322,9 @@ POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/s
|
||||
|
||||
else ifdef WANT_SOURCE_INSTALL
|
||||
|
||||
#ifdef MAKEFILE_SRC
|
||||
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARE_INSTALL = $(WANT_SHARE_INSTALL))
|
||||
#endif
|
||||
PREFIX=$(abspath $(NHSROOT))
|
||||
# suppress nethack.sh
|
||||
#SHELLDIR=
|
||||
@@ -335,6 +341,9 @@ CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
|
||||
|
||||
else # !WANT_SOURCE_INSTALL
|
||||
|
||||
#ifdef MAKEFILE_SRC
|
||||
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARE_INSTALL = $(WANT_SHARE_INSTALL))
|
||||
#endif
|
||||
PREFIX:=$(wildcard ~)
|
||||
SHELLDIR=$(PREFIX)/bin
|
||||
HACKDIR=$(PREFIX)/nethackdir
|
||||
@@ -343,46 +352,24 @@ CHGRP=/usr/bin/true
|
||||
GAMEPERM = 0700
|
||||
VARFILEPERM = 0600
|
||||
VARDIRPERM = 0700
|
||||
|
||||
ifdef ($(WANT_DEFAULT),X11)
|
||||
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
|
||||
PREINSTALL= cp -n win/X11/nethack.rc ~/.nethackrc || true
|
||||
PREINSTALL+= cp -n win/X11/nethack.rc ~/.nethackrc || true;
|
||||
endif # WANT_DEFAULT X11
|
||||
|
||||
PREINSTALL+= mkdir $(SHELLDIR);
|
||||
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; \
|
||||
$(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; \
|
||||
$(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; \
|
||||
chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
|
||||
ifdef WANT_BUNDLE
|
||||
#
|
||||
# Bundle
|
||||
#
|
||||
# $(HACKDIR)/$(GAME).app/
|
||||
# Contents/
|
||||
# Frameworks/
|
||||
# Info.plist
|
||||
# MacOS/
|
||||
# $(GAME)
|
||||
# PkgInfo/
|
||||
# PlugIns/
|
||||
# Resources/
|
||||
# SharedFrameWorks/
|
||||
#
|
||||
BUNDLE = mkdir -p $(HACKDIR)/nethack.app/Contents/MacOS; \
|
||||
sys/unix/hints/macosx.sh infoplist > $(HACKDIR)/nethack.app/Contents/Info.plist; \
|
||||
mv $(HACKDIR)/nethack $(HACKDIR)/nethack.app/Contents/MacOS/nethack;
|
||||
ifdef WANT_SHARE_INSTALL
|
||||
BUNDLE+= chmod $(GAMEPERM) $(HACKDIR)/nethack.app/Contents/MacOS/nethack;
|
||||
endif
|
||||
|
||||
POSTINSTALL+= $(BUNDLE)
|
||||
POSTINSTALL+= if test -f $(SHELLDIR)/$(GAME); then \
|
||||
sed -i '' 's;HACKDIR/$(GAME);HACKDIR/$(GAME).app/Contents/MacOS/$(GAME);' $(SHELLDIR)/$(GAME) ; fi;
|
||||
endif # WANT_BUNDLE
|
||||
endif # !WANT_SHARE_INSTALL
|
||||
|
||||
INSTDIR=$(HACKDIR)
|
||||
VARDIR=$(HACKDIR)
|
||||
|
||||
|
||||
# ~/Library/Preferences/NetHack Defaults
|
||||
# OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp
|
||||
# OPTIONS=hilite_pet,toptenwin,msghistory:200,windowtype:Qt
|
||||
@@ -399,6 +386,60 @@ VARDIR=$(HACKDIR)
|
||||
#-INCLUDE multisnd2-pre.370
|
||||
#
|
||||
|
||||
ifndef MAKEFILE_UTL
|
||||
.PHONY: bundle
|
||||
endif
|
||||
ifdef MAKEFILE_SRC
|
||||
.PHONY: updatescript
|
||||
abspath := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
ABSBUNDLEPATH := $(dir $(abspath))
|
||||
#$(info ABSBUNDLEPATH=$(ABSBUNDLEPATH)bundle)
|
||||
endif # MAKEFILE_SRC
|
||||
|
||||
ifdef MAKEFILE_SRC
|
||||
ifdef WANT_BUNDLE
|
||||
#
|
||||
# bundle
|
||||
#
|
||||
# $(HACKDIR)/$(GAME).app/
|
||||
# Contents/
|
||||
# Frameworks/
|
||||
# Info.plist
|
||||
# MacOS/
|
||||
# $(GAME)
|
||||
# PkgInfo/
|
||||
# PlugIns/
|
||||
# Resources/
|
||||
# SharedFrameWorks/
|
||||
#
|
||||
BUNDLE_TOP = bundle/$(GAME).app
|
||||
BUNDLE_CONTENTSDIR = $(BUNDLE_TOP)/Contents
|
||||
BUNDLE_FRAMEWORKSDIR = $(BUNDLE_CONTENTSDIR)/Frameworks
|
||||
BUNDLE_MACOSDIR = $(BUNDLE_CONTENTSDIR)/MacOS
|
||||
BUNDLE_PKGINFODIR = $(BUNDLE_CONTENTSDIR)/PkgInfo
|
||||
BUNDLE_PLUGINSDIR = $(BUNDLE_CONTENTSDIR)/PlugIns
|
||||
BUNDLE_RESOURCESDIR = $(BUNDLE_CONTENTSDIR)/Resources
|
||||
BUNDLE_SHAREDFRAMEWORKSDIR = $(BUNDLE_CONTENTSDIR)/SharedFrameworks
|
||||
BUNDLE_INFOPLIST = $(BUNDLE_CONTENTSDIR)/Info.plist
|
||||
BUNDLE_GAME = $(BUNDLE_MACOSDIR)/$(GAME)
|
||||
BUNDLE = bundle
|
||||
ifdef NEEDS_WAV
|
||||
BUNDLEWAVS = $(addprefix $(BUNDLE_RESOURCESDIR)/, $(addsuffix .wav, $(SNDWAVS)))
|
||||
BUNDLE_WAV = bundlewav
|
||||
endif
|
||||
BUNDLELIST = $(BUNDLE_TOP) $(BUNDLE_CONTENTSDIR) $(BUNDLE_FRAMEWORKSDIR) \
|
||||
$(BUNDLE_MACOSDIR) $(BUNDLE_PKGINFODIR) $(BUNDLE_PLUGINSDIR) \
|
||||
$(BUNDLE_RESOURCESDIR) $(BUNDLE_SHAREDFRMEWORKSDIR) \
|
||||
$(BUNDLE_INFOPLIST) $(BUNDLE_GAME) $(BUNDLE_WAV)
|
||||
endif # WANT_BUNDLE
|
||||
#
|
||||
# We include the bundle outside of a WANT_BUNDLE block because
|
||||
# it is unlikely that anyone will use 'make WANT_BUNDLE=1 clean'
|
||||
#
|
||||
CLEANMORE += rm -rf bundle ;
|
||||
endif # MAKEFILE_SRC
|
||||
|
||||
#
|
||||
#-POST
|
||||
|
||||
#
|
||||
@@ -418,6 +459,73 @@ $(TARGETPFX)winshim.o : ../win/shim/winshim.c $(HACK_H)
|
||||
$(CC) $(CFLAGS) -c -o$@ $<
|
||||
endif # WANT_LIBNH
|
||||
|
||||
# -- bundle ---
|
||||
#
|
||||
ifdef MAKEFILE_TOP
|
||||
bundle: update
|
||||
( cd src ; $(MAKE) WANT_BUNDLE=1 bundle )
|
||||
|
||||
endif # MAKEFILE_TOP
|
||||
ifdef WANT_BUNDLE
|
||||
ifdef MAKEFILE_SRC
|
||||
|
||||
bundle: $(BUNDLELIST) $(BUNDLE_GAME) $(BUNDLE_WAV) updatescript
|
||||
@echo $(GAME) bundle : $(ABSBUNDLEPATH)$(BUNDLE_TOP)
|
||||
@echo $(GAME) game : $(ABSBUNDLEPATH)$(BUNDLE_GAME)
|
||||
|
||||
$(BUNDLE_RESOURCESDIR)/%.wav: ../sound/wav/%.wav | $(BUNDLE_RESOURCESDIR)
|
||||
cp $< $@
|
||||
|
||||
bundlewav: $(BUNDLEWAVS)
|
||||
|
||||
$(BUNDLE_TOP):
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_CONTENTSDIR): $(BUNDLE_TOP)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_FRAMEWORKSDIR): $(BUNDLE_CONTENTSDIR)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_MACOSDIR): $(BUNDLE_CONTENTSDIR)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_PKGINFODIR): $(BUNDLE_CONTENTSDIR)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_PLUGINSDIR): $(BUNDLE_CONTENTSDIR)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_RESOURCESDIR): $(BUNDLE_CONTENTSDIR)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_SHAREDFRAMEWORKSDIR): $(BUNDLE_CONTENTSDIR)
|
||||
mkdir -p $@
|
||||
|
||||
$(BUNDLE_GAME): $(BUNDLE_MACOSDIR) $(GAMEBIN)
|
||||
cp $(GAMEBIN) $@
|
||||
#ifdef WANT_SHARE_INSTALL
|
||||
# chmod $(GAMEPERM) $@
|
||||
#endif
|
||||
|
||||
$(BUNDLE_INFOPLIST): ../sys/unix/hints/macosx.sh
|
||||
( cd .. && sys/unix/hints/macosx.sh infoplist >src/$@ && cd src)
|
||||
|
||||
updatescript:
|
||||
ifneq "$(SHELLDIR)" ""
|
||||
if test -f $(SHELLDIR)/$(GAME); then \
|
||||
cp $(SHELLDIR)/$(GAME) $(GAME).tmp; \
|
||||
sed -i '' 's;\$$HACKDIR/$(GAME);$(ABSBUNDLEPATH)$(BUNDLE_GAME);' $(SHELLDIR)/$(GAME) ; \
|
||||
diff -u $(GAME).tmp $(SHELLDIR)/$(GAME) | grep "="; \
|
||||
rm -f $(GAME).tmp; \
|
||||
fi;
|
||||
endif
|
||||
endif # MAKEFILE_SRC
|
||||
endif # WANT_BUNDLE
|
||||
|
||||
#
|
||||
# --- end of bundle ---
|
||||
#
|
||||
#
|
||||
#-INCLUDE cross-post.370
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user