OSDN Git Service

Merge branch 'develop' into macos-develop
[hengbandforosx/hengbandosx.git] / src / Makefile.am
index 625e1b6..dab6a03 100644 (file)
@@ -1042,26 +1042,122 @@ EXTRA_hengband_SOURCES = \
        main-win/main-win-tokenizer.cpp main-win/main-win-tokenizer.h \
        main-win/main-win-utils.cpp main-win/main-win-utils.h \
        main-win/wav-reader.cpp main-win/wav-reader.h \
+       main-cap.cpp \
        wall.bmp \
        stdafx.cpp stdafx.h
 
+cocoa_xcode_files = \
+       cocoa/AppDelegate.m \
+       cocoa/Base.lproj/MainMenu.xib \
+       cocoa/Base.lproj/SoundAndMusic.xib
+cocoa_icon_files = \
+       cocoa/hengband_Icons.icns \
+       cocoa/Save.icns \
+       cocoa/Edit.icns \
+       cocoa/Data.icns
+cocoa_plist_template = cocoa/Angband-Cocoa.xml
+cocoa_plist_strings_template = cocoa/Angband-Cocoa.strings
+cocoa_plist_files = \
+       cocoa/CommandMenu.plist
+cocoa_en_nib_files = \
+       cocoa/Base.lproj/MainMenu.nib \
+       cocoa/Base.lproj/SoundAndMusic.nib
+cocoa_en_strings_files = \
+       cocoa/en.lproj/Localizable.strings \
+       cocoa/en.lproj/CommandMenu.strings \
+       cocoa/en.lproj/GraphicsMenu.strings
+cocoa_ja_strings_files = \
+       cocoa/ja.lproj/MainMenu.strings \
+       cocoa/ja.lproj/SoundAndMusic.strings \
+       cocoa/ja.lproj/Localizable.strings \
+       cocoa/ja.lproj/CommandMenu.strings \
+       cocoa/ja.lproj/GraphicsMenu.strings
+
 EXTRA_DIST = \
-       gcc-wrap
+       gcc-wrap \
+       $(cocoa_xcode_files) \
+       $(cocoa_icon_files) \
+       $(cocoa_plist_template) \
+       $(cocoa_plist_strings_template) \
+       $(cocoa_plist_files) \
+       $(cocoa_en_nib_files) \
+       $(cocoa_en_strings_files) \
+       $(cocoa_ja_strings_files)
 
-DEFAULT_INCLUDES = -I$(srcdir) -I$(top_builddir)/src
-CPPFLAGS += $(XFT_CFLAGS) $(libcurl_CFLAGS)
-if PCH
-CPPFLAGS += -include ../src/stdafx.h
+if COCOA
+hengband_SOURCES += \
+       main-cocoa.mm \
+       system/grafmode.h \
+       system/grafmode.cpp \
+       cocoa/AppDelegate.h \
+       cocoa/AngbandAudio.h \
+       cocoa/AngbandAudio.mm \
+       cocoa/SoundAndMusic.h \
+       cocoa/SoundAndMusic.mm
+AM_CFLAGS = -mmacosx-version-min=10.15 -Wunguarded-availability
+AM_OBJCXXFLAGS = -std=c++20 -fobjc-arc -mmacosx-version-min=10.15 -Wunguarded-availability -stdlib=libc++
+AM_CXXFLAGS = -mmacosx-version-min=10.15 -Wunguarded-availability -stdlib=libc++
+hengband_LDFLAGS = -framework cocoa -framework AVFoundation $(AM_LDFLAGS)
+hengband_LINK = MACOSX_DEPLOYMENT_TARGET=10.15 $(OBJCXXLINK) $(hengband_LDFLAGS) $(LDFLAGS) -o $@
+APPNAME = $(PACKAGE_NAME)
+APPEXE = hengband
+APPDIR = $(APPNAME).app
+BUNDLE_IDENTIFIER = jp.osdn.hengband
+BUNDLE_VERSION = $(PACKAGE_VERSION)
+BUNDLE_DISPLAY_NAME = $(APPNAME)
+BUNDLE_NAME = $(BUNDLE_DISPLAY_NAME)
+BUNDLE_DISPLAY_NAME_JA = 変愚蛮怒
+BUNDLE_NAME_JA = $(BUNDLE_DISPLAY_NAME_JA)
+# Be careful with characters (like '&') in the copyright that have special
+# meanings to sed.
+COPYRIGHT = Copyright © Mr. Hoge and many others
+# For now, using the line that appears in news_j.txt.  Is that appropriate?
+# The ampersand is a kanji so it doesn't seem to be treated as a special
+# character by sed.
+COPYRIGHT_JA = Mr.hoge (echizen@users.sourceforge.jp) & 多くの方々
+APPBNDL = $(bindir)/$(APPDIR)
+APPCONT = $(APPBNDL)/Contents
+APPBIN = $(APPCONT)/MacOS
+APPRES = $(APPCONT)/Resources
+appbin_PROGRAMS = $(APPEXE)
+appbindir = $(APPBIN)
+dist_appicon_DATA = $(cocoa_icon_files)
+appicondir = $(APPRES)
+appplist_DATA = $(cocoa_plist_files)
+appplistdir = $(APPRES)
+appennib_DATA = $(cocoa_en_nib_files)
+appennibdir = $(APPRES)/Base.lproj
+appen_DATA = $(cocoa_en_strings_files)
+appendir = $(APPRES)/en.lproj
+appja_DATA = $(cocoa_ja_strings_files)
+appjadir = $(APPRES)/ja.lproj
+else
+EXTRA_hengband_SOURCES += main-cocoa.mm system/grafmode.h system/grafmode.cpp \
+       cocoa/AppDelegate.h
+hengband_LINK = $(CXXLINK)
 endif
+
+# The "-I$(top_builddir)/src/cocoa" is there so can use the same include
+# directives in the cocoa/*.{h,mm} files when building here or rebuilding the
+# nib files in Xcode according to the procedure in cocoa/AppDelegate.m.
+DEFAULT_INCLUDES = -I$(srcdir) -I$(top_builddir)/src -I$(top_builddir)/src/cocoa
+CPPFLAGS += $(XFT_CFLAGS) $(libcurl_CFLAGS)
 LIBS += $(XFT_LIBS) $(libcurl_LIBS)
 COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+OBJCXXCOMPILE = $(srcdir)/gcc-wrap $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) \
+       $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS)
 CXXCOMPILE = $(srcdir)/gcc-wrap $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CXXFLAGS)
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
 
 if PCH
+# Would use CPPFLAGS, but that affects both the C++ and Objective-C++
+# preprocessing:  don't want to use the precompiled header for the
+# Objective-C++ code.
+CXXCOMPILE += -include ../src/stdafx.h
+
 stdafx.h.gch: stdafx.h stdafx.cpp Makefile
-       $(CXX) -x c++-header $(CXXFLAGS) $(srcdir)/stdafx.cpp -o $@
+       $(CXX) -x c++-header $(CXXFLAGS) $(AM_CXXFLAGS) $(srcdir)/stdafx.cpp -o $@
        if test none != "$(PCH_CHECKSUMMER)" ; then \
                rm -f "$@".sum ; \
                $(PCH_CHECKSUMMER) $@ > "$@".sum ; \
@@ -1076,6 +1172,51 @@ if SET_GID
        chmod g+s "$(DESTDIR)$(bindir)/hengband"
 endif
 
+if COCOA
+# Suppress the warnings from the EUC-JP encoded strings used when building
+# the Japanese version.
+AM_CFLAGS += -Wno-invalid-source-encoding
+AM_CXXFLAGS += -Wno-invalid-source-encoding
+AM_OBJCXXFLAGS += -Wno-invalid-source-encoding
+
+# Create lib/info within the application bundle since not currently
+# installing anything to it.  Other relevant lib directories should
+# be created from the Makefiles in the lib directory.
+install-data-local:
+       @mkdir -p $(APPCONT)
+       @mkdir -p $(appendir)
+       @mkdir -p $(appjadir)
+       @mkdir -p $(APPRES)/lib/info
+       sed -e 's/\$$VERSION\$$/$(PACKAGE_VERSION)/' \
+               -e 's/\$$COPYRIGHT\$$/$(COPYRIGHT)/' \
+               -e 's/\$$NAME\$$/$(APPNAME)/' \
+               -e 's/\$$EXECUTABLE\$$/$(APPEXE)/' \
+               -e 's/\$$BUNDLE_VERSION\$$/$(BUNDLE_VERSION)/' \
+               -e 's/\$$BUNDLE_IDENTIFIER\$$/$(BUNDLE_IDENTIFIER)/' \
+               -e 's/\$$BUNDLE_DISPLAY_NAME\$$/$(BUNDLE_DISPLAY_NAME)/' \
+               -e 's/\$$BUNDLE_NAME\$$/$(BUNDLE_NAME)/' \
+               $(srcdir)/$(cocoa_plist_template) > $(APPCONT)/Info.plist
+       sed -e 's/\$$VERSION\$$/$(PACKAGE_VERSION)/' \
+               -e 's/\$$COPYRIGHT\$$/$(COPYRIGHT)/' \
+               -e 's/\$$BUNDLE_DISPLAY_NAME\$$/$(BUNDLE_DISPLAY_NAME)/' \
+               -e 's/\$$BUNDLE_NAME\$$/$(BUNDLE_NAME)/' \
+               $(srcdir)/$(cocoa_plist_strings_template) > $(appendir)/InfoPlist.strings
+       sed -e 's/\$$VERSION\$$/$(PACKAGE_VERSION)/' \
+               -e 's/\$$COPYRIGHT\$$/$(COPYRIGHT_JA)/' \
+               -e 's/\$$BUNDLE_DISPLAY_NAME\$$/$(BUNDLE_DISPLAY_NAME_JA)/' \
+               -e 's/\$$BUNDLE_NAME\$$/$(BUNDLE_NAME_JA)/' \
+               $(srcdir)/$(cocoa_plist_strings_template) > $(appjadir)/InfoPlist.strings
+
+uninstall-local:
+       -rm $(APPCONT)/Info.plist
+       -rm $(appendir)/InfoPlist.strings
+       -rm $(appjadir)/InfoPlist.strings
+
+endif
+
+distclean-local:
+       -rm -r -f $(DEPDIR) */$(DEPDIR) */*/$(DEPDIR)
+
 clean-local:
        -rm stdafx.h.gch stdafx.h.gch.sum
        -rm -rf ../build