OSDN Git Service

日本語版
[nazghul-jp/nazghul-jp.git] / configure.ac
1 dnl This file is part of the nazghul program
2 dnl
3 dnl Process this file with autogen.sh to produce a configure script.
4
5 dnl ---------------------------------------------------------------------------
6 dnl 1. Boilerplate
7 dnl      This section should include standard boilerplate code, such as the call 
8 dnl      to AC_INIT (which must be first), AM_INIT_AUTOMAKE, AC_CONFIG_HEADER, 
9 dnl      and perhaps AC_REVISION.
10 dnl ---------------------------------------------------------------------------
11
12 AC_PREREQ(2.59)
13
14 dnl   This macro performs essential initialization for the
15 dnl   generated `configure' script. An optional argument may provide the name of a
16 dnl   file from the source directory to ensure that the directory has been 
17 dnl   specified correctly.
18 AC_INIT(nazghul, 0.7.1, [nazghul-devel@lists.sourceforge.net])
19 AC_CONFIG_SRCDIR([src/nazghul.c])
20 AM_CONFIG_HEADER([config.h])
21
22 dnl AC_CANONICAL_HOST
23 dnl   This macro determines the type of the host system and sets the output 
24 dnl   variable `host', as well as other more obscure variables.
25 AC_CANONICAL_HOST
26
27 dnl AC_CANONICAL_TARGET
28 dnl   I'm not certain what this is. The automake book refers to 
29 dnl   AC_CANONICAL_SYSTEM, but not AC_CANONICAL_TARGET. A Google search only 
30 dnl   yields scads of mailing list reports about people having weird problems 
31 dnl   with this,
32 AC_CANONICAL_TARGET
33
34 dnl AM_INIT_AUTOMAKE(package, version, [nodefine])
35 dnl   This macro is used to do all the standard initialization required by 
36 dnl   Automake. It has two required arguments: the package name and the version 
37 dnl   number. This macro sets and calls AC_SUBST on the shell variables PACKAGE 
38 dnl   and VERSION. By default it also defines these variables (via 
39 dnl   AC_DEFINE_UNQUOTED). However, this macro also accepts an optional third 
40 dnl   argument which, if not empty, means that the AC_DEFINE_UNQUOTED calls for 
41 dnl   PACKAGE and VERSION should be suppressed.
42 AM_INIT_AUTOMAKE
43 AM_MAINTAINER_MODE
44
45 dnl ---------------------------------------------------------------------------
46 dnl 2. Options
47 dnl      The next section should include macros which add command-line options 
48 dnl      to configure, such as AC_ARG_ENABLE. It is typical to put support code
49 dnl      for the option in this section as well, if it is short enough.
50 dnl ---------------------------------------------------------------------------
51
52 dnl ---------------------------------------------------------------------------
53 dnl 3. Programs
54 dnl      Next it is traditional to check for programs that are either needed by
55 dnl      the configure process, the build process, or by one of the programs 
56 dnl      being built. This usually involves calls to macros like AC_CHECK_PROG
57 dnl      and AC_PATH_TOOL.
58 dnl ---------------------------------------------------------------------------
59
60 dnl AC_PROG_CC
61 dnl   This checks for the C compiler to use and sets the shell variable CC to the 
62 dnl   value. If the GNU C compiler is being used, this sets the shell variable GCC 
63 dnl   to `yes'. This macro sets the shell variable CFLAGS if it has not already 
64 dnl   been set. It also calls AC_SUBST on CC and CFLAGS.
65 AC_PROG_CC
66
67 dnl AC_PROG_CXX
68 dnl   This is like AC_PROG_CC, but it checks for the C++ compiler, and sets the
69 dnl   variables CXX, 
70 AC_PROG_CXX
71
72 dnl AC_PROG_LIBTOOL
73 dnl   This macro is the primary way to integrate Libtool support into `configure'.
74 dnl   If you are using Libtool, you should call this macro in `configure.in'. Among
75 dnl    other things, it adds support for the `--enable-shared' configure flag.
76 dnl AC_PROG_LIBTOOL
77
78 dnl AC_PROG_INSTALL
79 dnl   This looks for an install program and sets the output variables INSTALL, 
80 dnl   INSTALL_DATA, INSTALL_PROGRAM, and INSTALL_SCRIPT. This macro assumes that if
81 dnl   an install program cannot be found on the system, your package will have 
82 dnl   `install-sh' available in the directory chosen by AC_CONFIG_AUX_DIR.
83 dnl AC_PROG_INSTALL
84
85 AC_PROG_MAKE_SET
86
87 dnl ---------------------------------------------------------------------------
88 dnl 4. Libraries
89 dnl      Checks for libraries come before checks for other objects visible to C
90 dnl      (or C++, or anything else). This is necessary because some other checks
91 dnl      work by trying to link or run a program; by checking for libraries
92 dnl      first you ensure that the resulting programs can be linked.
93 dnl ---------------------------------------------------------------------------
94
95 dnl Check for SDL and SDL features, i.e. -lSDL
96 SDL_VERSION=1.2.3
97 AM_PATH_SDL($SDL_VERSION,
98             :,
99             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
100 )
101
102 dnl ---------------------------------------------------------------------------
103 dnl 5. Headers
104 dnl      Next come checks for existence of headers.
105 dnl ---------------------------------------------------------------------------
106 AC_LANG([C])
107 AC_HEADER_STDC
108 AC_LANG([C++])
109 AC_CHECK_HEADERS([fcntl.h \
110         malloc.h          \
111         float.h           \
112         limits.h])
113
114 dnl ---------------------------------------------------------------------------
115 dnl 6. Typedefs and structures
116 dnl    We do checks for typedefs after checking for headers for the simple
117 dnl    reason that typedefs appear in headers, and we need to know which headers
118 dnl    we can use before we look inside them.
119 dnl ---------------------------------------------------------------------------
120 PETI_ENABLED_DYNAMIC_LINKING
121 AC_C_CONST
122 AC_C_INLINE
123 AC_C_VOLATILE
124
125 dnl ---------------------------------------------------------------------------
126 dnl 7. Functions
127 dnl      Finally we check for functions. These come last because functions have
128 dnl      dependencies on the preceding items: when searching for functions,
129 dnl      libraries are needed in order to correctly link, headers are needed in
130 dnl      order to find prototypes (this is especially important for C++, which
131 dnl      has stricter prototyping rules than C), and typedefs are needed for
132 dnl      those functions which use or return types which are not built in.
133 dnl ---------------------------------------------------------------------------
134 AC_CHECK_FUNCS([malloc  \
135         realloc         \
136         select_argtypes \
137         vprintf         \
138         strerror        \
139         strpbrk         \
140         strstr          \
141         atexit          \
142         floor           \
143         strcasecmp      \
144         strdup          \
145         realloc         \
146         select          \
147         strchr])
148
149 dnl Add in the SDL CFLAGS
150 CFLAGS="$CFLAGS $SDL_CFLAGS"
151
152 dnl Use the same flags for c++ as for c
153 CXXFLAGS="$CFLAGS"
154
155 dnl The preprocessor needs the same info too.
156 CXXCPP="$CXXCPP $CXXFLAGS"
157
158 dnl Set the compiler to c++ (for now)
159 CC="$CXX"
160
161 dnl Add libraries to build process
162 LIBS="$LIBS $SDL_LIBS"
163
164 dnl Check specifically for libpng, i.e. -lpng switch
165 AC_CHECK_LIB(png, png_create_write_struct)
166
167 AC_CHECK_HEADER([png.h],
168                [],
169                [AC_MSG_ERROR([*** png include file not found!
170 You should install development package.])])
171
172 dnl Check specifically for SDL_image library, i.e. -lSDL_image switch
173 AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray)
174
175 AC_CHECK_HEADER([SDL_image.h],
176                [],
177                [AC_MSG_ERROR([*** SDL_image include files not found!
178 You should install development package.])])
179
180 dnl Check specifically for SDL_mixer library, i.e. -lSDL_mixer switch
181 AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio)
182
183 AC_CHECK_HEADER([SDL_mixer.h],
184                [],
185                [AC_MSG_ERROR([*** SDL_mixer include files not found!
186 You should install development package.])])
187
188 dnl ---------------------------------------------------------------------------
189 dnl 8. Output
190 dnl      This is done by invoking AC_OUTPUT.
191 dnl ---------------------------------------------------------------------------
192
193 # User directories for saving game data
194  
195 AC_DEFINE(NAZGHUL_USER_DIR, "/.nazghul",
196            [.nazghul is for Unix users.])
197
198 AC_DEFINE(NAZGHUL_USER_DIR_WIN, "/_nazghul",
199            [_nazghul is for Windows users.])
200
201 AC_DEFINE(HOME_ENV, "HOME",
202            [Most likely your home directory is stored in $HOME.])
203
204 AC_DEFINE(MIN_SCRIPT_MAJOR, 0,
205           [Minimum supported script version])
206
207 AC_DEFINE(MIN_SCRIPT_MINOR, 6,
208           [Minimum supported script version])
209
210 AC_DEFINE(MIN_SCRIPT_RELEASE, 0,
211           [Minimum supported script version])
212
213 AC_DEFINE(USE_SKILLS, 1, [Enable Yuse command and skills])
214 AC_DEFINE(USE_QUESTS, 1, [Enable quest log])
215
216 # Finally create all the generated files
217 AC_CONFIG_FILES([Makefile \
218         m4/Makefile       \
219         src/Makefile      \
220         worlds/Makefile   \
221         worlds/haxima-1.002/Makefile \
222         worlds/haxima-1.002/music/Makefile])
223
224 AC_OUTPUT
225
226 cat <<EOF
227
228 $PACKAGE_NAME $PACKAGE_VERSION configured.
229
230 You can now type \`gmake' to compile $PACKAGE_NAME.
231 If \`gmake' is not available on your system, try \`make' instead.
232 EOF