fork of https://github.com/sourcegraph/zoekt
1#!/bin/sh
2
3# This script installs universal-ctags within an alpine container.
4
5# Commit hash of github.com/universal-ctags/ctags.
6# Last bumped 2024-09-02.
7CTAGS_VERSION=v6.1.0
8CTAGS_ARCHIVE_TOP_LEVEL_DIR=ctags-6.1.0
9# When using commits you can rely on
10# CTAGS_ARCHIVE_TOP_LEVEL_DIR=ctags-$CTAGS_VERSION
11
12CTAGS_TMPDIR=
13
14cleanup() {
15 apk --no-cache --purge del ctags-build-deps || true
16 cd /
17 if [ -n "$CTAGS_TMPDIR" ]; then
18 rm -rf "$CTAGS_TMPDIR"
19 fi
20}
21
22trap cleanup EXIT
23
24set -eux
25
26apk --no-cache add \
27 --virtual ctags-build-deps \
28 autoconf \
29 automake \
30 binutils \
31 curl \
32 g++ \
33 gcc \
34 jansson-dev \
35 make \
36 pkgconfig
37
38# ctags is dynamically linked against jansson
39apk --no-cache add jansson
40
41NUMCPUS=$(grep -c '^processor' /proc/cpuinfo)
42CTAGS_TMPDIR=$(mktemp -d /tmp/ctags.XXXXXX)
43
44# Installation
45curl --retry 5 "https://codeload.github.com/universal-ctags/ctags/tar.gz/$CTAGS_VERSION" | tar xz -C "$CTAGS_TMPDIR"
46cd "$CTAGS_TMPDIR/$CTAGS_ARCHIVE_TOP_LEVEL_DIR"
47./autogen.sh
48./configure --program-prefix=universal- --enable-json --disable-readcmd
49make -j"$NUMCPUS" --load-average="$NUMCPUS"
50make install