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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
|
# Copyright (C) 2011-2013,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 libtoolcxx pkgconfig verbose_compile pkgconfig_dep gettext x11 lfs"
LTSHARED=1
DEFAULT_LINGUAS=nl
SWITCHES="+x11 +gpm"
USERHELP=print_help
INSTALLDIRS="libdir docdir includedir"
print_help() {
echo " --without-x11 Do not include X11 integration"
echo " --without-gpm Do not include GPM support"
}
test_select() {
DESC="$1"
shift
clean_cxx
for HEADER in "$@"
do
echo "#include <${HEADER}>"
done > .configcxx.cc
cat >> .configcxx.cc <<EOF
#include <stdlib.h>
int main(int argc, char *argv[]) {
fd_set test;
FD_ZERO(&test);
FD_SET(0, &test);
if (FD_ISSET(0, &test))
FD_CLR(0, &test);
select(1, &test, NULL, NULL, NULL);
return 0;
}
EOF
test_link_cxx "${DESC}"
}
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
if [ "$CXX11" != 1 ] ; then
error "!! libt3widget requires a C++11 compatible compiler"
fi
clean_cxx
cat > .configcxx.cc <<EOF
#include <math.h>
int main(int argc, char *argv[]) {
floor(0.5);
ceil(0.5);
return 0;
}
EOF
if test_compile_cxx "math functions" ; then
if test_link_cxx "math functions in standard library" ; then
:
elif test_link_cxx "math functions in -lm" ; then
CONFIGLIBS="$CONFIGLIBS -lm"
else
error "!! Can not find library for basic math functions"
fi
else
error "!! Can not find basic math functions"
fi
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.2 LIBTRANSCRIPT test_link_cxx PKGCONFIG_REQUIRES_PRIVATE || \
error "!! Can not find libtranscript. libtranscript is required to compile libt3widget."
clean_cxx
cat > .configcxx.cc <<EOF
#include <unictype.h>
#include <unicase.h>
int main(int argc, char *argv[]) {
uint8_t buffer[10];
size_t buffer_size = sizeof(buffer);
size_t out_size;
char nul = 0;
u8_casefold(buffer, buffer_size, NULL, NULL, NULL, &out_size);
uc_is_general_category_withtable(0x1234, UC_CATEGORY_MASK_Zs);
uc_is_property_id_continue(0x1234);
return 0;
}
EOF
test_link_cxx "libunistring" "TESTLIBS=-lunistring" || \
error "!! Can not find libunistring library. Libunistring is required to compile libt3widget."
clean_cxx
cat > .configcxx.cc <<EOF
#include <t3window/window.h>
#include <t3window/terminal.h>
int main(int argc, char *argv[]) {
t3_window_get_version();
return 0;
}
EOF
pkgconfig libt3window/0.4.0 LIBT3WINDOW test_link_cxx PKGCONFIG_REQUIRES || \
error "!! Can not find libt3window. libt3window is required to compile libt3widget."
clean_cxx
cat > .configcxx.cc <<EOF
#include <t3key/key.h>
int main(int argc, char *argv[]) {
t3_key_get_version();
return 0;
}
EOF
pkgconfig libt3key/0.2.0 LIBT3KEY test_link_cxx PKGCONFIG_REQUIRES_PRIVATE || \
error "!! Can not find libt3key. libt3key is required to compile libt3widget."
clean_cxx
cat > .configcxx.cc <<EOF
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
int main(int argc, char *argv[]) {
int code;
PCRE2_SIZE err_offset;
pcre2_code_8 *pcre = pcre2_compile_8(reinterpret_cast<PCRE2_SPTR8>("pattern"), PCRE2_ZERO_TERMINATED, PCRE2_UTF | PCRE2_CASELESS, &code, &err_offset, nullptr);
return 0;
}
EOF
pkgconfig libpcre2-8 LIBPCRE test_link_cxx PKGCONFIG_REQUIRES_PRIVATE || {
clean_c
cat > .configcxx.cc <<EOF
#include <pcre.h>
int main(int argc, char *argv[]) {
int err;
int err_offset;
const char *error_message;
pcre *pcre = pcre_compile2("pattern", PCRE_UTF8, &err, &error_message, &err_offset, NULL);
return 0;
}
EOF
pkgconfig libpcre LIBPCRE test_link PKGCONFIG_REQUIRES_PRIVATE && \
CONFIGFLAGS="${CONFIGFLAGS} -DPCRE_COMPAT"
} || \
error "!! Can not find libpcre2-8. libpcre2-8 is required to compile libt3widget."
if test_select "select in <sys/select.h>" "sys/select.h" ; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAS_SELECT_H"
else
test_select "select in <unistd.h>" "sys/time.h" "sys/types.h" "unistd.h" || error "!! Can not find required select function."
fi
unset PTHREADFLAGS PTHREADLIBS
clean_cxx
cat > .configcxx.cc <<EOF
int main(int argc, char *argv[]) {
(void) argc;
(void) argv;
return 0;
}
EOF
test_link_cxx "pthread library -lpthread" TESTLIBS=-lpthread && CONFIGLIBS="$CONFIGLIBS -lpthread"
cat > .configcxx.cc <<EOF
#include <math.h>
int main(int argc, char *argv[]) {
ceil((double) argc);
return 0;
}
EOF
test_link_cxx "ceil in standard library" || {
if test_link_cxx "ceil in -lm" TESTLIBS=-lm ; then
CONFIGLIBS="${CONFIGLIBS} -lm"
else
error "!! Can not find required linker flags for ceil function. See config.log for details."
fi
}
clean_cxx
cat > .configcxx.cc <<EOF
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <fnmatch.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <dirent.h>
int main(int argc, char *argv[]) {
struct sigaction sa;
struct stat statbuf;
int fds[2];
char buffer[100];
DIR *dir;
struct dirent *entry;
struct timeval tv;
sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGWINCH);
sigaction(SIGWINCH, &sa, NULL);
sigprocmask(SIG_UNBLOCK, &sa.sa_mask, NULL);
fnmatch("a", "b", 0);
stat("file", &statbuf);
pipe(fds);
close(fds[0]);
read(fds[0], buffer, sizeof(buffer));
write(fds[0], buffer, sizeof(buffer));
snprintf(buffer, sizeof(buffer), "foo");
kill(0, SIGWINCH);
getpid();
dir = opendir("foo");
entry = readdir(dir);
closedir(dir);
getcwd(buffer, sizeof(buffer));
gettimeofday(&tv, NULL);
return 0;
}
EOF
test_link_cxx "other required common Un*x functions" || {
check_message_result "Testing required functions seperatly for debugging purposes"
checkfunction "sigemptyset" "struct sigaction sa; sigemptyset(&sa.sa_mask);" "<signal.h>"
checkfunction "sigaddset" "struct sigaction sa; sigaddset(&sa.sa_mask, SIGWINCH);" "<signal.h>"
checkfunction "sigaction" "struct sigaction sa; sigaction(SIGWINCH, &sa, NULL);" "<stdlib.h>" "<signal.h>"
checkfunction "sigprocmask" "struct sigaction sa; sigprocmask(SIG_UNBLOCK, &sa.sa_mask, NULL);" "<stdlib.h>" "<signal.h>"
checkfunction "fnmatch" 'fnmatch("a", "b", 0);' "<fnmatch.h>"
checkfunction "stat" 'struct stat statbuf; stat("file", &statbuf);' "<sys/types.h>" "<sys/stat.h>" "<unistd.h>"
checkfunction "pipe" 'int fds[2]; pipe(fds);' "<unistd.h>"
checkfunction "close" 'int fd; close(fd);' "<unistd.h>"
checkfunction "read" 'char buffer[100]; int fd; read(fd, buffer, sizeof(buffer));' "<unistd.h>"
checkfunction "write" 'char buffer[100]; int fd; read(fd, buffer, sizeof(buffer));' "<unistd.h>"
checkfunction "snprintf" 'char buffer[100]; snprintf(buffer, sizeof(buffer), "foo");' "<stdio.h>"
checkfunction "kill" 'kill(0, SIGWINCH);' "<sys/types.h>" "<signal.h>"
checkfunction "getpid" 'getpid();' "<sys/types.h>" "<unistd.h>"
checkfunction "opendir" 'DIR *dir = opendir("foo");' "<sys/types.h>" "<dirent.h>"
checkfunction "readdir" 'DIR *dir; struct dirent *entry = readdir(dir);' "<sys/types.h>" "<dirent.h>"
checkfunction "closedir" 'DIR *dir; closedir(dir);' "<sys/types.h>" "<dirent.h>"
checkfunction "getcwd" 'char buffer[100]; getcwd(buffer, sizeof(buffer));' "<unistd.h>"
checkfunction "gettimeofday" 'struct timeval tv; gettimeofday(&tv, NULL);' "<sys/time.h>"
error "!! A required Un*x function was not found. See config.log for details."
}
clean_cxx
cat > .configcxx.cc <<EOF
#include <string.h>
int main(int argc, char *argv[]) {
strdup(argv[0]);
return 0;
}
EOF
test_link_cxx "strdup" && CONFIGFLAGS="${CONFIGFLAGS} -DHAS_STRDUP"
unset X11MODULE
if [ yes = "${with_x11}" ] ; then
unset HAS_DYNAMIC DL_FLAGS DL_LIBS
clean_cxx
cat > .configcxx.cc <<EOF
#include <dlfcn.h>
int main(int argc, char *argv[]) {
void *handle = dlopen("name", RTLD_LOCAL);
dlsym(handle, "func");
dlclose(handle);
return 0;
}
EOF
if test_compile_cxx "dlopen/dlsym/dlclose in dlfcn.h" ; then
if test_link_cxx "dlopen/dlsym/dlclose in standard library" ; then
HAS_DYNAMIC=y
DL_FLAGS=-DHAS_DLFCN
elif test_link_cxx "dlopen/dlsym/dlclose in -ldl" TESTLIBS=-ldl ; then
HAS_DYNAMIC=y
DL_FLAGS=-DHAS_DLFCN
DL_LIBS=-ldl
fi
fi
if [ -z "$HAS_DYNAMIC" ] ; then
clean_cxx
cat > .configcxx.cc <<EOF
#include <ltdl.h>
int main(int argc, char *argv[]) {
lt_dlhandle handle;
handle = lt_dlopen("name");
lt_dlsym(handle, "sym_name");
lt_dlclose(handle);
lt_dlinit();
lt_dlexit();
return 0;
}
EOF
if test_link_cxx "libltdl" "TESTLIBS=-lltdl" ; then
HAS_DYNAMIC=y
DL_LIBS=-ltdl
fi
fi
clean_cxx
cat > .configcxx.cc <<EOF
#include <stdlib.h>
#include <xcb/xcb.h>
int main(int argc, char *argv[]) {
int value;
xcb_connection_t *c = xcb_connect(NULL, NULL);
value = XCB_TIME_CURRENT_TIME;
value = XCB_ATOM_WM_NAME;
value = XCB_ATOM_STRING;
value = XCB_ATOM_NONE;
}
EOF
if [ -z "$HAS_DYNAMIC" ] ; then
check_message_result "!! Could not find dlfcn functions or libltdl. libt3widget will not provide X11 clipboard integration."
elif pkgconfig xcb X11 test_link_cxx ; then
CONFIGFLAGS="$CONFIGFLAGS -DWITH_X11 $DL_FLAGS"
CONFIGLIBS="$CONFIGLIBS $DL_LIBS"
X11MODULE=src/libt3widget2-x11.la
else
check_message_result "!! Could not find the libxcb library. libt3widget will not provide X11 clipboard integration."
fi
fi
if [ yes = "${with_gpm}" ] ; then
clean_cxx
cat > .configcxx.cc <<EOF
#include <gpm.h>
#include <linux/keyboard.h>
int main(int argc, char *argv[]) {
Gpm_Connect connect;
Gpm_Event event;
Gpm_Open(&connect, 0);
Gpm_GetEvent(&event);
event.modifiers = (1 << KG_SHIFT);
}
EOF
if test_link_cxx "GPM" TESTLIBS="-lgpm" ; then
CONFIGFLAGS="$CONFIGFLAGS -DHAS_GPM"
CONFIGLIBS="$CONFIGLIBS -lgpm"
else
check_message_result "!! Could not locate GPM. libt3widget will not provide GPM support."
fi
fi
cat > .configcxx.cc <<EOF
#include <string>
int main(int argc, char *argv[]) {
std::string test;
test.shrink_to_fit();
return 0;
}
EOF
if test_link_cxx "shrink_to_fit in string" CXXFLAGS="${CXXFLAGS}"; then
CONFIGFLAGS="${CONFIGFLAGS} -DHAS_STRING_SHRINK_TO_FIT"
fi
PKGCONFIG_DESC="Dialog toolkit library"
PKGCONFIG_VERSION="1.2.0"
PKGCONFIG_URL="http://os.ghalkes.nl/t3/libt3widget.html"
PKGCONFIG_CFLAGS="-I\${includedir}/t3/widget"
PKGCONFIG_LIBS="-lt3widget"
PKGCONFIG_LIBS_PRIVATE="${PKGCONFIG_LIBS_PRIVATE} ${PTHREADLIBS} ${CONFIGLIBS} -lunistring"
gen_pkgconfig libt3widget
create_makefile "CONFIGFLAGS=${CONFIGFLAGS} ${LIBTRANSCRIPT_FLAGS} \
${LIBT3KEY_FLAGS} ${LIBT3WINDOW_FLAGS} ${LIBPCRE_FLAGS} ${PTHREADFLAGS}" \
"CONFIGLIBS=${CONFIGLIBS} ${LIBTRANSCRIPT_LIBS} -lunistring \
${LIBT3KEY_LIBS} ${LIBT3WINDOW_LIBS} ${LIBPCRE_LIBS} ${PTHREADLIBS}" \
"X11MODULE=${X11MODULE}" "X11_FLAGS=${X11_FLAGS}" "X11_LIBS=${X11_LIBS}"
}
|