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 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
|
#!/bin/sh
# Mini configure script
# 26-01-2011
echo
MT_V="3.50.13"
MT_DATE="2025-12-06"
MT_VERSION="mtPaint $MT_V"
MT_LANG=YES
MT_MAN=YES
MT_POD=NO
MT_CPICK=mtpaint
MT_FPICK=mtpaint
MT_LISTS=2
MT_ANIM=Gifsicle
ICON_SET=icons1
GTK_FILE=_conf.txt
HELP=1
OS=
MARCH=
OPTS=YES
USE_THREADS=YES
AS_NEEDED=
DEFS=
WARN=
# Path overrides
MT_BINDIR=
MT_DATAROOT=
MT_DOCDIR=
MT_LOCDIR=
MT_MANDIR=
MT_PO=
MT_HOST=
# Initialize library-tracking vars
STATICLIBS=
for A in PNG JPEG JP2 TIFF WEBP FT CMS
do
eval "N$A="
eval "STATIC_$A="
STATICLIBS="$STATICLIBS \$STATIC_$A"
done
GTK=
GTKVERSION=
# Prevent nasty surprises from locale
unset LC_ALL
export LC_COLLATE=C # LC_CTYPE=C LC_NUMERIC=C
for A in "$@"
do
case "$A" in
"staticpng" ) STATIC_PNG=PNG;;
"jpeg" ) NJPEG=YES;;
"nojpeg" ) NJPEG=NO;;
"staticjpeg" ) STATIC_JPEG=JPEG;;
"jp2v1" ) NJP2=OpenJPEG;;
"jp2v2" ) NJP2=OpenJPEG2;;
"jasper" ) NJP2=JasPer;;
"nojp2" ) NJP2=NO;;
"staticjp2" ) STATIC_JP2=JPEG2000;;
"tiff" ) NTIFF=YES;;
"notiff" ) NTIFF=NO;;
"statictiff" ) STATIC_TIFF=TIFF;;
"webp" ) NWEBP=YES;;
"nowebp" ) NWEBP=NO;;
"staticwebp" ) STATIC_WEBP=WebP;;
"noft" ) NFT=NO;;
"staticft" ) STATIC_FT=FreeType;;
"lcms" ) NCMS=LittleCMS;;
"lcms2" ) NCMS=LittleCMS2;;
"nolcms" ) NCMS=NO;;
"staticlcms" ) STATIC_CMS=LittleCMS;;
"gtk1" ) GTK=1;;
"gtk"[23]* ) GTK=2
[ "$A" != "${A#gtk3}" ] && GTK=3
# Override minor version of installed GTK+
GTKVERSION="`echo "$A" | sed -e 's/gtk[23]\.\{0,1\}\([0-9]*\).*/\1/'`";;
"intl" ) MT_LANG=YES;;
"man" ) MT_MAN=YES;;
"pod" ) MT_POD=YES;;
"gtkfilesel" ) MT_FPICK=gtkfilesel;;
"gtkcolsel" ) MT_CPICK=gtkcolsel;;
"oldlists" ) MT_LISTS=1;;
"imagick" ) MT_ANIM=ImageMagick;;
"icons"* ) ICON_SET=$A;;
"win" ) OS="MinGW/MSYS"
GTK=2;;
"cflags" ) OPTS=CFLAGS;;
"386" ) MARCH='-march=i386';;
"486" ) MARCH='-march=i486';;
"586" ) MARCH='-march=i586';;
"686" ) MARCH='-march=i686';;
"--cpu="* ) MARCH="-march=${A#*=}";;
"slow" ) OPTS=NO;;
"debug" ) OPTS=DEBUG;;
"release" ) OPTS=RELEASE;;
"thread" ) USE_THREADS=YES;;
"nothread" ) USE_THREADS=NO;;
"asneeded" ) AS_NEEDED=-Wl,--as-needed;;
"--help" ) HELP=0;;
"--prefix="* ) MT_PREFIX="${A#*=}";;
"--bindir="* ) MT_BINDIR="${A#*=}";;
"--datarootdir="* ) MT_DATAROOT="${A#*=}";;
"--docdir="* ) MT_DOCDIR="${A#*=}";;
"--localedir="* ) MT_LOCDIR="${A#*=}";;
"--mandir="* ) MT_MANDIR="${A#*=}";;
"--host="* ) MT_HOST="${A#*=}";;
"--fakeroot"* ) FAKE_ROOT="${A#*=}"
FAKE_LL="${A%%=*}"
FAKE_LL="${FAKE_LL#--fakeroot}";;
"panic" ) WARN="-Wextra -Wno-missing-field-initializers -Wno-unused-parameter";;
"flush" ) echo Clearing out directory to original state
echo
make clean
echo
rm $GTK_FILE
rm po/mtpaint.pot
rm -rf src/graphics
exit;;
"merge" ) xgettext src/*.c src/*.h --keyword=_ --keyword=__ -o po/mtpaint.pot
cd po
NEW_DIR=trans_
mkdir $NEW_DIR`date +%d-%m-%Y-%H-%M-%S`
for file in *.po
do
echo New file = $file-a
mv "$file" "$file-a"
msgmerge -N "$file-a" mtpaint.pot > "$file"
mv "$file-a" $NEW_DIR*
done
rm mtpaint.pot
mv $NEW_DIR* ../../old_trans
exit;;
"newpo" ) xgettext src/*.c src/*.h --keyword=_ --keyword=__ -o po/mtpaint.pot
exit;;
# Override variable
[!=]*=* ) MT_VAR=${A%%=*}
if [ "$MT_VAR" != "${MT_VAR#*[!A-Za-z0-9_]}" ]
then
echo "Invalid variable: '$MT_VAR'"
else
eval $MT_VAR=\${A#*=}
export $MT_VAR
fi;;
* ) echo "Unrecognized option '$A'"
exit;;
esac
done
if [ "$HELP" = 0 ]
then
cat << 'EOF' ; exit
Usage: ./configure [OPTION] ... [VAR=VALUE] ...
Options:
win .............. Configure for Windows MinGW / MSYS
gtk1 ............. Configure for GTK+1
gtk2 ............. Configure for GTK+2
gtk2.VER ......... Configure for GTK+2, minor version VER
gtk3 ............. Configure for GTK+3
gtk3.VER ......... Configure for GTK+3, minor version VER
gtkfilesel ....... Use GtkFileSelection file picker
gtkcolsel ........ Use GtkColorSelection colour picker
oldlists ......... Use GtkList and GtkCList lists
imagick .......... Use ImageMagick for GIF animation tasks
thread ........... Use multithreading
nothread ......... Don't use multithreading
cflags ........... Use CFLAGS environment variable
--cpu= ........... Target a specific CPU, e.g. athlon-xp, x86-64
686 .............. Target 686 machines
586 .............. Target 586 machines
486 .............. Target 486 machines
386 .............. Target 386 machines
slow ............. Don't use compiler optimizations
asneeded ......... Use linker optimization --as-needed
release .......... Use the set of optimizations which work best for mtPaint code
debug ............ Include debugging info in binary
--host= .......... Cross-compile with a specific toolchain, e.g. i586-mingw32
staticpng ........ Statically link PNG library
jpeg ............. Use libjpeg
nojpeg ........... Don't use libjpeg
staticjpeg ....... Statically link JPEG library
jp2v1 ............ Use libopenjpeg
jp2v2 ............ Use libopenjpeg2
jasper............ Use libjasper
nojp2 ............ Don't use libopenjpeg and libjasper
staticjp2 ........ Statically link JPEG 2000 library
tiff ............. Use libtiff
notiff ........... Don't use libtiff
statictiff ....... Statically link TIFF library
webp ............. Use libwebp
nowebp ........... Don't use libwebp
staticwebp ....... Statically link WebP library
noft ............. Don't use FreeType
staticft ......... Statically link FreeType library
lcms ............. Use LittleCMS
lcms2............. Use LittleCMS2
nolcms ........... Don't use LittleCMS
staticlcms ....... Statically link LittleCMS library
intl ............. Use internationalized po files
man .............. Install the mtPaint man page
--fakeroot=DIR ... DIR = location of library and include files to use for cross-compilation
--fakeroot64=DIR . DIR = ... when targeting a 64-bit system
icons ............ Compile with alternative icon set - see ./src/icons1/README for details
--prefix=DIR ..... DIR = prefix location of all installs, e.g. /usr or /usr/local (default)
--bindir=DIR ..... DIR = location of bin file to install, ${prefix}/bin by default
--docdir=DIR ..... DIR = location of documentation to install, ${prefix}/share/doc/mtpaint by default
--localedir=DIR .. DIR = location of locale files to install, ${prefix}/share/locale by default
--mandir=DIR ..... DIR = location of man page to install, ${prefix}/share/man/man1 by default
panic ............ Enable rarely-useful warnings - developers only
flush ............ Flush directories to initial state
newpo ............ Create ./po/mtpaint.pot
merge ............ Update all po files with new strings - developers only
Environment variables:
CC ............... C compiler (defaults to gcc)
CFLAGS ........... C compiler flags (not recommended; for enabling better optimizations use 'release' option instead)
LDFLAGS .......... linker flags, e.g. -L<libdir>
CPPFLAGS ......... C preprocessor flags, e.g. -I<includedir>
CCLD ............. "test link" command (defaults to $CC -nostartfiles)
Default settings: GNU/Linux system, O2 optimizations, English only version,
mtpaint file picker, mtpaint colour picker.
pkg-config gtk+-2.0 is checked to determine GTK+2 availability in GNU/Linux
EOF
fi
### Detect the OS
if [ -n "$OS" ] ; then
: # Do nothing
elif [ "$OSTYPE" = "msys" ] ; then
OS="MinGW/MSYS"
elif [ "$OSTYPE" != "${OSTYPE#darwin}" ] ; then
OS="Darwin"
elif [ -z "$MT_HOST" ] ; then
OS="GNU/Linux"
elif [ "$MT_HOST" != "${MT_HOST%mingw32*}" ] ; then
OS="MinGW/GNU/Linux"
else
OS="Other/GNU/Linux"
fi
### Prepare to use selected icon set
mkdir -p src/graphics
cp src/$ICON_SET/*.xpm src/$ICON_SET/*.xbm src/graphics
### Choose which sub-makefiles to run
MAKE_DIRS=src
[ "$MT_LANG" = YES ] && MAKE_DIRS="$MAKE_DIRS po" # translations
[ "$MT_MAN" = YES ] && MAKE_DIRS="$MAKE_DIRS doc" # man page
### Setup directories
if [ "$OS" != "${OS#MinGW/}" ]
then
EXEEXT=".exe"
MT_PREFIX="${MT_PREFIX-/c/Program Files/mtPaint}"
else
MT_PREFIX="${MT_PREFIX-/usr/local}"
fi
MT_BINDIR="${MT_BINDIR:-$MT_PREFIX/bin}"
MT_DATAROOT="${MT_DATAROOT:-$MT_PREFIX/share}"
MT_DOCDIR="${MT_DOCDIR:-$MT_DATAROOT/doc/mtpaint}"
MT_MANDIR="${MT_MANDIR:-$MT_DATAROOT/man}"
if [ "$OS" != "${OS#MinGW/}" ]
then
MT_LOCDIR="${MT_LOCDIR:-$MT_BINDIR/locale}"
# Want package-relative path on Windows
MT_PKGDIR=${MT_BINDIR%/bin}
[ "$MT_PKGDIR" = "$MT_BINDIR" ] && MT_PKGDIR=${MT_BINDIR%/lib}
MT_PKGDIR="$MT_PKGDIR/"
MT_PO="/"
while [ "$MT_LOCDIR" = "${MT_LOCDIR#$MT_PKGDIR}" ]
do
MT_PO="/..$MT_PO"
if [ "$MT_PKGDIR" = "${MT_PKGDIR%/[!/]*/}" ]
then # Cannot relativize path - leave it be
MT_PO=
break
fi
MT_PKGDIR="${MT_PKGDIR%/[!/]*/}/"
done
MT_PO="$MT_PO${MT_LOCDIR#$MT_PKGDIR}"
else
MT_LOCDIR="${MT_LOCDIR:-$MT_DATAROOT/locale}"
MT_PO="$MT_LOCDIR"
fi
### Setup compiler
# Only GCC and GNU toolchain are fully supported at the time
# Clang is recognized mainly to avoid mixups with GCC version checks
# No support for GNU-incompatible linkers in fakeroot mode
INCLUDES=
LIBS=
if [ "$OS" != "${OS%GNU/Linux}" ] || [ "$OS" = "Darwin" ]
then
CC=${CC:-`which ${MT_HOST:+$MT_HOST-}gcc`}
PKG_CONFIG=${PKG_CONFIG:-${MT_HOST:+$MT_HOST-}pkg-config}
fi
CC=${CC:-gcc}
# Use compiler as linker in tests - this way, both accept "-Wl," in LDFLAGS
CCLD=${CCLD:-$CC -nostartfiles}
# Get compiler type
CCNAME=gcc # by default
$CC -v 2>&1 | grep -q "clang version" && CCNAME=clang
# Get compiler version
CCVER=`$CC -dumpfullversion -dumpversion`
# Get target architecture
CCARCH=`$CC -dumpmachine`
# For eternally misconfigured, Windows-hosted MinGW
[ "$CCARCH" != "${CCARCH#mingw32}" ] && CCARCH=i586-mingw32
# For any properly built toolchain
ARCH=${ARCH:-${CCARCH%%-*}}
if [ -n "$FAKE_ROOT" ] # A way to replace just some libraries, leaving others be
then
PKGCONFIG () # Check both locations in turn
{
PKG_CONFIG_PATH= PKG_CONFIG_LIBDIR="$FAKE_ROOT/lib$FAKE_LL/pkgconfig" \
pkg-config --define-variable=prefix="$FAKE_ROOT" "$@" \
2> /dev/null || "$PKG_CONFIG" "$@"
}
MT_TESTLINK="$CCLD -L$FAKE_ROOT/lib$FAKE_LL -Wl,--unresolved-symbols=ignore-in-shared-libs $LDFLAGS"
MT_TESTCOMP="$CC -std=c89 -fno-builtin -isystem $FAKE_ROOT/include $CPPFLAGS ${MT_TESTLINK#$CCLD}"
else
PKGCONFIG ()
{
"$PKG_CONFIG" "$@"
}
MT_TESTLINK="$CCLD $LDFLAGS"
MT_TESTCOMP="$CC -std=c89 -fno-builtin $CPPFLAGS $LDFLAGS"
fi
if [ "$OS" != "${OS%/MSYS}" ]
then
MT_TESTLINK="redir -e /dev/null $MT_TESTLINK -L/lib"
MT_TESTCOMP="redir -e /dev/null $MT_TESTCOMP -L/lib"
INCLUDES="-I/include"
LIBS="-L/lib"
fi
IS_LIB()
{
$MT_TESTLINK -$1 -o _conf.tmp > /dev/null 2>&1
}
CAN_DO()
{
echo "main() { $1; }" > _conf.c
$MT_TESTCOMP _conf.c -o _conf.tmp > /dev/null 2>&1
}
HAVE_FUNC()
{
CAN_DO "$1()"
}
FOLLOW_C_STD()
{
echo "
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ > $1)"'
#error "Incompatible C language version"
#endif
int main(void) { return 0; }
' > _conf.c
${MT_TESTCOMP%% -std=c89*}${MT_TESTCOMP#* -std=c89} _conf.c -o _conf.tmp > /dev/null 2>&1
}
HAVE_CC_VER()
{
# First 2 parts of GCC or Clang version
MT_VN0=${CCVER%%.*}
MT_VN1=${CCVER#$MT_VN0}
MT_VN0=${MT_VN0%%[!0-9]*}
MT_VN1=${MT_VN1#.}
MT_VN1=${MT_VN1%%[!0-9]*}
# Compare them to given version
[ ${1%%.*} -eq "$MT_VN0" ] && [ ${1#*.} -le "$MT_VN1" ] || \
[ ${1%%.*} -lt "$MT_VN0" ]
}
HAVE_GCC_VER()
{
[ "$CCNAME" = gcc ] && HAVE_CC_VER $1
}
HAVE_CLANG()
{
[ "$CCNAME" = clang ]
}
HAVE_CLANG_VER()
{
[ "$CCNAME" = clang ] && HAVE_CC_VER $1
}
### Detect libraries and functions
if CAN_DO "volatile int v, z; z = __sync_fetch_and_add(&v, 1)"
then
DEFS="$DEFS -DHAVE__SFA"
fi
if HAVE_FUNC "mkdtemp"
then
DEFS="$DEFS -DHAVE_MKDTEMP"
fi
if IS_LIB "ljpeg"
then
NJPEG=${NJPEG:-YES}
fi
NJPEG=${NJPEG:-NO}
if IS_LIB "lopenjp2"
then
NJP2=${NJP2:-OpenJPEG2}
fi
if IS_LIB "lm -lopenjpeg"
then
NJP2=${NJP2:-OpenJPEG}
fi
if IS_LIB "ljasper"
then
NJP2=${NJP2:-JasPer}
fi
NJP2=${NJP2:-NO}
if IS_LIB "ltiff"
then
NTIFF=${NTIFF:-YES}
fi
NTIFF=${NTIFF:-NO}
if IS_LIB "lwebp"
then
NWEBP=${NWEBP:-YES}
fi
NWEBP=${NWEBP:-NO}
if IS_LIB "lfreetype"
then
NFT=${NFT:-YES}
fi
NFT=${NFT:-NO}
if IS_LIB "llcms2"
then
NCMS=${NCMS:-LittleCMS2}
fi
if IS_LIB "llcms"
then
NCMS=${NCMS:-LittleCMS}
fi
NCMS=${NCMS:-NO}
### Setup optimizations
if [ "$OPTS" = RELEASE ]
then
# Target i386 when compiling for any x86 CPU with GCC;
# this produces smallest *AND* fastest binary
# !!! Questionable, now; need retesting, and proper cross-configuring too
# With Clang, target pentium4; no incompatible HW expected in the wild,
# and anything lesser results in much slower code
case $ARCH in
i?86) HAVE_CLANG && MARCH=${MARCH:--march=pentium4}
MARCH=${MARCH:--march=i386};;
esac
CFLAGS="-O2 $MARCH"
# Add optimizations which are proven to really make mtPaint code faster
if HAVE_CLANG
then : # Clang - no useful extra flags
elif HAVE_GCC_VER 4.0
then # GCC 4.x
CFLAGS="$CFLAGS -fweb -fomit-frame-pointer -fmodulo-sched"
else # GCC 3.x
CFLAGS="$CFLAGS -fweb"
fi
# Do not add unneeded dependencies
AS_NEEDED="-Wl,--as-needed"
# Disable GTK+ debug code
DEFS="$DEFS -DGTK_NO_CHECK_CASTS -DG_DISABLE_CAST_CHECKS"
elif [ "$OPTS" = DEBUG ]
then
CFLAGS="-ggdb"
elif [ "$OPTS" = YES ]
then
CFLAGS="-O2 $MARCH"
elif [ "$OPTS" = NO ]
then
CFLAGS="$MARCH"
else # $OPTS = CFLAGS
MARCH=
# And leave CFLAGS alone
fi
# Set Windows-specific flags
if [ "$OS" != "${OS#MinGW/}" ]
then
CFLAGS="-mms-bitfields $CFLAGS"
LDFLAGS="-mwindows $LDFLAGS"
fi
# Revert the changed defaults in GCC 10 and Clang 11
{ HAVE_GCC_VER 10.0 || HAVE_CLANG_VER 11.0; } && CFLAGS="$CFLAGS -fcommon"
# Lock the C standard
FOLLOW_C_STD 201710 || CFLAGS="$CFLAGS -std=gnu17"
# Enable warnings
WARN="-Wall $WARN"
if HAVE_GCC_VER 4.0
then # Tell gcc 4.x to shut up
WARN="$WARN -Wno-pointer-sign"
fi
if HAVE_GCC_VER 4.1
then # Tell gcc 4.1+ to shut up some more
WARN="$WARN -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast"
fi
if HAVE_GCC_VER 6.0
then # Tell gcc 6.x to stop misleading
WARN="$WARN -Wno-misleading-indentation"
fi
if HAVE_GCC_VER 9.3
then # Tell gcc 9.3+ to cut it short
WARN="$WARN -Wno-stringop-truncation -Wformat-truncation=0 -Wformat-overflow=0"
fi
if HAVE_CLANG
then # Tell Clang to clang less
WARN="$WARN -Wno-pointer-sign -Wno-int-to-pointer-cast -Wno-string-plus-int"
fi
if HAVE_CLANG_VER 11.0
then # Tell Clang 11.x to clang yet less
WARN="$WARN -Wno-pointer-to-int-cast -Wno-misleading-indentation"
fi
# Deterministic compile
SET_RANDSEED=
if HAVE_CLANG || HAVE_GCC_VER 3.3
then
SET_RANDSEED='-frandom-seed=$*'
fi
# Apple linker
[ "$OS" = "Darwin" ] && AS_NEEDED=
### Setup libraries
MT_DLIBS=
MT_SLIBS=
LIB_NAME () # ( lib_ID , static_mode , libs )
{
if [ "$2" ]
then
MT_SLIBS="$MT_SLIBS ${1:+-l$1}$3"
else
MT_DLIBS="$MT_DLIBS ${1:+-l$1}$3"
fi
}
if [ "$NJP2" = OpenJPEG2 ]
then
INCLUDES="$INCLUDES `PKGCONFIG libopenjp2 --cflags 2>/dev/null`" || \
INCLUDES="$INCLUDES -I/usr/include/openjpeg-2.0"
LIB_NAME openjp2 "$STATIC_JP2"
DEFS="$DEFS -DU_JP2=2"
fi
if [ "$NJP2" = OpenJPEG ]
then
INCLUDES="$INCLUDES `PKGCONFIG libopenjpeg1 --cflags 2>/dev/null`" || \
INCLUDES="$INCLUDES `PKGCONFIG libopenjpeg --cflags 2>/dev/null`" || \
INCLUDES="$INCLUDES -I/usr/include/openjpeg"
LIB_NAME openjpeg "$STATIC_JP2"
DEFS="$DEFS -DU_JP2"
if [ "$STATIC_JP2" ] || [ "$OS" != "${OS#MinGW}" ]
then
DEFS="$DEFS -DOPJ_STATIC"
fi
fi
if [ "$NJP2" = JasPer ]
then
LIB_NAME jasper "$STATIC_JP2"
DEFS="$DEFS -DU_JASPER"
fi
if [ "$NWEBP" = YES ]
then
LIB_NAME webp "$STATIC_WEBP"
DEFS="$DEFS -DU_WEBP"
fi
if [ "$NTIFF" = YES ]
then
LIB_NAME tiff "$STATIC_TIFF"
DEFS="$DEFS -DU_TIFF"
fi
if [ "$NJPEG" = YES ]
then
LIB_NAME jpeg "$STATIC_JPEG"
DEFS="$DEFS -DU_JPEG"
fi
if [ "$NFT" = YES ]
then
DEFS="$DEFS -DU_FREETYPE"
if [ "$OS" = "GNU/Linux" ] && which freetype-config > /dev/null 2>&1
then # Do it the old way, for native builds on *very* old distros
FT_INCLUDES="`freetype-config --cflags`"
LIB_NAME "" "$STATIC_FT" "`freetype-config --libs`"
elif [ "$OS" != "${OS%/MSYS}" ]
then # pkg-config may be missing on Windows - hardcode its results
FT_INCLUDES="-I/include/freetype2"
LIB_NAME "" "$STATIC_FT" "-lfreetype -lz"
else # Use pkg-config
FT_INCLUDES="`PKGCONFIG freetype2 --cflags`"
LIB_NAME "" "$STATIC_FT" "`PKGCONFIG freetype2 --libs`"
fi
# Remove irrelevant GLib2 headers when compiling for GTK+1
if [ "$GTK" = 1 ]
then
for ZAD in $FT_INCLUDES
do
[ "$ZAD" = "${ZAD#*/glib-2.0}" ] && INCLUDES="$INCLUDES $ZAD"
done
else
INCLUDES="$INCLUDES $FT_INCLUDES"
fi
# libiconv may be separate, or part of libc
HAVE_FUNC "iconv_open" || LIB_NAME iconv "$STATIC_FT"
fi
if [ "$NCMS" = LittleCMS2 ]
then
LIB_NAME lcms2 "$STATIC_CMS"
DEFS="$DEFS -DU_LCMS=2"
fi
if [ "$NCMS" = LittleCMS ]
then
LIB_NAME lcms "$STATIC_CMS"
DEFS="$DEFS -DU_LCMS"
fi
if [ -n "$FAKE_ROOT" ]
then
INCLUDES="$INCLUDES `PKGCONFIG libpng --cflags`"
LIB_NAME "" "$STATIC_PNG" "`PKGCONFIG libpng --libs`"
else
LIB_NAME png "$STATIC_PNG"
fi
LIB_NAME z "$STATIC_PNG"
LIB_NAME m
if [ "$MT_LANG" = YES ]
then
HAVE_FUNC "gettext" || LIB_NAME intl
DEFS="$DEFS -DU_NLS -DMT_LANG_DEST='\"$MT_PO\"'"
fi
# !!! Would be nice to subtract MT_SLIBS from MT_DLIBS first
LIBS="$LIBS $MT_DLIBS${MT_SLIBS:+ -Wl,-dn $MT_SLIBS -Wl,-dy}"
rm -f _conf.c _conf.tmp
### Setup GTK+
FOUND_GTK=
[ "$OS" != "${OS#MinGW/}" ] && GTK=2
[ "${GTK:-2}" = 2 ] && PKGCONFIG gtk+-2.0 --cflags > /dev/null 2>&1 && FOUND_GTK=2 GTK=2
[ "${GTK:-1}" = 1 ] && PKGCONFIG gtk+ --cflags > /dev/null 2>&1 && FOUND_GTK=1 GTK=1
[ "${GTK:-3}" = 3 ] && PKGCONFIG gtk+-3.0 --cflags > /dev/null 2>&1 && FOUND_GTK=3 GTK=3
GTK=${GTK:-1}
if [ "$USE_THREADS" = NO ] ; then
THREADS=
elif [ "$GTK" -ge 2 ] ; then
THREADS="gthread-2.0"
else # "$GTK" = 1
THREADS="gthread"
fi
# !!! It is assumed that the nondefault install prefix is the one GTK+ lives in
if [ "$FOUND_GTK" = 3 ] && [ ${GTKVERSION:-12} -ge 12 ] &&
PKGCONFIG --atleast-version=3.12 gtk+-3.0
then
GTKPREFIX=`PKGCONFIG gtk+-3.0 --variable=prefix`
INCLUDES="$INCLUDES `PKGCONFIG gtk+-3.0 $THREADS --cflags`"
LIBS="$LIBS `PKGCONFIG gtk+-3.0 $THREADS --libs`"
elif [ "$FOUND_GTK" = 3 ]
then
echo "GTK+3 versions prior to 3.12 are not and can not be supported"
exit 1
elif [ "$FOUND_GTK" = 2 ]
then
GTKPREFIX=`PKGCONFIG gtk+-2.0 --variable=prefix`
INCLUDES="$INCLUDES `PKGCONFIG gtk+-2.0 $THREADS --cflags`"
LIBS="$LIBS `PKGCONFIG gtk+-2.0 $THREADS --libs`"
elif [ "$FOUND_GTK" = 1 ]
then
# !!! Full equivalent to "gtk-config gtk" would be "pkg-config gtk+ gmodule",
# but for mtPaint, 'gmodule' is nothing but a nuisance anyway
GTKPREFIX=`PKGCONFIG gtk+ --variable=prefix`
INCLUDES="$INCLUDES `PKGCONFIG gtk+ $THREADS --cflags`"
LIBS="$LIBS `PKGCONFIG gtk+ $THREADS --libs`"
elif [ "$GTK" = 2 ] && [ "$OS" != "${OS%/MSYS}" ]
then # Windows system w/o working pkg-config
GTKPREFIX=/
INCLUDES="$INCLUDES -I/include/gtk-2.0 -I/lib/gtk-2.0/include -I/include/atk-1.0 -I/include/pango-1.0 -I/include/freetype2 -I/include/glib-2.0 -I/lib/glib-2.0/include"
LIBS="$LIBS -lgtk-win32-2.0 -lgdk-win32-2.0 -lpango-1.0 -lglib-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 ${THREADS:+-lgthread-2.0}"
elif [ "$GTK" = 1 ] && gtk-config --cflags > /dev/null
then # Very old GNU/Linux system
GTKPREFIX=`gtk-config gtk --prefix`
INCLUDES="$INCLUDES `gtk-config gtk $THREADS --cflags`"
LIBS="$LIBS `gtk-config gtk $THREADS --libs | sed 's/-rdynamic//'`"
elif [ "$GTK" = 1 ]
then # Even older GNU/Linux system
GTKPREFIX=/opt/gnome
GTK_INCLUDE="-I$GTKPREFIX/include/gtk-1.2 -I$GTKPREFIX/include/glib-1.2 -I$GTKPREFIX/lib/glib/include -I/usr/X11R6/include"
GTK_LIB="-L/usr/lib -L/usr/X11R6/lib -L$GTKPREFIX/lib -lgtk -lgdk -lgmodule -lglib -ldl -lXext -lX11 -lm"
echo
echo I have not been able to find gtk-config so I am assuming the following:
echo
echo GTK_INCLUDE = $GTK_INCLUDE
echo GTK_LIB = $GTK_LIB
echo
echo If these values are not right for your system, edit the configure script
echo
INCLUDES="$INCLUDES $GTK_INCLUDE"
LIBS="$LIBS $GTK_LIB"
else
echo "Failed to find required GTK+$GTK libraries" 1>&2
exit 1
fi
# Need to add this to use GTK+1 with GCC 5 or Clang
[ "$GTK" = 1 ] && { HAVE_CLANG || HAVE_GCC_VER 5.0; } && CFLAGS="$CFLAGS -std=gnu89"
# Also need to add "-lX11" on GTK+2/X systems
[ "$GTK" = 2 ] && [ "$LIBS" != "${LIBS#*gdk-x11}" ] && LIBS="$LIBS -lX11"
# Need the same on GTK+3/X systems even more
[ "$GTK" = 3 ] && PKGCONFIG gtk+-x11-3.0 && LIBS="$LIBS -lX11"
# GTK+ minor version to use
DEFS="$DEFS${GTKVERSION:+ -DGTK${GTK}VERSION=$GTKVERSION}"
# Widgets to use
if [ "$GTK" = 3 ]
then
MT_LISTS=2 # GtkList & GtkCList are with us no more
MT_FPICK=mtpaint # Neither is GtkFileSelection
elif [ "$GTK" = 2 ]
then # GTK+3 compatible things need some compatibility
[ ${GTKVERSION:-18} -lt 18 ] && MT_LISTS=1
[ "$FOUND_GTK" != 2 ] || PKGCONFIG --atleast-version=2.18 gtk+-2.0 || MT_LISTS=1
else # GTK+1
MT_LISTS=1
fi
# Stop the spam
[ "$GTK" = 2 ] && WARN="$WARN -Wno-deprecated-declarations"
### Set feature flags
[ "$USE_THREADS" = "YES" ] && DEFS="$DEFS -DU_THREADS"
if [ "$MT_FPICK" = mtpaint ]
then
DEFS="$DEFS -DU_FPICK_MTPAINT"
else # "$MT_FPICK" = gtkfilesel
DEFS="$DEFS -DU_FPICK_GTKFILESEL"
fi
if [ "$MT_CPICK" = mtpaint ]
then
DEFS="$DEFS -DU_CPICK_MTPAINT"
else # "$MT_CPICK" = gtkcolsel
DEFS="$DEFS -DU_CPICK_GTK"
fi
[ "$MT_LISTS" = 1 ] && DEFS="$DEFS -DU_LISTS_GTK1"
[ "$MT_ANIM" = ImageMagick ] && DEFS="$DEFS -DU_ANIM_IMAGICK"
# mtPaint version
DEFS="$DEFS -DMT_VERSION='\"$MT_VERSION\"'"
###
### Rebase the paths, for '--fakeroot' substitutions to work
FAKE_PATHS () # variable, key
{
FAKE_KEYS=" "
for A in $1
do
[ "$A" = "${A#$2/}" ] && continue
for B in "$GTKPREFIX/include" "$GTKPREFIX/lib"\
/usr/include /usr/lib /usr/local/include /usr/local/lib
do
[ "$A" != "${A#$2$B}" ] || continue
C="$2$FAKE_ROOT${A#$2${B%/*}}"
[ "$C" != "$A" ] && [ "$FAKE_KEYS" = "${FAKE_KEYS#* $C }" ] &&\
FAKE_KEYS="$FAKE_KEYS$C "
break
done
done
echo "$FAKE_KEYS"
}
if [ "$FAKE_ROOT" ]
then
# !!! Spaces in paths will NOT be well received here
FAKE_PATHS "$LIBS" -L
LIBS="-L$FAKE_ROOT/lib$FAKE_LL $FAKE_KEYS $LIBS"
FAKE_PATHS "$INCLUDES" -I
INCLUDES="-isystem $FAKE_ROOT/include $FAKE_KEYS $INCLUDES"
AS_NEEDED="-Wl,--as-needed,--no-add-needed,--unresolved-symbols=ignore-in-shared-libs"
fi
### Write config
cat << CONFIG > "$GTK_FILE"
CC = $CC $WARN
EXEEXT = $EXEEXT
MT_VERSION=$MT_VERSION
MT_DATE=$MT_DATE
MT_PREFIX="$MT_PREFIX"
MT_DATAROOT="$MT_DATAROOT"
MT_LANG_DEST="$MT_LOCDIR"
MT_MAN_DEST="$MT_MANDIR"
LDFLAG = $AS_NEEDED $LIBS $LDFLAGS
CFLAG = $DEFS $INCLUDES $CPPFLAGS $CFLAGS
subdirs = $MAKE_DIRS
BIN_INSTALL="$MT_BINDIR"
SET_RANDSEED = $SET_RANDSEED
CONFIG
### Report config
eval STATICLIBS=\"$STATICLIBS\"
STATICLIBS=`echo -n "$STATICLIBS" | sed -e 's/ */ /g' -e 's/^ //'`
cat << CONFIG
---------------------
mtPaint Configuration
---------------------
-------
General
-------
Version $MT_V
System $OS
Toolkit GTK+$GTK${GTKVERSION:+.$GTKVERSION}
Lists GTK+$MT_LISTS
File Picker $MT_FPICK
Colour Picker $MT_CPICK
Animation Package $MT_ANIM
Use FreeType $NFT
Use CMS $NCMS
Icon set $ICON_SET
Internationalized $MT_LANG
Multithreaded $USE_THREADS
--------
Compiler
--------
Optimizations $OPTS
CFLAGS $CFLAGS
LDFLAGS ${AS_NEEDED:+$AS_NEEDED }$LDFLAGS
Static libraries ${STATICLIBS:-NONE}
----------
File Types
----------
Use JPEG $NJPEG
Use JPEG 2000 $NJP2
Use TIFF $NTIFF
Use WebP $NWEBP
------------
Installation
------------
Binary install $MT_BINDIR
CONFIG
[ "$MT_LANG" = YES ] && cat << CONFIG
Locale install $MT_LOCDIR
Locale program $MT_PO
CONFIG
cat << CONFIG
Install man page $MT_MAN
CONFIG
[ "$MT_MAN" = YES ] && cat << CONFIG
Man page install $MT_MANDIR
CONFIG
echo
|