OSDN Git Service

Merge branch 'develop' of github.com:hengband/hengband into macos-develop
[hengbandforosx/hengbandosx.git] / configure.ac
1 ,dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(hengband, 3.0.0.0)
3
4 AC_CONFIG_MACRO_DIRS([m4])
5 AC_CONFIG_HEADERS(src/autoconf.h)
6 AC_CONFIG_SRCDIR(src/main.cpp)
7 AM_INIT_AUTOMAKE
8
9 AC_ARG_WITH(setgid,
10 [  --with-setgid=NAME      install hengband as group NAME],
11 [case "${withval}" in
12   no) GAMEGROUP="";;
13   yes) AC_MSG_ERROR(missing argument for --with-setgid);;
14   *) GAMEGROUP="$withval";;
15 esac])
16 AC_SUBST(GAMEGROUP)
17 AM_CONDITIONAL(SET_GID, test "$GAMEGROUP" != "")
18
19 dnl generate the installation path for the ./lib/ folder
20 if test "$GAMEGROUP" != ""; then
21   MY_EXPAND_DIR(game_libpath, "$datarootdir/games/$PACKAGE/lib/")
22 else
23   MY_EXPAND_DIR(game_libpath, "./lib/")
24   bindir="`pwd`"
25 fi
26
27 dnl overwrite the path with an user-specified value
28 AC_ARG_WITH(libpath,
29 [  --with-libpath=path     specify the path to the Hengband lib folder],
30 [game_libpath="$withval"])
31
32 AC_ARG_WITH(varpath,
33 [  --with-varpath=path     specify the path to the Hengband var folder],
34 [game_varpath="$withval"],
35 [game_varpath="$game_libpath"])
36
37 AC_DEFINE_UNQUOTED(DEFAULT_LIB_PATH, "$game_libpath", [Path to the Hengband lib folder])
38 DEFAULT_LIB_PATH="$game_libpath"
39 AC_SUBST(DEFAULT_LIB_PATH)
40
41 AC_DEFINE_UNQUOTED(DEFAULT_VAR_PATH, "$game_varpath", [Path to the Hengband var folder])
42 DEFAULT_VAR_PATH="$game_varpath"
43 AC_SUBST(DEFAULT_VAR_PATH)
44
45 dnl Checks for programs.
46 AC_LANG(C++)
47 AC_PROG_CXX
48 dnl Note that the -std= option for Objective-C++ is hardwired in
49 dnl src/Makefile.am so that should be changed if this is.
50 AX_CXX_COMPILE_STDCXX(20, [ext], [mandatory])
51 PKG_PROG_PKG_CONFIG
52
53 AC_ARG_ENABLE(japanese,
54 [  --disable-japanese      build english version], use_japanese=no, [AC_DEFINE(JP, 1, [Enable Japanese]) AC_DEFINE(EUC, 1, [Use Extended Unix Code])])
55
56 AC_ARG_ENABLE(xim,
57 [  --disable-xim           disable xim support], use_xim=no, use_xim=yes)
58 AC_ARG_ENABLE(fontset,
59 [  --disable-fontset       disable fontset support], use_fontset=no, use_fontset=yes)
60 AC_ARG_ENABLE([xft],
61         AS_HELP_STRING([--enable-xft], [Enable xft support]))
62 AC_ARG_ENABLE(worldscore,
63 [  --disable-worldscore    disable worldscore support], worldscore=no)
64 AC_ARG_ENABLE(chuukei,
65 [  --enable-chuukei        enable internet chuukei support], AC_DEFINE(CHUUKEI, 1, [Chuukei mode]))
66 AC_ARG_ENABLE([cocoa],
67 [  --enable-cocoa          enable a Cocoa user interface (OS X only)],
68 [AC_DEFINE([MACH_O_COCOA], [1], [Use a Cocoa interface (OS X only)])], [])
69 AM_CONDITIONAL([COCOA], [test x$enable_cocoa = xyes])
70 dnl Since AC_PROG_OBJCXX has the side effect of setting this conditional,
71 dnl guarantee that is is always set, regardless of what happens in the if
72 dnl statement.
73 AM_CONDITIONAL([am__fastdepOBJCXX], false)
74 if test x"$enable_cocoa" = xyes ; then
75   dnl Use AC_LANG_PUSH and AC_LANG_POP to try to get back to the state that
76   dnl AC_LANG_C set in case there are side effects.
77   AC_LANG_PUSH([Objective C++])
78   AC_PROG_OBJCXX
79   AC_LANG_POP([Objective C++])
80   AC_DEFINE(SAFE_DIRECTORY, 1, [Mark var directory with version string])
81   AC_DEFINE(VERSION_STRING, "3.0.0", [Version string to use for var directory])
82 fi
83 AC_ARG_ENABLE([pch],
84 [  --disable-pch           disable use of precompiled headers],
85 enable_pch=no, enable_pch=yes)
86 AM_CONDITIONAL([PCH], [test x$enable_pch = xyes])
87
88 dnl Checks for libraries.
89 dnl Replace `main' with a function in -lncurses:
90 if test x"$enable_cocoa" != xyes ; then
91   AC_CHECK_LIB(ncursesw, initscr, [AC_DEFINE(USE_GCU, 1, [Allow -mGCU environment]) AC_DEFINE(USE_NCURSES, 1, [Use ncurses]) LIBS="$LIBS -lncursesw"])
92   if test "$ac_cv_lib_ncursesw_initscr" != yes; then
93     AC_CHECK_LIB(ncurses, initscr, [AC_DEFINE(USE_GCU, 1, [Allow -mGCU environment]) AC_DEFINE(USE_NCURSES, 1, [Use ncurses]) LIBS="$LIBS -lncurses"])
94     if test "$ac_cv_lib_ncurses_initscr" != yes; then
95       AC_CHECK_LIB(curses, initscr, [AC_DEFINE(USE_GCU, 1, [Allow -mGCU environment]) LIBS="$LIBS -lcurses"])
96       if test "$ac_cv_lib_curses_initscr" != yes; then
97         AC_CHECK_LIB(termcap, tgetent, [AC_DEFINE(USE_CAP, 1, [Allow -mCAP environment]) LIBS="$LIBS -ltermcap"])
98       fi
99     fi
100   fi
101 fi
102
103 AC_CHECK_LIB(iconv, iconv_open)
104
105 dnl The world score server is currently only available in Japanese.
106 if test "$use_japanese" = no; then
107   worldscore=no
108 fi
109 if test "$worldscore" != no; then
110   PKG_CHECK_MODULES([libcurl], [libcurl], [true], [
111     AC_SEARCH_LIBS([curl_global_init], [curl curl-gnutls curl-nss], [true], [AC_MSG_ERROR([libcurl is necessary for posting scores])])])
112   AC_DEFINE(WORLD_SCORE, 1, [Allow the game to send scores to the score server])
113 fi
114
115 dnl Checks for header files.
116 dnl AC_PATH_XTRA has side effects on CPP which are beneficial on Mac OS X.
117 dnl Removing it or conditionally executing it will likely lead to warnings
118 dnl on that platform about the preprocessor disagreeing with the compiler on
119 dnl the tests in AC_CHECK_HEADERS.
120 AC_PATH_XTRA
121 AS_IF([test "$have_x" = yes && test x"$enable_cocoa" != xyes], [
122   LIBS="$LIBS -lX11"
123   AC_DEFINE(USE_X11, 1, [Allow -mX11 environment])
124   CXXFLAGS="$X_CFLAGS $CXXFLAGS"
125   LDFLAGS="$X_LIBS $LDFLAGS"
126
127   if test "$use_fontset" = yes; then
128     AC_DEFINE(USE_FONTSET, 1, [Use FontSet])
129   else
130     if test "$use_japanese" != no; then
131       AC_DEFINE(USE_JP_FONTSTRUCT, 1, [Use Kanji without FontSet])
132     fi
133   fi
134
135   if test "$use_xim" = yes; then
136     AC_DEFINE(USE_XIM, 1, [Use X Imput Method])
137   fi
138
139   if test "$use_fontset" = yes || test "$use_xim" = yes; then
140     AC_DEFINE(USE_LOCALE, 1, [Support Locale])
141     if test "$use_japanese" != no; then
142       AC_DEFINE(DEFAULT_LOCALE, "ja_JP.eucJP", Default Japanese Locale)
143     fi
144     AC_CHECK_LIB(X11, _Xsetlocale, AC_DEFINE(X_LOCALE, 1, [Use XLocale]))
145     AC_CHECK_LIB(xpg4, setlocale, LIBS="$LIBS -lxpg4")
146   fi
147
148   AS_IF([test "x$enable_xft" = "xyes"], [
149     PKG_CHECK_MODULES(XFT, [xft],
150       [AC_DEFINE([USE_XFT], [1], [Use XFT])])
151   ])
152 ])
153
154 if test "$use_japanese" != no; then
155   AC_CHECK_PROG(NKF, nkf, yes)
156   if test x"$NKF" != x"yes"; then
157     AC_MSG_ERROR([nkf is not found. Please install nkf.])
158   fi
159 fi
160
161 if test "$enable_pch" != no; then
162   dnl md5sum, sha224sum, sha256sum, sha384sum, sha512sum and b2sum are
163   dnl frequently available on Linux.  md5 is available on macOS and OpenBSD.
164   dnl sha1, sha256, and sha512 are available on OpenBSD.
165   AC_PATH_PROGS(PCH_CHECKSUMMER, [md5sum md5 sha1sum sha1 sha224sum sha256sum sha256 sha384sum sha512sum sha512 b2sum], [none])
166   AC_ARG_VAR([PCH_CHECKSUMMER], [full path to a utility to compute the checksum for the precompiled header; checksum is for ccache's pch_external_checksum])
167 fi
168
169 AC_CHECK_HEADERS(fcntl.h sys/file.h sys/ioctl.h sys/time.h termio.h unistd.h stdint.h)
170
171 dnl Checks for typedefs, structures, and compiler characteristics.
172 AC_C_CONST
173 AC_TYPE_PID_T
174 AC_TYPE_SIZE_T
175 AC_STRUCT_TM
176
177 dnl Checks for library functions.
178 AC_PROG_GCC_TRADITIONAL
179 AC_FUNC_MEMCMP
180 AC_FUNC_STRFTIME
181 AC_FUNC_VPRINTF
182 AC_CHECK_FUNCS(gethostname mkdir select socket strtol vsnprintf mkstemp usleep)
183
184 AC_CONFIG_FILES(Makefile src/Makefile lib/Makefile lib/apex/Makefile lib/bone/Makefile lib/data/Makefile lib/edit/Makefile lib/edit/quests/Makefile lib/edit/towns/Makefile lib/file/Makefile lib/help/Makefile lib/info/Makefile lib/pref/Makefile lib/save/Makefile lib/script/Makefile lib/user/Makefile lib/xtra/Makefile lib/xtra/graf/Makefile lib/xtra/music/Makefile lib/xtra/sound/Makefile)
185 AC_OUTPUT()