xref: /Universal-ctags/docs/autotools.rst (revision dccba5efd1817d9496a454283c2332234ce8b193)
1caef7777SMasatake YAMATOBuilding with configure (\*nix including GNU/Linux)
2d5ef1ac0SMasatake YAMATO---------------------------------------------------------------------
352a03ee4Sngirard
4*dccba5efSHiroo HAYASHIIf you are going to build Universal Ctags on a popular GNU/Linux
5*dccba5efSHiroo HAYASHIdistribution, you can install the tools and libraries that Universal Ctags
6010c41a0SMasatake YAMATOrequires (or may use) as packages. See `GNU/Linux distributions`_ about
76371d75cSMasatake YAMATOthe packages.
852a03ee4Sngirard
9d5ef1ac0SMasatake YAMATOLike most Autotools-based projects, you need to do::
10d5ef1ac0SMasatake YAMATO
1119c66dffSHiroo HAYASHI    $ git clone https://github.com/universal-ctags/ctags.git
1219c66dffSHiroo HAYASHI    $ cd ctags
139d5b773cSMasatake YAMATO    $ ./autogen.sh
14d5ef1ac0SMasatake YAMATO    $ ./configure --prefix=/where/you/want # defaults to /usr/local
15d5ef1ac0SMasatake YAMATO    $ make
16d5ef1ac0SMasatake YAMATO    $ make install # may require extra privileges depending on where to install
17d5ef1ac0SMasatake YAMATO
182cebbf9fSDoug KearnsAfter installation the `ctags` executable will be in `$prefix/bin/`.
19d5ef1ac0SMasatake YAMATO
207b78beeeSMasatake YAMATO`autogen.sh` runs `autoreconf` internally.
212cebbf9fSDoug KearnsIf you use a (binary oriented) GNU/Linux distribution, `autoreconf` may
222cebbf9fSDoug Kearnsbe part of the `autoconf` package. In addition you may have to install
23e7619a1fShath995`automake` and/or `pkg-config`, too.
24eb375513SMasatake YAMATO
25010c41a0SMasatake YAMATOGNU/Linux distributions
266371d75cSMasatake YAMATO,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
276371d75cSMasatake YAMATO
286371d75cSMasatake YAMATOBefore running ./autogen.sh, install some packages.
296371d75cSMasatake YAMATO
30459b969cSK.TakataOn Debian-based systems (including Ubuntu), do::
316371d75cSMasatake YAMATO
326371d75cSMasatake YAMATO    $ sudo apt install \
336371d75cSMasatake YAMATO        gcc make \
346371d75cSMasatake YAMATO        pkg-config autoconf automake \
356371d75cSMasatake YAMATO        python3-docutils \
366371d75cSMasatake YAMATO        libseccomp-dev \
376371d75cSMasatake YAMATO        libjansson-dev \
386371d75cSMasatake YAMATO        libyaml-dev \
396371d75cSMasatake YAMATO        libxml2-dev
406371d75cSMasatake YAMATO
41010c41a0SMasatake YAMATOOn Fedora systems, do::
42010c41a0SMasatake YAMATO
43010c41a0SMasatake YAMATO    $ sudo dnf install \
44010c41a0SMasatake YAMATO        gcc make \
45010c41a0SMasatake YAMATO        pkgconfig autoconf automake \
46010c41a0SMasatake YAMATO        python3-docutils \
47010c41a0SMasatake YAMATO        libseccomp-devel \
48010c41a0SMasatake YAMATO        jansson-devel \
49010c41a0SMasatake YAMATO        libyaml-devel \
50010c41a0SMasatake YAMATO        libxml2-devel
51010c41a0SMasatake YAMATO
522cebbf9fSDoug KearnsChanging the executable's name
53eb375513SMasatake YAMATO,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
54eb375513SMasatake YAMATO
55eb375513SMasatake YAMATOOn some systems, like certain BSDs, there is already a 'ctags' program in the base
56eb375513SMasatake YAMATOsystem, so it is somewhat inconvenient to have the same name for
57*dccba5efSHiroo HAYASHIUniversal Ctags. During the ``configure`` stage you can now change
582cebbf9fSDoug Kearnsthe name of the created executable.
59eb375513SMasatake YAMATO
60ff522909SDoug KearnsTo add a prefix 'ex' which will result in 'ctags' being renamed to 'exctags':
61eb375513SMasatake YAMATO
62eb375513SMasatake YAMATO.. code-block:: bash
63eb375513SMasatake YAMATO
64eb375513SMasatake YAMATO	$ ./configure --program-prefix=ex
65eb375513SMasatake YAMATO
66ff522909SDoug KearnsTo completely change the program's name run the following:
67eb375513SMasatake YAMATO
68eb375513SMasatake YAMATO.. code-block:: bash
69eb375513SMasatake YAMATO
70eb375513SMasatake YAMATO	$ ./configure --program-transform-name='s/ctags/my_ctags/; s/etags/myemacs_tags/'
71ff522909SDoug Kearns
72ff522909SDoug KearnsPlease remember there is also an 'etags' installed alongside 'ctags' which you may also want to rename as shown above.
739d7450a9Sleleliu008
749d7450a9Sleleliu008Cross-compilation
759d7450a9Sleleliu008,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
769d7450a9Sleleliu008
779d7450a9Sleleliu008The way of cross-compilation is a bit complicated because the
789d7450a9Sleleliu008build-system of ctags uses `packcc`, a code generator written in C
799d7450a9Sleleliu008language. It means that two C compilers should be installed on you build machine;
809d7450a9Sleleliu008one for compiling `packcc`, another for compiling `ctags`.
819d7450a9Sleleliu008
829d7450a9Sleleliu008We provide two sets of configure variables to affect these two C compilers:
839d7450a9Sleleliu008`CC`, `CFLAGS`, `CPPFLAGS`, `LDFLAGS` variables affect the compiler who compiles `ctags`.
849d7450a9Sleleliu008`CC_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `LDFLAGS_FOR_BUILD` variables
859d7450a9Sleleliu008affect the compiler who compiles `packcc`.
869d7450a9Sleleliu008
879d7450a9Sleleliu008When native-compiling, `FOO_FOR_BUILD` is the same as `FOO`.
889d7450a9Sleleliu008
899d7450a9Sleleliu008Here is an example show you how to use these configure variables:
909d7450a9Sleleliu008
919d7450a9Sleleliu008::
929d7450a9Sleleliu008
939d7450a9Sleleliu008       $ mkdir ./out
949d7450a9Sleleliu008       $ configure \
959d7450a9Sleleliu008               --host=armv7a-linux-androideabi \
969d7450a9Sleleliu008               --prefix=`pwd`/out \
979d7450a9Sleleliu008               --enable-static \
989d7450a9Sleleliu008               --disable-seccomp \
999d7450a9Sleleliu008               CC=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang \
1009d7450a9Sleleliu008               CFLAGS='-v' \
1019d7450a9Sleleliu008               CPP='/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang -E' \
1029d7450a9Sleleliu008               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' \
1039d7450a9Sleleliu008               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' \
1049d7450a9Sleleliu008               AR=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar \
1059d7450a9Sleleliu008               RANLIB=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib \
1069d7450a9Sleleliu008               CC_FOR_BUILD=/usr/bin/cc \
1079d7450a9Sleleliu008               CFLAGS_FOR_BUILD='-v' \
1089d7450a9Sleleliu008               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 \
1099d7450a9Sleleliu008               PKG_CONFIG_LIBDIR=/Users/leleliu008/.ndk-pkg/pkg
1109d7450a9Sleleliu008       ...
1119d7450a9Sleleliu008       $ make
1129d7450a9Sleleliu008       ...
1139d7450a9Sleleliu008       $ make install
1149d7450a9Sleleliu008       ...
1159d7450a9Sleleliu008       $ ls out/bin
1169d7450a9Sleleliu008       ctags readtags
1179d7450a9Sleleliu008
1189d7450a9Sleleliu008Simpler example for `aarch64-linux-gnu` can be found in `circle.yml` in the source tree.
119