1#!/bin/bash
2#
3# Copyright (C) 2015 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18# Generates the android_includes/ directory with the headers that normally will
19# be generated by cmake. Run this command whenever you update the include files.
20
21LOCAL_PATH=$(realpath $(dirname "$0"))
22
23cleanup() {
24  rm -rf "${WORKDIR}"
25}
26trap cleanup INT TERM ERR EXIT
27
28WORKDIR=$(mktemp -d libdivsufsort.XXXXXX)
29INCLUDESDIR="${LOCAL_PATH}/android_include"
30
31pushd "${WORKDIR}"
32cmake "${LOCAL_PATH}" \
33  -DBUILD_DIVSUFSORT64=1 \
34  -DBUILD_EXAMPLES=0 \
35  -DUSE_OPENMP=0 \
36  -DWITH_LFS=1
37
38mkdir -p "${INCLUDESDIR}"
39echo "Copying headers:"
40cp -v include/*.h "${INCLUDESDIR}/"
41popd >/dev/null
42
43cat <<EOF
44=============================================================
45Remember to run the following command to add the new headers:
46
47  git add android_include/*
48
49EOF
50