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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
|
#!/bin/sh
##########################################################################
# compile.sh - Unix/X11 configuration script
# $Date: 2007/07/01 09:46:46 $
# $Revision: 1.15 $
#
# This is a minimalist configuration script for GLFW, which is used to
# determine the availability of certain features.
#
# This script is not very nice at all (especially the Makefile generation
# is very ugly and hardcoded). Hopefully it will be cleaned up in the
# future, but for now it does a pretty good job.
##########################################################################
##########################################################################
# Check arguments
##########################################################################
silent=no
for arg in "$@"; do
{
case "$arg" in
# Silent?
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
esac;
}
done;
##########################################################################
# Misc.
##########################################################################
config_script=$0
# File descriptor usage:
# 0 standard input
# 1 file creation
# 2 errors and warnings
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 compiler messages saved in config.log
# 6 checking for... messages and results
exec 5>./config.log
if [ "x$silent" = xyes ]; then
exec 6>/dev/null
else
exec 6>&1
fi
echo "\
This file contains any messages produced by compilers while
running $config_script, to aid debugging if $config_script makes a mistake.
" 1>&5
##########################################################################
# Default compiler settings
##########################################################################
if [ "x$CC" = x ]; then
CC=cc
fi
CFLAGS=
LFLAGS=
LDFLAGS=
INCS=
LIBS="-lGL -lX11"
##########################################################################
# Compilation commands
##########################################################################
compile='$CC -c $CFLAGS conftest.c 1>&5'
link='$CC -o conftest $CFLAGS $LFLAGS conftest.c $LIBS 1>&5'
##########################################################################
# Check on what system we are running
##########################################################################
echo "Checking what kind of system this is... " 1>&6
case "x`uname 2> /dev/null`" in
xLinux)
CFLAGS="$CFLAGS -Dlinux"
LDFLAGS="-shared"
echo " Linux" 1>&6
;;
xDarwin)
CFLAGS="$CFLAGS"
LDFLAGS="-flat_namespace -undefined suppress"
echo " Mac OS X" 1>&6
;;
*)
LDFLAGS="-shared -soname libglfw.so"
echo " Generic Unix" 1>&6
;;
esac
echo " " 1>&6
##########################################################################
# Check for X11 libs/include directories
##########################################################################
echo "Checking for X11 libraries location... " 1>&6
# X11R6 in /usr/X11/lib ?
if [ -r "/usr/X11/lib" ]; then
LFLAGS="$LFLAGS -L/usr/X11/lib"
INCS="-I/usr/X11/include"
echo " X11 libraries location: /usr/X11/lib" 1>&6
# X11R/ in /usr/X11R7/lib ?
elif [ -r "/usr/X11R7/lib" ]; then
LFLAGS="$LFLAGS -L/usr/X11R7/lib"
INCS="-I/usr/X11R7/include"
echo " X11 libraries location: /usr/X11R7/lib" 1>&6
# X11R6 in /usr/X11R6/lib ?
elif [ -r "/usr/X11R6/lib" ]; then
LFLAGS="$LFLAGS -L/usr/X11R6/lib"
INCS="-I/usr/X11R6/include"
echo " X11 libraries location: /usr/X11R6/lib" 1>&6
# X11R5 in /usr/X11R5/lib ?
elif [ -r "/usr/X11R5/lib" ]; then
LFLAGS="$LFLAGS -L/usr/X11R5/lib"
INCS="-I/usr/X11R5/include"
echo " X11 libraries location: /usr/X11R5/lib" 1>&6
# X11R6 in /opt/X11R6/lib (e.g. QNX)?
elif [ -r "/opt/X11R6/lib" ]; then
LFLAGS="$LFLAGS -L/opt/X11R6/lib"
INCS="-I/opt/X11R6/include"
echo " X11 libraries location: /opt/X11R6/lib" 1>&6
# X11R6 in /usr/X/lib ?
elif [ -r "/usr/X/lib" ]; then
LFLAGS="$LFLAGS -L/usr/X/lib"
INCS="-I/usr/X/include"
echo " X11 libraries location: /usr/X/lib" 1>&6
else
# TODO: Detect and report X11R7 in /usr/lib
echo " X11 libraries location: Unknown (assuming linker will find them)" 1>&6
fi
echo " " 1>&6
CFLAGS="$CFLAGS $INCS"
##########################################################################
# Check if we are using GNU C
##########################################################################
echo "Checking whether we are using GNU C... " 1>&6
echo "$config_script: checking whether we are using GNU C" >&5
cat > conftest.c <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if { ac_try='$CC -E conftest.c'; { (eval echo $config_script: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
use_gcc=yes
else
use_gcc=no
fi
rm -f conftest*
echo " Using GNU C: ""$use_gcc" 1>&6
if [ "x$use_gcc" = xyes ]; then
CC=gcc
fi
echo " " 1>&6
##########################################################################
# Check for X11 RandR availability
##########################################################################
echo "Checking for X11 RandR support... " 1>&6
echo "$config_script: Checking for X11 RandR support" >&5
has_xrandr=no
cat > conftest.c <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
int main() {; return 0;}
EOF
if { (eval echo $config_script: \"$compile\") 1>&5; (eval $compile) 2>&5; }; then
rm -rf conftest*
has_xrandr=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
rm -f conftest*
echo " X11 RandR extension: ""$has_xrandr" 1>&6
if [ "x$has_xrandr" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_XRANDR"
LIBS="$LIBS -lXrandr"
fi
echo " " 1>&6
##########################################################################
# Check for X11 VidMode availability
##########################################################################
if [ "x$has_xrandr" != xyes ]; then
echo "Checking for X11 VidMode support... " 1>&6
echo "$config_script: Checking for X11 VidMode support" >&5
has_xf86vm=no
cat > conftest.c <<EOF
#include <X11/Xlib.h>
#include <X11/extensions/xf86vmode.h>
#if defined(__APPLE_CC__)
#error Not supported under Mac OS X
#endif
int main() {; return 0;}
EOF
if { (eval echo $config_script: \"$compile\") 1>&5; (eval $compile) 2>&5; }; then
rm -rf conftest*
has_xf86vm=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
rm -f conftest*
echo " X11 VidMode extension: ""$has_xf86vm" 1>&6
if [ "x$has_xf86vm" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_XF86VIDMODE"
LIBS="$LIBS -lXxf86vm -lXext"
fi
echo " " 1>&6
fi
##########################################################################
# Check for pthread support
##########################################################################
echo "Checking for pthread support... " 1>&6
echo "$config_script: Checking for pthread support" >&5
has_pthread=no
cat > conftest.c <<EOF
#include <pthread.h>
int main() {pthread_t posixID; posixID=pthread_self(); return 0;}
EOF
# Try -pthread (most systems)
CFLAGS_THREAD="-pthread"
CFLAGS_OLD="$CFLAGS"
CFLAGS="$CFLAGS $CFLAGS_THREAD"
LIBS_OLD="$LIBS"
LIBS="$LIBS -pthread"
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_pthread=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
# Try -lpthread
if [ "x$has_pthread" = xno ]; then
CFLAGS_THREAD="-D_REENTRANT"
CFLAGS="$CFLAGS_OLD $CFLAGS_THREAD"
LIBS="$LIBS_OLD -lpthread"
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_pthread=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
fi
# Try -lsocket (e.g. QNX)
if [ "x$has_pthread" = xno ]; then
CFLAGS="$CFLAGS_OLD"
LIBS="$LIBS_OLD -lsocket"
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_pthread=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
fi
echo " pthread support: ""$has_pthread" 1>&6
if [ "x$has_pthread" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_PTHREAD"
else
LIBS="$LIBS_OLD"
fi
echo " " 1>&6
##########################################################################
# Check for sched_yield support
##########################################################################
if [ "x$has_pthread" = xyes ]; then
echo "Checking for sched_yield support... " 1>&6
echo "$config_script: Checking for sched_yield support" >&5
has_sched_yield=no
LIBS_OLD="$LIBS"
cat > conftest.c <<EOF
#include <pthread.h>
int main() {sched_yield(); return 0;}
EOF
if { (eval echo $config_script: \"$compile\") 1>&5; (eval $compile) 2>&5; }; then
has_sched_yield=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
if [ "x$has_sched_yield" = xno ]; then
LIBS="$LIBS_OLD -lrt"
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
has_sched_yield=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
LIBS="$LIBS_OLD"
fi
fi
rm -f conftest*
echo " sched_yield: ""$has_sched_yield" 1>&6
if [ "x$has_sched_yield" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_SCHED_YIELD"
fi
echo " " 1>&6
fi
##########################################################################
# Check for glXGetProcAddressXXX availability
##########################################################################
echo "Checking for glXGetProcAddress support... " 1>&6
echo "$config_script: Checking for glXGetProcAddress support" >&5
has_glXGetProcAddress=no
has_glXGetProcAddressARB=no
has_glXGetProcAddressEXT=no
# glXGetProcAddress check
cat > conftest.c <<EOF
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <GL/gl.h>
int main() {void *ptr=(void*)glXGetProcAddress("glFun"); return 0;}
EOF
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_glXGetProcAddress=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
rm -f conftest*
# glXGetProcAddressARB check
cat > conftest.c <<EOF
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <GL/gl.h>
int main() {void *ptr=(void*)glXGetProcAddressARB("glFun"); return 0;}
EOF
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_glXGetProcAddressARB=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
rm -f conftest*
# glXGetProcAddressEXT check
cat > conftest.c <<EOF
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <GL/gl.h>
int main() {void *ptr=(void*)glXGetProcAddressEXT("glFun"); return 0;}
EOF
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_glXGetProcAddressEXT=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
rm -f conftest*
echo " glXGetProcAddress extension: ""$has_glXGetProcAddress" 1>&6
echo " glXGetProcAddressARB extension: ""$has_glXGetProcAddressARB" 1>&6
echo " glXGetProcAddressEXT extension: ""$has_glXGetProcAddressEXT" 1>&6
if [ "x$has_glXGetProcAddress" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_GLXGETPROCADDRESS"
fi
if [ "x$has_glXGetProcAddressARB" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_GLXGETPROCADDRESSARB"
fi
if [ "x$has_glXGetProcAddressEXT" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_GLXGETPROCADDRESSEXT"
fi
echo " " 1>&6
##########################################################################
# Check for dlopen support
##########################################################################
echo "Checking for dlopen support... " 1>&6
echo "$config_script: Checking for dlopen support" >&5
has_dlopen=no
cat > conftest.c <<EOF
#include <dlfcn.h>
int main() {void *l=dlopen("libGL.so",RTLD_LAZY|RTLD_GLOBAL); return 0;}
EOF
# First try without -ldl
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_dlopen=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
# Now try with -ldl if the previous attempt failed
if [ "x$has_dlopen" = xno ]; then
LIBS_OLD="$LIBS"
LIBS="$LIBS -ldl"
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_dlopen=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
if [ "x$has_dlopen" = xno ]; then
LIBS="$LIBS_OLD"
fi
fi
rm -f conftest*
echo " dlopen support: ""$has_dlopen" 1>&6
if [ "x$has_dlopen" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_DLOPEN"
fi
echo " " 1>&6
##########################################################################
# Check for sysconf support
##########################################################################
echo "Checking for sysconf support... " 1>&6
echo "$config_script: Checking for sysconf support" >&5
has_sysconf=no
cat > conftest.c <<EOF
#include <unistd.h>
#ifndef _SC_NPROCESSORS_ONLN
#ifndef _SC_NPROC_ONLN
#error Neither _SC_NPROCESSORS_ONLN nor _SC_NPROC_ONLN available
#endif
#endif
int main() {long x=sysconf(_SC_ARG_MAX); return 0; }
EOF
if { (eval echo $config_script: \"$link\") 1>&5; (eval $link) 2>&5; }; then
rm -rf conftest*
has_sysconf=yes
else
echo "$config_script: failed program was:" >&5
cat conftest.c >&5
fi
rm -f conftest*
echo " sysconf support: ""$has_sysconf" 1>&6
if [ "x$has_sysconf" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_SYSCONF"
fi
echo " " 1>&6
##########################################################################
# Check for sysctl support
##########################################################################
echo "Checking for sysctl support... " 1>&6
echo "$config_script: Checking for sysctl support" >&5
has_sysctl=no
cat > conftest.c <<EOF
#include <sys/types.h>
#include <sys/sysctl.h>
#ifdef CTL_HW
#ifdef HW_NCPU
yes;
#endif
#endif
EOF
if { ac_try='$CC -E conftest.c'; { (eval echo $config_script: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
has_sysctl=yes
fi
rm -f conftest*
echo " sysctl support: ""$has_sysctl" 1>&6
if [ "x$has_sysctl" = xyes ]; then
CFLAGS="$CFLAGS -D_GLFW_HAS_SYSCTL"
fi
echo " " 1>&6
##########################################################################
# Post fixups
##########################################################################
if [ "x$use_gcc" = xyes ]; then
CFLAGS_SPEED="-c -I. -I.. $CFLAGS -O3 -ffast-math -Wall"
CFLAGS="-c -I. -I.. $CFLAGS -Os -Wall"
CFLAGS_LINK="$INCS -O3 -ffast-math -Wall"
else
CFLAGS_SPEED="-c -I. -I.. $CFLAGS -O"
CFLAGS="-c -I. -I.. $CFLAGS -O"
CFLAGS_LINK="$INCS -O"
fi
CFLAGS_LINK="-I../include $CFLAGS_LINK"
LFLAGS_LINK="../lib/x11/libglfw.a $LFLAGS -lGLU $LIBS -lm"
##########################################################################
# Create Makefiles
##########################################################################
# ./lib/x11/Makefile.x11
MKNAME='./lib/x11/Makefile.x11'
echo "Creating ""$MKNAME""..." 1>&6
echo " " 1>&6
echo "$config_script: Creating ""$MKNAME""..." >&5
echo "##########################################################################" >$MKNAME
echo "# Automatically generated Makefile for GLFW" >>$MKNAME
echo "##########################################################################" >>$MKNAME
echo "CC = $CC" >>$MKNAME
echo "CFLAGS = $CFLAGS" >>$MKNAME
echo "CFLAGS_SPEED = $CFLAGS_SPEED" >>$MKNAME
echo "LDFLAGS = $LDFLAGS" >>$MKNAME
echo "LFLAGS = $LFLAGS" >>$MKNAME
echo "LIBS = $LIBS" >>$MKNAME
echo " " >>$MKNAME
cat './lib/x11/Makefile.x11.in' >>$MKNAME
# ./examples/Makefile.x11
MKNAME='./examples/Makefile.x11'
echo "Creating ""$MKNAME""..." 1>&6
echo " " 1>&6
echo "$config_script: Creating ""$MKNAME""..." >&5
echo "##########################################################################" >$MKNAME
echo "# Automatically generated Makefile for GLFW" >>$MKNAME
echo "##########################################################################" >>$MKNAME
echo "CC = $CC" >>$MKNAME
echo "CFLAGS = $CFLAGS_LINK" >>$MKNAME
echo "LFLAGS = $LFLAGS_LINK" >>$MKNAME
echo " " >>$MKNAME
cat './examples/Makefile.x11.in' >>$MKNAME
##########################################################################
# Create pkg-config template file
##########################################################################
# ./lib/x11/libglfw.pc.in
MKNAME="./lib/x11/libglfw.pc.in"
echo "Creating ""$MKNAME""..." 1>&6
echo " " 1>&6
echo "$config_script: Creating ""$MKNAME""..." >&5
cat > "$MKNAME" <<EOF
prefix=@PREFIX@
exec_prefix=@PREFIX@
libdir=@PREFIX@/lib
includedir=@PREFIX@/include
Name: GLFW
Description: A portable framework for OpenGL development
Version: 2.6.0
URL: http://glfw.sourceforge.net/
Libs: -L\${libdir} -lglfw $LFLAGS $LIBS -lm
Cflags: -I\${includedir} $CFLAGS_THREAD
EOF
|