xref: /Universal-ctags/docs/autotools.rst (revision dccba5efd1817d9496a454283c2332234ce8b193)
1Building with configure (\*nix including GNU/Linux)
2---------------------------------------------------------------------
3
4If you are going to build Universal Ctags on a popular GNU/Linux
5distribution, you can install the tools and libraries that Universal Ctags
6requires (or may use) as packages. See `GNU/Linux distributions`_ about
7the packages.
8
9Like most Autotools-based projects, you need to do::
10
11    $ git clone https://github.com/universal-ctags/ctags.git
12    $ cd ctags
13    $ ./autogen.sh
14    $ ./configure --prefix=/where/you/want # defaults to /usr/local
15    $ make
16    $ make install # may require extra privileges depending on where to install
17
18After installation the `ctags` executable will be in `$prefix/bin/`.
19
20`autogen.sh` runs `autoreconf` internally.
21If you use a (binary oriented) GNU/Linux distribution, `autoreconf` may
22be part of the `autoconf` package. In addition you may have to install
23`automake` and/or `pkg-config`, too.
24
25GNU/Linux distributions
26,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
27
28Before running ./autogen.sh, install some packages.
29
30On Debian-based systems (including Ubuntu), do::
31
32    $ sudo apt install \
33        gcc make \
34        pkg-config autoconf automake \
35        python3-docutils \
36        libseccomp-dev \
37        libjansson-dev \
38        libyaml-dev \
39        libxml2-dev
40
41On Fedora systems, do::
42
43    $ sudo dnf install \
44        gcc make \
45        pkgconfig autoconf automake \
46        python3-docutils \
47        libseccomp-devel \
48        jansson-devel \
49        libyaml-devel \
50        libxml2-devel
51
52Changing the executable's name
53,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
54
55On some systems, like certain BSDs, there is already a 'ctags' program in the base
56system, so it is somewhat inconvenient to have the same name for
57Universal Ctags. During the ``configure`` stage you can now change
58the name of the created executable.
59
60To add a prefix 'ex' which will result in 'ctags' being renamed to 'exctags':
61
62.. code-block:: bash
63
64	$ ./configure --program-prefix=ex
65
66To completely change the program's name run the following:
67
68.. code-block:: bash
69
70	$ ./configure --program-transform-name='s/ctags/my_ctags/; s/etags/myemacs_tags/'
71
72Please remember there is also an 'etags' installed alongside 'ctags' which you may also want to rename as shown above.
73
74Cross-compilation
75,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
76
77The way of cross-compilation is a bit complicated because the
78build-system of ctags uses `packcc`, a code generator written in C
79language. It means that two C compilers should be installed on you build machine;
80one for compiling `packcc`, another for compiling `ctags`.
81
82We provide two sets of configure variables to affect these two C compilers:
83`CC`, `CFLAGS`, `CPPFLAGS`, `LDFLAGS` variables affect the compiler who compiles `ctags`.
84`CC_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `LDFLAGS_FOR_BUILD` variables
85affect the compiler who compiles `packcc`.
86
87When native-compiling, `FOO_FOR_BUILD` is the same as `FOO`.
88
89Here is an example show you how to use these configure variables:
90
91::
92
93       $ mkdir ./out
94       $ configure \
95               --host=armv7a-linux-androideabi \
96               --prefix=`pwd`/out \
97               --enable-static \
98               --disable-seccomp \
99               CC=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang \
100               CFLAGS='-v' \
101               CPP='/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang -E' \
102               CPPFLAGS='-I/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/include --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Qunused-arguments -Dftello=ftell -Dfseeko=fseek' \
103               LDFLAGS='-L/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot' \
104               AR=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar \
105               RANLIB=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib \
106               CC_FOR_BUILD=/usr/bin/cc \
107               CFLAGS_FOR_BUILD='-v' \
108               PKG_CONFIG_PATH=/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib/pkgconfig \
109               PKG_CONFIG_LIBDIR=/Users/leleliu008/.ndk-pkg/pkg
110       ...
111       $ make
112       ...
113       $ make install
114       ...
115       $ ls out/bin
116       ctags readtags
117
118Simpler example for `aarch64-linux-gnu` can be found in `circle.yml` in the source tree.
119