1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
# Copyright (C) 2011-2012,2018 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTENSIONS="cxx verbose_compile pkgconfig_dep gettext lfs"
DEFAULT_LINGUAS=nl
INSTALLDIRS="bindir docdir mandir"
checkfunction_internal() {
clean_cxx
FUNC="$1"
CHECKFOR="$2"
CODE="$3"
shift 3
{
for INCLUDE
do
echo "#include ${INCLUDE}"
done
cat <<EOF
int main(int argc, char *argv[]) {
${CODE}
return 0;
}
EOF
} > .configcxx.cc
"${FUNC}" "${CHECKFOR}"
}
checkfunction() {
checkfunction_internal test_link_cxx "$@"
}
checkfunction_compile() {
checkfunction_internal test_compile_cxx "$@"
}
config() {
has_support_cxx11
clean_cxx
cat > .configcxx.cc <<EOF
#include <transcript/transcript.h>
int main(int argc, char *argv[]) {
transcript_get_version();
return 0;
}
EOF
pkgconfig libtranscript/0.2.0 LIBTRANSCRIPT test_link_cxx || \
error "!! Can not find libtranscript. libtranscript is required to compile tilde."
clean_cxx
cat > .configcxx.cc <<EOF
#include <uninorm.h>
int main(int argc, char *argv[]) {
uint8_t buffer[10];
size_t buffer_size = sizeof(buffer);
size_t out_size;
u8_normalize(UNINORM_NFC, buffer, buffer_size, NULL, &out_size);
return 0;
}
EOF
test_link_cxx "libunistring" "TESTLIBS=-lunistring" || \
error "!! Can not find libunistring library. Libunistring is required to compile tilde."
clean_cxx
cat > .configcxx.cc <<EOF
#include <t3widget/widget.h>
using namespace t3widget;
int main(int argc, char *argv[]) {
get_version();
return 0;
}
EOF
pkgconfig libt3widget/1.2.0 LIBT3WIDGET test_link_cxx || \
error "!! Can not find libt3widget. libt3widget is required to compile tilde."
clean_cxx
cat > .configcxx.cc <<EOF
#include <t3config/config.h>
int main(int argc, char *argv[]) {
t3_config_get_version();
return 0;
}
EOF
pkgconfig libt3config/1.0.0 LIBT3CONFIG test_link_cxx || \
error "!! Can not find libt3config. libt3config is required to compile tilde."
clean_cxx
cat > .configcxx.cc <<EOF
#include <t3highlight/highlight.h>
int main(int argc, char *argv[]) {
t3_highlight_get_version();
return 0;
}
EOF
pkgconfig libt3highlight/0.4.0 LIBT3HIGHLIGHT test_link_cxx || \
error "!! Can not find libt3highlight. libt3highlight is required to compile tilde."
clean_cxx
cat > .configcxx.cc <<EOF
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <cstdlib>
#include <cstdarg>
#include <cstdio>
#include <signal.h>
#include <fnmatch.h>
#include <dirent.h>
int main(int argc, char *argv[]) {
int fd;
struct stat statbuf;
char buf[1024];
size_t bufsiz;
va_list ap;
close(fd);
fstat(fd, &statbuf);
fchmod(fd, 0644);
fsync(fd);
ftruncate(fd, 5);
off_t offset = lseek(fd, 0, SEEK_CUR);
fd = open("name", O_RDONLY);
unlink("name");
bufsiz = readlink("path", buf, sizeof(buf));
fd = mkstemp("pathXXXXXX");
vsnprintf(buf, sizeof(buf), "fmt", ap);
fdopen(fd, "r+");
return 0;
}
EOF
test_link_cxx "other required common Un*x functions" || {
check_message_result "Testing required functions seperatly for debugging purposes"
checkfunction "close" 'int fd; close(fd);' "<unistd.h>"
checkfunction "fstat" 'int fd; struct stat statbuf; fstat(fd, &statbuf);' "<sys/types.h>" "<sys/stat.h>" "<unistd.h>"
checkfunction "fchmod" 'int fd; fchmod(fd, 0);' "<sys/stat.h>"
checkfunction "fsync" 'int fd; fsync(fd);' "<unistd.h>"
checkfunction "ftruncate" 'int fd; ftruncate(fd, 5);' "<unistd.h>" "<sys/types.h>"
checkfunction "lseek" 'int fd; off_t offset = lseek(fd, 0, SEEK_CUR);' "<sys/types.h>" "<unistd.h>"
checkfunction "open" 'int fd = open("name", O_RDONLY);' "<fcntl.h>" "<sys/stat.h>" "<sys/types.h>"
checkfunction "unlink" 'unlink("name");' "<unistd.h>"
checkfunction "readlink" 'char buf[1024]; size_t bufsiz; bufsiz = readlink("path", buf, sizeof(buf));' "<unistd.h>"
checkfunction "mkstemp" 'mkstemp("pathXXXXXX");' "<cstdlib>"
checkfunction "vsnprintf" 'char buf[1024]; va_list ap; vsnprintf(buf, sizeof(buf), "fmt", ap);' "<cstdio>" "<cstdarg>"
checkfunction "fdopen" 'int fd; fdopen(fd, "r+");' "<cstdio>"
error "!! A required Un*x function was not found. See config.log for details."
}
clean_cxx
cat > .configcxx.cc <<EOF
#include <fcntl.h>
int main(int argc, char *argv[]) {
posix_fallocate(1, 0, 10);
}
EOF
if test_link_cxx "posix_fallocate" ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAS_POSIX_FALLOCATE"
fi
clean_cxx
cat > .configcxx.cc <<EOF
#ifndef __linux__
#error sendfile should only be used on linux, as different platforms have different semantics
#endif
#include <sys/sendfile.h>
int main(int argc, char *argv[]) {
off_t offset = 0;
sendfile(1, 2, &offset, 10);
}
EOF
if test_link_cxx "Linux sendfile" ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAS_SENDFILE"
fi
clean_cxx
cat > .configcxx.cc <<EOF
#define _GNU_SOURCE
#include <unistd.h>
int main(int argc, char *argv[]) {
off_t in, out;
copy_file_range(1, &in, 2, &out, 10, 0);
}
EOF
if test_link_cxx "copy_file_range" ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAS_COPY_FILE_RANGE"
fi
clean_cxx
cat > .configcxx.cc <<EOF
#include <linux/fs.h>
#include <sys/ioctl.h>
int main(int argc, char *argv[]) {
int fd;
ioctl(1, FICLONE, fd);
}
EOF
if test_link_cxx "ficlone" ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAS_FICLONE"
fi
create_makefile "CONFIGFLAGS=${CONFIGFLAGS} ${LIBTRANSCRIPT_FLAGS} ${LIBT3WIDGET_FLAGS} ${LIBT3CONFIG_FLAGS} ${LIBT3HIGHLIGHT_FLAGS}" \
"CONFIGLIBS=${CONFIGLIBS} ${LIBTRANSCRIPT_LIBS} -lunistring ${LIBT3WIDGET_LIBS} ${LIBT3CONFIG_LIBS} ${LIBT3HIGHLIGHT_LIBS}"
}
|