This document is about using old autotools based build system.
Installing with modern meson based build system is documented
in doc/INSTALL.meson.

===================
Installing Freeciv:
===================

This file describes how to compile and install Freeciv. Last time we
made sure this file is up to date was 16-Jul-06.
Last minor update was 08-Dec-25.

There may be a localized version of this file in the ./doc directory,
named INSTALL.<locale> (e.g., INSTALL.de).

This document contains sections and subsections as follows:
     0. Prerequisites:
     1. Prerequisites for the clients:
          1a. Prerequisites for the Gtk3.22 client:
          1b. Prerequisites for the Gtk4 client:
          1c. Prerequisites for the SDL2 client:
          1d. Prerequisites for the Qt client:
     2. Generating Makefiles
          2a. Generating the Makefile for git versions:
          2b. Generating the Makefile for release versions:
     3. Compiling Freeciv:
     4. Installation:
     5. Native Language Support:
     6. Readline Support:
     7. Reinier's Solaris Installation Notes:
     8. Mac OS X and Darwin notes:
     9. Windows notes:


0. Prerequisites:
=================

Freeciv has a number of prerequisites. Note, that apart from the first
prerequisite, the Freeciv configuration process is smart enough to work
out whether your system is suitable. If in doubt, just try it.

 - Unix (or similar)

   The Unix operating system, a work-alike such as Linux or FreeBSD,
   or some OS that provides a very Unix-like personality or mode, like
   EMX under OS/2 or the Cygwin toolkit under Windows.
   (See https://www.cygwin.com/). Support for BSD-style TCP/IP sockets
   is essential, as is a Bourne-shell compatible shell, such as GNU "bash".
   (Most Unixes fit the bill...)

 - An ANSI C compiler.

   Freeciv is written in very portable (almost) ANSI C. Both 32- and 64-
   bit machines are supported. You cannot use a "K&R C" compiler, or
   a C++ compiler.

   Development of Freeciv is primarily done with "gcc", the GNU
   project's excellent C compiler. Releases can be compiled with gcc
   or most other compilers (such as clang or the unbundled Solaris C compiler).

 - A "make" program.

   Freeciv developers generally use "gmake", the GNU make program.

   Officially released versions of Freeciv are designed to have
   makefiles which work with most make programs.

   You can check if you have GNU make installed on your system by
   typing:

    % make -v                   [and if this doesn't work, try "gmake -v"]

   The output should include "GNU Make" somewhere.

 - libtool version 2.2 or better

 - libcurl;
   - For autotools based builds version 7.15.4 or better
   - For meson based builds 7.56.0 or better

   Libcurl takes care of https, and sometimes http, communication
   with external services like the metaserver, and the modpack downloads
   by the modpack installer.

   https://curl.se/

 - libicu

   Libicu helps handling UTF-8 texts

   https://icu.unicode.org/

 - libsqlite3 is required unless both authentication and modpack
   installer support have been disabled from the build.

   https://www.sqlite.org/

The git version has additional requirements. A release version
contains the generated files.

 - The programs from GNU gettext version 0.16 or better

   Especial the xgettext program is required to create the *.gmo
   files which aren't included in the git tree.

 - GNU autoconf version 2.69 or better

   Autoconf is required to create configure from configure.ac.

 - GNU automake version 1.13 or better

   Automake is required to create the various Makefile.in from
   Makefile.am.

 - Python version 3.6

   Some source files are generated by python scripts.
   In general, the minimum supported python version will follow
   that required for the meson build's minimum meson version;
   see INSTALL.meson for that.


1. Prerequisites for the clients:
=================================

The Freeciv client comes in the following forms:
* Gtk+ 3.0 widget library, version 3.22 ("Gtk+ 3.22")
* Gtk 4.0 widget library, version 4.0
* SDL2
* Qt

These forms have different prerequisites, explained separately below.

Your system will need to satisfy at least one of these sets of prerequisites.

Note that most Linux systems have separate library packages for "runtime"
library support and for development support (for compiling programs
which use those libraries). To compile Freeciv on such systems you
will need to have the appropriate "development" packages installed.

Sound support is built in by default if development files for
"SDL2" and "SDL2_mixer" libraries are found from the system.
Minimum version for SDL2 is 2.0.6.

     https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.8.0/SDL2_mixer-2.8.0.tar.gz


1a. Prerequisites for the Gtk+ 3.22 client:
==========================================

 - "pkgconf", or older "pkg-config"

   "pkgconf" is a system for managing library compile/link flags that
   works with automake and autoconf. You may obtain it at:

      https://distfiles.dereferenced.org/pkgconf/pkgconf-2.0.2.tar.xz

 - The "Glib" utility library.

   The "Glib" utility library provides non-graphical functions used by the
   "Gdk" and "Gtk+" libraries, like hash tables, single linked lists, etc.

   Freeciv requires a version of "Glib" greater or equal to 2.50

   If the Freeciv configure process tells you that you don't have the
   Glib library installed, then it may be obtained from here:

     https://download.gnome.org/sources/glib/2.78/glib-2.78.4.tar.xz

 - The "Atk" accessibility library.

   The "Atk" library provides a set of interfaces for accessibility.
   It allows people with disabilities to utilize all the functionality
   provided by Gtk+ apps. You may obtain it at:

     https://download.gnome.org/sources/atk/2.38/atk-2.38.0.tar.xz

 - The "Pango" text layout and rendering library.

   "Pango" is library for layout and rendering of text, with an emphasis
   on internationalization. You may obtain it at:

     https://download.gnome.org/sources/pango/1.50/pango-1.50.14.tar.xz

 - The "Gdk-Pixbuf" image loading/saving library

   "Gdk-Pixbuf" used to be part of "Gtk+" itself, but is now separate
   project. It may be obtained from:

     https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.10.tar.xz

 - The "Gtk+" widget library.

   The "Gtk+" widget library was designed for the GIMP graphics program.
   Since then it has gained popularity as an easy to program, free toolkit.

   The "Gtk+" library comes with one companion libraries:

     "Gdk":
       Provides an abstraction layer over X-Windows/LinuxFB/Windows to implement
       basic drawing functions, windows, clipping, etc.

   Freeciv requires a version of "Gtk+" greater or equal to 3.22.0.

   If the Freeciv configure process tells you that you don't have the
   Gtk+ library installed, then it may be obtained from here:

     https://download.gnome.org/sources/gtk+/3.24/gtk%2B-3.24.41.tar.xz

   "Gtk+" depends on the "Glib", "Atk", "Gdk-Pixbuf", and "Pango" libraries.

If you are going to make these yourself, build and install them in the
following order: pkgconf, Glib, Atk, Pango, Gdk-Pixbuf, Gtk+.

1b. Prerequisites for the Gtk 4.0 client:
==========================================

 - "pkgconf", or older "pkg-config"

   "pkgconf" is a system for managing library compile/link flags that
   works with automake and autoconf. You may obtain it at:

      https://distfiles.dereferenced.org/pkgconf/pkgconf-2.0.2.tar.xz

 - The "Glib" utility library.

   The "Glib" utility library provides non-graphical functions used by the
   "Gdk" and "Gtk" libraries, like hash tables, single linked lists, etc.

   Freeciv requires a version of "Glib" greater or equal to 2.66

   If the Freeciv configure process tells you that you don't have the
   Glib library installed, then it may be obtained from here:

     https://download.gnome.org/sources/glib/2.78/glib-2.78.4.tar.xz

 - The "Atk" accessibility library.

   The "Atk" library provides a set of interfaces for accessibility.
   It allows people with disabilities to utilize all the functionality
   provided by Gtk apps. You may obtain it at:

     https://download.gnome.org/sources/atk/2.38/atk-2.38.0.tar.xz

 - The "Pango" text layout and rendering library.

   "Pango" is library for layout and rendering of text, with an emphasis
   on internationalization. You may obtain it at:

     https://download.gnome.org/sources/pango/1.50/pango-1.50.14.tar.xz

 - The "Gdk-Pixbuf" image loading/saving library

   You may be obtain it at:

     https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.10.tar.xz

 - The "Gtk" widget library.

   The "Gtk" widget library was designed for the GIMP graphics program.
   Since then it has gained popularity as an easy to program, free toolkit.

   "Gtk 4" is the default client. If you don't specify any client with
   "--enable-client" to configure, you will get "Gtk 4" client.

   The "Gtk" library comes with one companion libraries:

     "Gdk":
       Provides an abstraction layer over X-Windows/LinuxFB/Windows to implement
       basic drawing functions, windows, clipping, etc.

   Freeciv requires a version of "Gtk" greater or equal to 4.0.0.

   If the Freeciv configure process tells you that you don't have the
   Gtk library installed, then it may be obtained from here:

     https://download.gnome.org/sources/gtk/4.12/gtk-4.12.5.tar.xz

   "Gtk" depends on the "Glib", "Atk", "Gdk-Pixbuf", and "Pango" libraries.

If you are going to make these yourself, build and install them in the
following order: pkgconf, Glib, Atk, Pango, Gdk-Pixbuf, Gtk.

1c. Prerequisites for the SDL2 client:
=====================================

 - The "SDL2" library.

   "Simple DirectMedia Layer is a cross-platform multimedia library designed
    to provide low level access to audio, keyboard, mouse, joystick, 3D hardware
    via OpenGL, and 2D video framebuffer." (https://www.libsdl.org/)

   These features make it a good choice for portable games. You may obtain it
   at:

   https://github.com/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-2.28.5.tar.gz

   To compile the client using the "SDL2" library add "--enable-client=sdl2"
   to the Freeciv configure script. See the section below for more
   information about the configure script.

 - The "SDL2_image" library.

   This library loads the PNG images (with the help of libpng) and converts
   them to "SDL surfaces" that can be handled by the "SDL" library. You may
   obtain it at:

   https://github.com/libsdl-org/SDL_image/releases/download/release-2.8.2/SDL2_image-2.8.2.tar.gz

 - The "SDL2_gfx" library.

   https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz

 - The "SDL2_ttf" library.

   https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.22.0/SDL2_ttf-2.22.0.tar.gz

 - The "freetype" library.

   This library helps to render text for the SDL2 client, using an externally
   provided TrueType font. You may obtain it at:

   https://download.savannah.gnu.org/releases/freetype/freetype-2.13.2.tar.xz

1d. Prerequisites for the Qt client:
====================================

 - C++ compiler.

   Qt-client is written in C++, so you need appropriate compiler.
   Compiler needs to support c++17 standard, or,
   in case of --with-qtver=qt5 build, just c++11 standard

   In Freeciv development, g++ has been the primary C++ compiler.
   Also clang++ has been used.

 - Qt Meta Object Compiler (moc)

   Qt's Meta Object Compiler is a command usually called 'moc', or
   'moc-qt6' or 'moc-qt5' depending on Qt version in some systems.
   You may want install 'qtchooser' to find correct moc version for you
   when you have multiple Qt versions installed in parallel.

   If configure does not find (correct) moc, you can give it with
   environment variable MOCCMD, e.g.,
   ../src/configure MOCCMD="/home/freeciv/local-qt/bin/moc" --enable-client=qt

 - Qt6Core, Qt6Gui, and Qt6Widgets libraries and headers.
   At least version 6.0 is required.
   If one configures with Qt5 compatibility switch --with-qtver=qt5,
   required libraries and headers are Qt5Core, Qt5Gui, and Qt5Widgets
   and at least version 5.15 of Qt is required.


2. Generating Makefiles
=======================
This section contains two parts, one for generating makefiles from git
versions and one for generating makefiles from release versions.

2a. Generating the Makefile for git versions:
=============================================

This step is only needed for git versions.

To create the makefile just cd to the builddir,
and run autogen.sh from the source directory.

 % ../src/autogen.sh

This will create the configure script and will run it. All parameters
of autogen.sh are passed to configure. Read the next section about the
parameters which can be passed to configure.

2b. Generating the Makefile for release versions:
=================================================

Before you compile Freeciv, you must generate a Makefile. This makefile
is configured to suit the features available on your machine.

This configuration is done using the GNU "configure" script.

To use "configure", "cd" to directory where you want the build
to end, and run it from the top directory containing
the Freeciv files:

 % ../src/configure

This script will then attempt to determine the relevant features (and
misfeatures!!) of your system. It should print a page or two of
diagnostics about your machine, then stop gracefully.

If you'd like help on the various options supported by the configure
script, try the --help option, like this:

 % ../src/configure --help

By default the configure script will choose the Gtk client if the
required libraries are found. If you prefer to override this default,
you can give configure the "--enable-client=sdl2" option.

If you want to change the compiler options, set the CFLAGS environment
variable in your shell before running "configure". For example:

 % CFLAGS="-O -g -pipe" ../src//configure  [for people using Bourne shell or bash]

or

 % setenv CFLAGS "-O -g -pipe"
 % ../src/configure                        [for people using C shell or tcsh]

If you're tracking down a "core dump", we suggest that you use
a value of "-g" for CFLAGS.

When you install Freeciv (later), the game components will be copied into
subdirectories of /usr/local by default. If you would like to use some
other installation prefix besides /usr/local, you should specify it now:

 % ../src/configure --prefix=/opt/freeciv

If for some reason using "configure" gives you trouble, follow these steps:

  - Read the prerequisites section carefully, to determine if your
    system meets all the requirements.

  - If the problem is with "gettext", please read the Native Language
    Support section, below, for possible work-arounds.

  - Let us know, so that we can fix it for the next release!!

    Send mail to the freeciv-dev mailing list, telling us what you did,
    and what the result is. It would be helpful to include the output
    of the configure script, and the contents of the "config.status",
    "config.cache" and "config.log" files, which are generated by the
    configure script.

    You can find out about the freeciv-dev mailing list on our web
    site, at https://www.freeciv.org/


3. Compiling Freeciv:
=====================

If all has gone well previous to this point, then compiling Freeciv
should be as easy as typing "make" (or preferably, "gmake").

If you have problems, read the file BUGS, and follow the advice
carefully. If the problem is with "gettext", please read the Native
Language Support section, below, for possible work-arounds.

After compilation, the important results are:

  - The "client/freeciv-<GUI>" and "server/freeciv-server" binaries.
  - The "data/" directory, which contains the graphics and scenarios.
  - The "translations/" directory, which contains the localization files.
  - The "fcgui" and "fcser" scripts.

It's perfectly feasible to play Freeciv in this directory, without
installing it. If you do this, the "fcgui" and "fcser" scripts may be
useful, although they are not as necessary as they used to be.

See the README file for more information.

(However you cannot use Internationalization when playing Freeciv from
the source directory; you must install Freeciv for that.)


4. Installation:
================

Installing Freeciv involves installing the components mentioned in the
Compiling Freeciv section. These need to be copied to a directory such
as /usr/local (the default), /usr/games, /usr/games/freeciv,
/usr/local/freeciv, or some other suitable directory.

Typing "make install" should install everything correctly on your machine.
You may like to use the --prefix=DIR configure option (see the Generating
the Makefile section) to ensure the files get placed where you want.

When the Freeciv client and Freeciv server are run they both need to
find some files from the "data" directory. By default freeciv looks
in the following directories, in order, for any data files: the current
directory; the "data" subdirectory of the current directory; the
subdirectory ".freeciv" in the user's home directory; and the directory
where the files are placed by running "make install". You can override
this search patch by setting the FREECIV_DATA_PATH environment variable, to
a single directory or a list of directories separated by colons.

For example:

  % setenv FREECIV_DATA_PATH "/usr/games/freeciv/data:./data"
  (for users of csh, tcsh, etc.)

  % FREECIV_DATA_PATH="/usr/games/freeciv/data:./data"; export FREECIV_DATA_PATH
  (for users of sh, bash, ksh, zsh, etc.)

Also, note that you generally must install Freeciv if you wish to use
its Native Language Support. See the README file for more information.


5. Native Language Support:
===========================

Freeciv uses the "gettext" system for Native Language Support.

If you experience problems with gettext in either configuring or compiling
Freeciv, there are a few work-arounds you can try:

1. If you don't need Native Language Support, disable it using the
   "--disable-nls" configure option:

      % ../src/configure --disable-nls
      % make

2. You can try to install the latest version of GNU gettext.
   It may be obtained from here:

      https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.xz


6. Readline Support:
====================

Freeciv has optional support for the readline library.

Readline support is what makes the server command line behave sensibly,
making it possible to
 - Use the backspace key.
 - Use the cursor to move back and forth on the line you have written.
 - Use TAB completion of commands and command arguments. Ie, when you
   push tab the server will finish the word for you if there is only one
   possible choice.
 - Use the up and down cursor to scroll through the history of previously
   entered commands.
 - etc.

The configure script will check if you have the readline library correctly
installed. If so it will automatically set up the makefiles so that readline
is compiled into the server. If not then it will just silently configure
without readline support.
You can force configure to include readline or die trying by giving
configure the --with-readline option:

 % ../src/configure --with-readline

Some linux distributions (and possibly other operating systems) have
readline version 4 incorrectly installed, so that readline is not
set up to declare it's dynamic dependencies. In that case configure
will try to guess which extra libs it should link against and add them.
The configure script will give a warning if it had to add extra libs
to make readline work. This should be harmless, and is just meant as
a reminder to the folks who distribute readline. :)

7. Reinier's Solaris Installation Notes:
========================================

Solaris (2.5 and up) has its own version of X in /usr/openwin, its own
version of make in /usr/ccs/bin/make, and its own compiler (to be purchased
separately) which, if you have it, is available in /opt/SUNWspro/bin.
Solaris does not provide any of the stuff required for imlib, gdk and gtk,
either, which is required to build the GTK+ client. However, with some
patience, everything can be compiled without problems.

Make sure your environment variables, especially $PATH and $LD_LIBRARY_PATH,
and the configure options do not point to an inconsistent set of software,
and compiling will be fine.

You can set up your $PATH and configure to use only GNU
tools. Furthermore, Freeciv is known to compile with MIT X, and with
certain combinations of GNU and Sun tools. The exact recipes depend on your
local installation.


8. Mac OS X and Darwin notes:
=============================

Pkg-config files installed with icu4c homebrew package are not found
from normal path. This shows up as a configure error:
"icu development files not found. Adjusting PKG_CONFIG_PATH may help"
One needs to adjust PKG_CONFIG_PATH before configure, like this:
> export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"

Mac OS has a library called libedit that provides similar functionality to
readline, but is not a suitable replacement for freeciv use of readline.
You need to provide real readline implementation (e.g. from homebrew) to
get readline functionality to the freeciv server.

Readline files from homebrew are not found from normal paths, but
you need to adjust CPPFLAGS and LDFLAGS before configure.
If you don't have CPPFLAGS or LDFLAGS defined at all beforehand, use:
> export CPPFLAGS="-I$(brew --prefix readline)/include"
> export LDFLAGS="-L$(brew --prefix readline)/lib"
If you already have either defined, include also those existing
path components, e.g. CPPFLAGS:
> export CPPFLAGS="-I$(brew --prefix readline)/include:$CPPFLAGS"


9. Windows notes:
=================

Windows version of Freeciv can be built either with Msys2 or Cygwin.
Official Windows binaries are built with Msys2, and they are self-contained
packages. For using Cygwin version, you need Cygwin environment installed.

Build instructions for Msys2 versions are documented on doc/README.msys2

Cygwin specific installation notes can be found in doc/INSTALL.Cygwin.

** END **
