File: configure.ac

package info (click to toggle)
fontforge 1:20190801~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 71,404 kB
  • sloc: ansic: 590,896; python: 4,449; makefile: 1,265; sh: 529; perl: 315; xml: 259; cpp: 219
file content (782 lines) | stat: -rw-r--r-- 32,248 bytes parent folder | download
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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

# Copyright (C) 2000-2012 by George Williams
# Copyright (C) 2012 by Barry Schwartz
# Copyright (C) 2013 by Ben Martin
# Copyright (C) 2014 by Reuben Thomas <rrt@sc3d.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AC_PREREQ([2.68])

#--------------------------------------------------------------------------
# PackageTimestamp version
m4_define([fontforge_package_stamp], [20190801])
# reminder: When updating FontForge, also take note of desktop/* dates and
# startnoui.c, startui.c
#--------------------------------------------------------------------------
# Making point releases:
#   fontforge_major_version += 0;
#   fontforge_minor_version += 1; (patches or added function(s))
#
# If any new functions have been added:
#   fontforge_major_version += 0;
#   fontforge_minor_version += 1; (added function(s))
#
# If backwards compatibility has been broken:
#   fontforge_major_version += 1;
#   fontforge_minor_version = 0;
#
m4_define([fontforge_major_version], [3]) dnl 20120731-b was 1.0
m4_define([fontforge_minor_version], [0])
m4_define([libgdraw_major_version], [6]) dnl 20120731-b was 4.10
m4_define([libgdraw_minor_version], [0])
m4_define([libgunicode_major_version], [5]) dnl 20120731-b was 3.2
m4_define([libgunicode_minor_version], [0])
m4_define([libgutils_major_version], [3]) dnl 20120731-b was 1.3
m4_define([libgutils_minor_version], [1])
m4_define([libfontforgeexe_major_version], [fontforge_major_version]) dnl matches fontforge
m4_define([libfontforgeexe_minor_version], [fontforge_minor_version])
m4_define([libfontforge_major_version], [fontforge_major_version]) dnl matches fontforge
m4_define([libfontforge_minor_version], [fontforge_minor_version])

#--------------------------------------------------------------------------
# Setup variables before running AC_INIT()
m4_define([fontforge_version],
          [fontforge_major_version.fontforge_minor_version.fontforge_package_stamp])
m4_define([fontforge_info],
          [fontforge_major_version:fontforge_minor_version:0])
m4_define([fontforge_package_name],[fontforge])
m4_define([libfontforgeexe_info],[libfontforgeexe_major_version:libfontforgeexe_minor_version:0])
m4_define([libfontforge_info],[libfontforge_major_version:libfontforge_minor_version:0])
m4_define([libgdraw_info],[libgdraw_major_version:libgdraw_minor_version:0])
m4_define([libgunicode_info],[libgunicode_major_version:libgunicode_minor_version:0])
m4_define([libgutils_info],[libgutils_major_version:libgutils_minor_version:0])

#--------------------------------------------------------------------------

# We need this in order to pass things through automake when it doesn't like them.
BLANK1=''; AC_SUBST(BLANK1)
AC_SUBST([BLANK2],[""])

#--------------------------------------------------------------------------
AC_INIT([fontforge],[fontforge_package_stamp],[fontforge-devel@lists.sourceforge.net],
	[fontforge_package_name],[https://github.com/fontforge/fontforge])
AC_CONFIG_SRCDIR([Unicode/ArabicForms.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_TESTDIR([tests],[fontforge])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CONFIG_HEADERS([inc/fontforge-config.h])
AM_INIT_AUTOMAKE([foreign -Wall subdir-objects tar-pax])
AM_MAINTAINER_MODE([enable])
AC_USE_SYSTEM_EXTENSIONS
AX_CODE_COVERAGE

#--------------------------------------------------------------------------
#
# Checks for programs.

AC_PROG_AWK
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_GREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AC_PROG_SED
AC_PATH_PROG([STRIP],[strip],[:])

# Check for Objective C compiler
m4_ifdef([AC_PROG_OBJC], [
    AC_PROG_OBJC
], [
    AM_CONDITIONAL([am__fastdepOBJC], false)
    AC_SUBST([OBJC], [$CC])
    AC_SUBST([OBJCFLAGS], [$CFLAGS])
])

#--------------------------------------------------------------------------
# automake 1.12 requires AM_PROG_AR but automake < 1.11.2 doesn't recognize it.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

#--------------------------------------------------------------------------
# Enable silent build rules by default, this requires atleast Automake-1.11
# Disable by passing --disable-silent-rules to configure or using make V=1
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],[AC_SUBST([AM_DEFAULT_VERBOSITY],[1])])

LT_INIT

#--------------------------------------------------------------------------
# init these early so they can be filled by packages (especially glib-2.0).
my_cflags=
my_libs=

# The following is for the benefit of some other things that use a
# path relative to top_srcdir.
CPPFLAGS="${CPPFLAGS} AS_ESCAPE([-I${top_builddir}]) AS_ESCAPE([-I${top_srcdir}])"


FONTFORGE_ARG_ENABLE_GDK

if test x"${fontforge_can_use_gdk}" != xyes; then
    AC_PATH_XTRA
    i_do_have_x="${have_x}"
fi

if test x"${i_do_have_x}" = xyes || test x"${fontforge_can_use_gdk}" = xyes; then
    i_do_have_gui=yes
fi

AC_SUBST([HOST],["$host"])
AC_SUBST([MACAPP])

FONTFORGE_PLATFORM_SPECIFICS

#--------------------------------------------------------------------------
# Pass version variables to fontforge-config.h
AC_DEFINE([FONTFORGE_VERSION],["fontforge_package_stamp"],[FontForge Version])
AC_DEFINE([FONTFORGE_VERSION_MAJOR],[fontforge_major_version],[FontForge Major Version])
AC_DEFINE([FONTFORGE_VERSION_MINOR],[fontforge_minor_version],[FontForge Minor Version])
AC_DEFINE([FONTFORGE_LIBFFE_VERSION_MAJOR],[libfontforgeexe_major_version],[ExeLibFontForge Major Version])
AC_DEFINE([FONTFORGE_LIBFFE_VERSION_MINOR],[libfontforgeexe_minor_version],[ExeLibFontForge Minor Version])
AC_DEFINE([FONTFORGE_LIBFF_VERSION_MAJOR],[libfontforge_major_version],[LibFontForge Major Version])
AC_DEFINE([FONTFORGE_LIBFF_VERSION_MINOR],[libfontforge_minor_version],[LibFontForge Minor Version])

#--------------------------------------------------------------------------
# Pass library version variables to several MAKEFILE.AM
AC_SUBST([FONTFORGE_VERSION],[fontforge_version])
AC_SUBST([LIBFONTFORGEEXE_VERSION],[libfontforgeexe_info])
AC_SUBST([LIBFONTFORGE_VERSION],[libfontforge_info])
AC_SUBST([LIBGDRAW_VERSION],[libgdraw_info])
AC_SUBST([LIBGUNICODE_VERSION],[libgunicode_info])
AC_SUBST([LIBGUTILS_VERSION],[libgutils_info])

AC_SUBST([VERSION_MAJOR],[fontforge_major_version])
AC_SUBST([VERSION_MINOR],[fontforge_minor_version])
AC_SUBST([VERSION_PATCH],[fontforge_package_stamp])

#--------------------------------------------------------------------------
# URLs for dependencies.

cairo_url="http://www.cairographics.org/"
freetype_url="http://www.freetype.org/"
giflib_url="http://giflib.sourceforge.net/"
libpng_url="http://www.libpng.org/"
libxml_url="http://www.xmlsoft.org/"
libspiro_url="https://github.com/fontforge/libspiro"
libuninameslist_url="https://github.com/fontforge/libuninameslist"
libreadline_url="http://www.gnu.org/software/readline"
libxorg_url="http://www.x.org/"
python_url="https://www.python.org/"
gdk_url="http://www.gtk.org/"
woff2_url="https://github.com/google/woff2"

# Point to the Wikipedia page, primarily because one may want
# libjpeg-turbo rather than the reference implementation.
libjpeg_url="http://en.wikipedia.org/wiki/Libjpeg"

# Point to the Wikipedia page, so people can learn not to be fooled by
# the old website, which some while ago was hijacked by androids from
# beyond the orbit of Neptune.
libtiff_url="http://en.wikipedia.org/wiki/Libtiff"

#--------------------------------------------------------------------------

# Required for building FontForge package, plus we use PKG_CHECK_MODULES in
# a few checks and searches for programs and libraries.
# NOTE: Some distros don't have /usr/local included in the /etc/ld.so PATH,
# so, PKG_CHECK_MODULES may not find libraries you compile into /usr/local.
m4_ifndef([PKG_PROG_PKG_CONFIG],[m4_fatal(
  [Could not locate the pkg-config autoconf macros.
   These are usually located in /usr/share/aclocal/pkg.m4. If your macros
   are in a different location, try setting the environment variable
   ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
PKG_PROG_PKG_CONFIG([0.25])

AC_PATH_PROG([MSGFMT],[msgfmt],[msgfmt])
AC_PATH_PROG([XGETTEXT],[xgettext],[xgettext])
AC_PATH_PROG([INDENT],[indent],[indent])
AC_PATH_PROG([WGET],[wget],[wget])
AC_PATH_PROG([UNZIP],[unzip],[unzip])
AC_PATH_PROG([UPDATE_MIME_DATABASE],[update-mime-database],[:])
AC_PATH_PROG([UPDATE_DESKTOP_DATABASE],[update-desktop-database],[:])
AC_PATH_PROG([PLUTIL],[plutil],[:])


dnl###############################
dnl###############################

FONTFORGE_ARG_ENABLE_REAL

AC_ARG_ENABLE([programs],
        [AS_HELP_STRING([--disable-programs],[do not build "fontforge" and related programs
                                              (but do build libraries and possibly the Python extensions)])],
        [i_do_have_programs="${enableval}"],
        [i_do_have_programs=yes])
AM_CONDITIONAL([THE_PROGRAMS],[test x"${i_do_have_programs}" = xyes])
AC_SUBST([THE_PROGRAMS],["${i_do_have_programs}"])

FONTFORGE_ARG_ENABLE([debug],
        [AS_HELP_STRING([--enable-debug],[Turn on debug build and FONTFORGE_DEBUG conditional code])],
        [FONTFORGE_DEBUG])
if test x$enable_debug = xyes ; then
    CFLAGS="$CFLAGS -g -O0"
    CPPFLAGS="$CPPFLAGS -g -O0"
fi

FONTFORGE_ARG_DISABLE([native-scripting],
        [AS_HELP_STRING([--disable-native-scripting],[disable the legacy fontforge scripting language])],
        [_NO_FFSCRIPT])
AM_CONDITIONAL([NATIVE_SCRIPTING],[test x"${i_do_have_native_scripting}" = xyes])

FONTFORGE_ARG_DISABLE_PYTHON_SCRIPTING_AND_EXTENSION

AC_ARG_ENABLE([freetype-debugger],
        [AS_HELP_STRING([--enable-freetype-debugger[[=DIR]]],
                [use freetype's internal debugger within fontforge; requires source code of the
                 freetype library with which fontforge will be linked.
                 You need to set DIR to the top directory of the freetype sources,
                 or alternatively set the environment variable FREETYPE_SOURCE (see below)])],
        [i_do_have_freetype_debugger="${enableval}"],
        [AC_ARG_WITH([freetype-source],
                [AS_HELP_STRING([--with-freetype-source[[=DIR]]],[synonym for --enable-freetype-debugger])],
                [i_do_have_freetype_debugger="${withval}"],
                [i_do_have_freetype_debugger=no])])
# ' make syntax checkers happy

FONTFORGE_ARG_ENABLE([debug-raw-points],
        [AS_HELP_STRING([--enable-debug-raw-points],
                [add a raw mode to the points window of the debugger])],
        [FONTFORGE_CONFIG_SHOW_RAW_POINTS])

FONTFORGE_ARG_ENABLE([tile-path],
        [AS_HELP_STRING([--enable-tile-path],
                [enable a 'tile path' command (a variant of 'expand stroke')])],
        [FONTFORGE_CONFIG_TILEPATH])

FONTFORGE_ARG_ENABLE([write-pfm],
        [AS_HELP_STRING([--enable-write-pfm],
                [add the ability to save a PFM file without creating the associated font file])],
        [FONTFORGE_CONFIG_WRITE_PFM])

#--------------------------------------------------------------------------
# Theme pixmap ICON selection.
# Go with tango by default. Retain older 2012 theme for those who like it.
themename=tango

FONTFORGE_ARG_ENABLE([theme-2012],
        [AS_HELP_STRING([--enable-theme-2012],
                [use old circa 2012 icons instead of using the tango default icons])],
        [FONTFORGE_THEME_TANGO])
if test x$enable_theme_2012 = xyes; then
   themename="2012"
fi

# select the theme.
AM_CONDITIONAL([USE_THEME_2012],[test x"$themename" = x2012])
AM_CONDITIONAL([USE_THEME_TANGO],[test x"$themename" = xtango])

#--------------------------------------------------------------------------

FONTFORGE_ARG_ENABLE([maintainer-tools],
        [AS_HELP_STRING([--enable-maintainer-tools],
                [build programs used normally only by fontforge maintainers and developers])],
        [MAINTAINER_TOOLS])
AM_CONDITIONAL([MAINTAINER_TOOLS],[test x"${i_do_have_maintainer_tools}" = xyes])
AC_SUBST([MAINTAINER_TOOLS],["${i_do_have_maintainer_tools}"])

#--------------------------------------------------------------------------
# Check for autotrace and potrace (don't do anything with this yet)
dnl check for autotrace (v0.31-1) commented-out due to bug in autotrace.m4
dnl which requires brackets around [AUTOTRACE] on line 7.
i_do_find_auto_po_trace="no"
dnl AC_PATH_PROG([AUTO_TRACE],[autotrace],[no])
AC_PATH_PROG([PO_TRACE],[potrace],[no])
if test x"${PO_TRACE}" != xno; then
    i_do_find_auto_po_trace="yes"
fi
dnl if test x"${AUTO_TRACE}" != xno; then
dnl     i_do_find_auto_po_trace="yes"
dnl fi

#--------------------------------------------------------------------------
#
# Checks for libraries.

# Check for math.h include and math library.
AC_CHECK_HEADER([math.h],
   AC_SEARCH_LIBS([cos],[m],[have_libm=yes],
      AC_CHECK_LIB([m],[cos],[have_libm=yes],
         AC_CHECK_FUNC([cos],[have_libm=yes]))))
if test x"${have_libm}" != xyes; then
    AC_MSG_FAILURE([ERROR: Please install Math library and math.h],[1])
fi

if test x"${fontforge_can_use_gdk}" != xyes; then
    FONTFORGE_CONFIG_X_LIBRARIES
fi

# zlib is a requirement. It is too commonly available to bother leaving out.
# Try package first, if failed then try library searches and a header check.
PKG_CHECK_MODULES([ZLIB],[zlib],[have_zlib=yes],[have_zlib=no])
if test x"${have_zlib}" != xyes; then
   AC_SEARCH_LIBS([inflate],[z zlib zdll],[have_zlib=yes],[
      AC_CHECK_LIB([z],[inflate],[have_zlib=yes],[
      AC_CHECK_LIB([zlib],[inflate],[have_zlib=yes],[
      AC_CHECK_LIB([zdll],[inflate],[have_zlib=yes])])])],)
   if test x"${have_zlib}" = xyes; then
      AC_CHECK_HEADER([zlib.h],[],[have_zlib=no])
   fi
fi
if test x"${have_zlib}" != xyes; then
   AC_MSG_FAILURE([ERROR: Please install ZLIB library and zlib.h include file],[1])
fi

# glib became a requirement, but is also required if using GDK GUI system.
# before checking for glib-2.0, we need to verify you have pthreads first.
# Different OSes might have pthreads, pthread, kthread, or something else.
have_pthreads=yes
AX_PTHREAD( ,[have_pthreads=no]) dnl avoid filling "yes" here
if test x"${have_pthreads}" = xyes; then
   case $host in
      *aix*) ;; dnl AIX uses separate threading compiler (see AX_PTHREAD).
      *) CC="$PTHREAD_CC" ;;
   esac
else
   # just check for a function and avoid searching for "-pthreads"
   AC_CHECK_FUNC([pthread_create],[have_pthreads=yes])
fi
AC_CHECK_HEADER([pthread.h],,[have_pthreads=no])
if test x"${have_pthreads}" != xyes; then
   AC_MSG_FAILURE([ERROR: Please install PTHREADS library with development include files],[1])
else
   AC_DEFINE(HAVE_PTHREAD_H,[1],[We have pthreads.h.])
fi
PKG_CHECK_MODULES([GLIB],[glib-2.0 >= 2.6 gio-2.0],[have_glib=pkg],[have_glib=no])
# glib ships with gio library. Some systems have trouble accessing these.
# GLIB_CFLAGS='-pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
# GLIB_LIBS='-lgio-2.0 -lgobject-2.0 -lglib-2.0'
if test x"${have_glib}" = xno; then
   PKG_CHECK_MODULES([GLIB],[glib-2.0 >= 2.6],[have_glib=pkg],[have_glib=no])
   PKG_CHECK_MODULES([GIO_UNIX],[gio-unix-2.0],[my_cflags="${my_cflags} ${GIO_UNIX_CFLAGS}" my_libs="${my_libs} ${GIO_UNIX_LIBS}"],[have_glib=no])
fi
if test x"${have_glib}" != xpkg; then
   AC_MSG_FAILURE([ERROR: Please install GLIB-2.0 (with GIO-2.0 or GIO-UNIX-2.0) libraries with development include files],[1])
fi

if test x"${i_do_have_x}" = xyes; then
   PKG_CHECK_MODULES([PANGO],[pango >= 1.10 pangoxft])
fi

PKG_CHECK_MODULES([FREETYPE],[freetype2 >= 2.3.7])
PKG_CHECK_MODULES([LIBXML],[libxml-2.0])

AC_ARG_VAR([FREETYPE_SOURCE],
        [directory where freetype source code is located for --enable-freetype-debugger;
         however, if --enable-freetype-debugger=DIR is specified, then DIR overrides
         the setting of FREETYPE_SOURCE])
FONTFORGE_ARG_WITH_GIFLIB
FONTFORGE_ARG_WITH_LIBJPEG
FONTFORGE_ARG_WITH_LIBPNG
FONTFORGE_ARG_WITH_LIBTIFF
FONTFORGE_ARG_WITH_CAIRO # do this test only 'after' zlib and png checks
FONTFORGE_ARG_WITH_LIBSPIRO
FONTFORGE_ARG_WITH_LIBUNINAMESLIST
#FONTFORGE_ARG_WITH_LIBUNICODENAMES
FONTFORGE_ARG_WITH_LIBREADLINE
FONTFORGE_ARG_WITH_ICONV

FONTFORGE_ARG_ENABLE_WOFF2

if test x"${i_do_have_cairo}" = xyes; then
   PKG_CHECK_MODULES([PANGOCAIRO],[pangocairo])
fi

FONTFORGE_CONFIG_FREETYPE_DEBUGGER

#--------------------------------------------------------------------------
#
# Checks for header files.

AC_CHECK_HEADERS([arpa/inet.h fcntl.h ieeefp.h])
AC_CHECK_HEADERS([langinfo.h libintl.h])
AC_CHECK_HEADERS([memory.h netdb.h netinet/in.h])
AC_CHECK_HEADERS([strings.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
AC_CHECK_HEADERS([execinfo.h])

#--------------------------------------------------------------------------
#
# Checks for typedefs, structures, and compiler characteristics.

AC_C_BIGENDIAN
AC_TYPE_PID_T

AC_LANG_PUSH([C]) dnl NOTE: configure.ac - try not to push/pop too often
# Create LDFLAGS for libraries. Currently used to pass '-no-undefined' to libtool.
my_lib_ldflags="${CODE_COVERAGE_LDFLAGS}"
dnl add --no-undefined if supported. Based on information seen here:
dnl https://mail.gnome.org/archives/commits-list/2011-October/msg10575.html
dnl http://femass.com.br/Net-SNMP/configure.d/config_os_progs
case $host in
   dnl FreeBSD (et al.) does not complete linking for shared objects when
   dnl pthreads are requested, as different implementations are present; to
   dnl avoid problems, use -Wl,-z,defs only for those platform not behaving
   dnl this way.
   *-freebsd* | *-openbsd*)
      ;;
   *-apple-darwin*)
      ;;
   *mingw*)
      dnl Explicitly export all symbols on Windows, since FontForge lacks an export table
	  dnl See issue #1238 on GitHub for more information.
	  my_lib_ldflags="${my_lib_ldflags} -no-undefined -Wl,--export-all-symbols"
      ;;
   *cygwin*)
	  my_lib_ldflags="${my_lib_ldflags} -Wl,-no-undefined -Wl,--export-all-symbols"
      ;;
   *) saved_LDFLAGS=$LDFLAGS
      AC_MSG_CHECKING([whether the linker supports --no-undefined])
      LDFLAGS="$saved_LDFLAGS -Wl,--no-undefined"
      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
         [AC_MSG_RESULT([yes]);
          AX_CHECK_COMPILE_FLAG([-Wl,--no-undefined],[WARNING_CFLAGS+=" -Wl,--no-undefined"])],
         [AC_MSG_RESULT([no])])
      LDFLAGS="$saved_LDFLAGS"
	  my_lib_ldflags="${my_lib_ldflags} -no-undefined"
      ;;
esac
AC_SUBST([MY_LIB_LDFLAGS], [${my_lib_ldflags}])

# Native Windows Python modules have a '.pyd' extension and not '.dll'
pyhook_file_extension=""
case $host in
    *mingw*)
        pyhook_file_extension="${pyhook_file_extension} -shrext \".pyd\""
    ;;
esac
AC_SUBST([PYHOOK_FILE_EXTENSION], [${pyhook_file_extension}])

AC_LANG_POP

#--------------------------------------------------------------------------
# Bypass older autoscan recommendations (if anyone decides to run autoscan)
# These packages promises to not use malloc(0) or realloc(n, 0) so we don't
# want autoscan to suggest using AC_FUNC_MALLOC or AC_FUNC_REALLOC, by
# redefining the problem
m4_define([AN_FUNCTION], [m4_if([$1], [malloc], [],
  [AN_OUTPUT([function], $@)])])
m4_define([AN_FUNCTION], [m4_if([$1], [realloc], [],
  [AN_OUTPUT([function], $@)])])

#--------------------------------------------------------------------------
# Checks for library functions.

AC_FUNC_FORK
AC_FUNC_MKTIME
AC_FUNC_MMAP
if test x"${ac_cv_func_mmap_fixed_mapped}" != xyes; then
   AC_DEFINE([_NO_MMAP],1,[Define if not using mmap.])
fi
AC_CHECK_FUNCS([alarm dup2 endpwent])
AC_CHECK_FUNCS([getcwd gethostbyname gettimeofday])
AC_CHECK_FUNCS([mkdir munmap])
AC_CHECK_FUNCS([nl_langinfo putenv rmdir])
AC_CHECK_FUNCS([select setenv socket])
AC_CHECK_FUNCS([uname])

#--------------------------------------------------------------------------
# Put ifndef wrapper on fontforge-config.h so we don't call it repeatedly.
AH_TOP([#ifndef FONTFORGE_CONFIG_H

#define FONTFORGE_CONFIG_H 1])
AH_BOTTOM([
/* More or less obsolete settings from the old configure-fontforge.h */

/* Apple suggests using a sfnt version of 'true' for fonts designed for use   */
/*  only on a mac (windows refuses such fonts). I generally prefer to have a  */
/*  font work everywhere, so normally ff produces fonts with version 1.0      */
/*  Set this if you want Apple only fonts (produced when Apple mode is set and*/
/*  Opentype mode is unset in the Generate Fonts-Options dialog).	      */
/*									      */
/* #define FONTFORGE_CONFIG_APPLE_ONLY_TTF				      */
/*									      */


/* Nobody else puts apple unicode encodings into the name table. So I probably*/
/*  shouldn't either.  But if someone wants them...			      */
/*									      */
/* #define FONTFORGE_CONFIG_APPLE_UNICODE_NAMES				      */
/*									      */


/* I used to use an approximation method when converting cubic to quadratic   */
/*  splines which was non-symmetric. In some cases it produced better results */
/*  than the current approach. This flag restores the old algorithm.	      */
/*									      */
/* #define FONTFORGE_CONFIG_NON_SYMMETRIC_QUADRATIC_CONVERSION		      */
/*									      */


/* Prior to late Sept of 2003 FontForge converted certain mac feature/settings*/
/*  into opentype-like tags. Some features could be converted directly but for*/
/*  a few I made up tags.  Now FontForge is capable of using the mac feature  */
/*  settings directly. If you set this flag then when FontForge loads in an sfd*/
/*  file with these non-standard opentype tags, it will convert them into the */
/*  appropriate mac feature/setting combinations.                             */
/*									      */
/* #define FONTFORGE_CONFIG_CVT_OLD_MAC_FEATURES			      */
/*									      */


/* In addition to placing snippets of charstrings into subrs, I tried adding  */
/*  whole glyphs (when that was possible). To my surprise, it made things     */
/*  worse in one of my test cases, and barely registered an improvement in    */
/*  another.   So I think we're better off without it. But I don't understand */
/*  why things are worse so I'm leaving the code in to play with              */
/*									      */
/* #define FONTFORGE_CONFIG_PS_REFS_GET_SUBRS				      */
/*									      */

#endif])
#--------------------------------------------------------------------------

AM_CONDITIONAL([GRAPHICAL_USER_INTERFACE],[test x"${i_do_have_gui}" = xyes])
AM_CONDITIONAL([MACINTOSH],[test x"${gww_ismac}" = xyes])

# The following conditionals are always false, so the directories
# never get built by default. Nevertheless, they will be included by
# "make dist".
dnl AM_CONDITIONAL([FONTTOOLS],[test x != x])

#--------------------------------------------------------------------------
# Enable FontForge-Extras. Default is/was no since these files were default
# off (or not in use since 2012 or earlier). User can enable to build these
# files, and install extras found in directory contrib.
fontforge_extras=no
AC_ARG_ENABLE([fontforge-extras],
        [AS_HELP_STRING([--enable-fontforge-extras],
                [Build and Install fontforge-extras (from contrib directory).])],
        [fontforge_extras=yes])
# If user chose "./configure --disable-programs", then turn this off too.
if test x"${i_do_have_programs}" != xyes; then
   fontforge_extras=no
fi
AM_CONDITIONAL([FONTTOOLS],[test x"${fontforge_extras}" = xyes])

#--------------------------------------------------------------------------
# Create and Set FontForge Compiler Flags

FONTFORGE_CFLAG_CHECK([WARNING_CFLAGS], [-Werror=implicit-function-declaration])
FONTFORGE_CFLAG_CHECK([WARNING_CFLAGS], [-Werror=int-conversion])

my_cflags="${my_cflags} ${WARNING_CFLAGS}"
if test x"${i_do_have_freetype_debugger}" != xno; then
   my_cflags="${my_cflags} -I${FREETYPE_SOURCE}/src/truetype"
   my_cflags="${my_cflags} -I${FREETYPE_SOURCE}/include"
   my_cflags="${my_cflags} -I${FREETYPE_SOURCE}/include/freetype"
fi
my_cflags="${my_cflags} ${ZLIB_CFLAGS}"
my_cflags="${my_cflags} ${GLIB_CFLAGS}"
my_cflags="${my_cflags} ${CAIRO_CFLAGS}"
my_cflags="${my_cflags} ${PANGO_CFLAGS}"
my_cflags="${my_cflags} ${GDK_CFLAGS}"
my_cflags="${my_cflags} ${WOFF2_CFLAGS}"
my_cflags="${my_cflags} ${PANGOCAIRO_CFLAGS}"
my_cflags="${my_cflags} ${FREETYPE_CFLAGS}"
my_cflags="${my_cflags} ${GIFLIB_CFLAGS}"
my_cflags="${my_cflags} ${LIBJPEG_CFLAGS}"
my_cflags="${my_cflags} ${LIBPNG_CFLAGS}"
my_cflags="${my_cflags} ${LIBTIFF_CFLAGS}"
my_cflags="${my_cflags} ${LIBSPIRO_CFLAGS}"
my_cflags="${my_cflags} ${LIBUNINAMESLIST_CFLAGS}"
my_cflags="${my_cflags} ${LIBUNICODENAMES_CFLAGS}"
my_cflags="${my_cflags} ${LIBXML_CFLAGS}"
my_cflags="${my_cflags} ${PYTHON_CFLAGS}"
my_cflags="${my_cflags} ${PTHREAD_CFLAGS}"
my_cflags="${my_cflags} ${LIBREADLINE_CFLAGS}"
my_cflags="${my_cflags} ${CODE_COVERAGE_CFLAGS}"
my_cflags="${my_cflags} ${ICONV_CFLAGS}"
test x"${SDK}" = x || my_cflags="${my_cflags} -I${SDK}"
AC_SUBST([MY_CFLAGS],[${my_cflags}])

#--------------------------------------------------------------------------
# Create and Set FontForge Library Flags

test x"${i_do_have_giflib}" = xyes && my_libs="${my_libs} ${GIFLIB_LIBS}"
test x"${i_do_have_libjpeg}" = xyes && my_libs="${my_libs} ${LIBJPEG_LIBS}"
test x"${i_do_have_libpng}" = xyes && my_libs="${my_libs} ${LIBPNG_LIBS}"
test x"${i_do_have_libtiff}" = xyes && my_libs="${my_libs} ${LIBTIFF_LIBS}"
test x"${i_do_have_libuninameslist}" = xyes && my_libs="${my_libs} ${LIBUNINAMESLIST_LIBS}"
test x"${i_do_have_libunicodenames}" = xyes && my_libs="${my_libs} ${LIBUNICODENAMES_LIBS}"
test x"${i_do_have_cairo}" = xyes && my_libs="${my_libs} ${CAIRO_LIBS}"
test x"${i_do_have_cairo}" = xyes && my_libs="${my_libs} ${PANGOCAIRO_LIBS}"
test x"${i_do_have_iconv}" = xyes && my_libs="${my_libs} ${ICONV_LIBS}"
test x"${i_do_have_gui}" = xyes && my_libs="${my_libs} ${PANGO_LIBS}"
test x"${fontforge_can_use_woff2}" = xyes && my_libs="${my_libs} ${WOFF2_LIBS}"

if test x"${fontforge_can_use_gdk}" = xyes; then
    my_libs="${my_libs} ${GDK_LIBS}"
else
    test x"${i_do_have_x}" = xyes && my_libs="${my_libs} ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
fi

test x"${i_do_have_libreadline}" = xyes && my_libs="${my_libs} ${LIBREADLINE_LIBS}"
test x"${i_do_have_libspiro}" = xyes && my_libs="${my_libs} ${LIBSPIRO_LIBS}"
my_libs="${my_libs} ${LIBSPIRO_LIBS}"
my_libs="${my_libs} ${FREETYPE_LIBS}"
my_libs="${my_libs} ${PTHREAD_LIBS}"
my_libs="${my_libs} ${ZLIB_LIBS}"
my_libs="${my_libs} ${GLIB_LIBS}"
my_libs="${my_libs} ${LIBXML_LIBS}"
AC_SUBST([MY_LIBS],[${my_libs}])


#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------

AC_ARG_ENABLE([python-even],
        [AS_HELP_STRING([--enable-python-even],
                [enable a menu entry for Even])],
        [have_python_even=yes])
AM_CONDITIONAL([HAVE_PYTHON_EVEN],[test x"${have_python_even}" = xyes && test x"${i_do_have_python_scripting}" = xyes])

#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# Output commands - Create FontForge Portable Makefiles

AC_CONFIG_FILES([
Makefile
inc/Makefile
Unicode/Makefile
gutils/Makefile
share/Makefile
gdraw/Makefile
fontforge/Makefile
fontforgeexe/Makefile
fontforgeexe/pixmaps/Makefile
fontforgeexe/pixmaps/2012/Makefile
fontforgeexe/pixmaps/tango/Makefile
po/Makefile
doc/Makefile
doc/html/Makefile
pycontrib/Makefile
pycontrib/simple/Makefile
pyhook/Makefile
tests/Makefile
desktop/Makefile
contrib/Makefile
contrib/admintools/Makefile
contrib/cidmap/Makefile
contrib/cidmap/src/Makefile
contrib/fonttools/Makefile

fontforge.pc
inc/fontforge-version-extras.h
])

#--------------------------------------------------------------------------

FONTFORGE_CREATE_PKGCONFIG_FILES

#--------------------------------------------------------------------------
# Create FontForge and Python test driver
AC_CONFIG_FILES([tests/atlocal])

#--------------------------------------------------------------------------
# Collect "GIT" compile-time information to help when debugging FontForge.

FONTFORGE_GIT_VERSION=""
dnl if test -d ${srcdir}/.git; then
dnl   FONTFORGE_GIT_VERSION=`cd ${srcdir} && git log --pretty=format:'%H' -n 1`
dnl fi
FONTFORGE_DATE_NOW=${SOURCE_DATE_EPOCH:-$(date +'%s')}
FONTFORGE_DATE_OPTS="--date=@${FONTFORGE_DATE_NOW}"
if ! date --version 2>/dev/null ; then
  # Use POSIX date instead of GNU date on BSD systems
  FONTFORGE_DATE_OPTS="-j -f %s ${FONTFORGE_DATE_NOW}"
fi
FONTFORGE_MODTIME="$(date -u $FONTFORGE_DATE_OPTS +'%s')L"
FONTFORGE_MODTIME_STR="$(date -u $FONTFORGE_DATE_OPTS +'%H:%M %Z %e-%b-%Y')"
AC_SUBST(FONTFORGE_GIT_VERSION, ["$FONTFORGE_GIT_VERSION"])
AC_SUBST(FONTFORGE_MODTIME_STR, ["$FONTFORGE_MODTIME_STR"])
AC_SUBST(FONTFORGE_MODTIME_RAW, [$FONTFORGE_MODTIME])

#--------------------------------------------------------------------------

AC_OUTPUT

AC_MSG_NOTICE([

Configuration:

  Source code location	${srcdir}
  Build code location	${builddir}
  Destination prefix	${prefix}
  Compiler		${CC}

Summary of optional features:

			UseIt?	HaveIt?
  real (floating pt)		${my_real_type}
  programs		yes	${i_do_have_programs}
  native scripting	yes	${i_do_have_native_scripting}
  python scripting	${enable_python_scripting}	${i_do_have_python_scripting}${i_want_python_ver}
  python extension	${enable_python_extension}	${i_do_have_python_extension}
  freetype debugger		${i_do_have_freetype_debugger}
  raw points mode		${i_do_have_debug_raw_points}
  tile path			${i_do_have_tile_path}
  fontforge-extras	yes	${fontforge_extras}
  potrace or autotrace	${i_do_find_auto_po_trace}

Summary of optional dependencies:

Optional Library	UseIt?	HaveIt?	WebsiteURL
  giflib		${with_giflib}	${i_do_have_giflib}	${giflib_url}
  libjpeg		${with_libjpeg}	${i_do_have_libjpeg}	${libjpeg_url}
  libpng		${with_libpng}	${i_do_have_libpng}	${libpng_url}
  libreadline		${with_libreadline}	${i_do_have_libreadline}	${libreadline_url}
  libspiro		${with_libspiro}	${i_do_have_libspiro}	${libspiro_url}
  libtiff		${with_libtiff}	${i_do_have_libtiff}	${libtiff_url}
  libuninameslist	${with_libuninameslist}	${i_do_have_libuninameslist}	${libuninameslist_url}
  python-dev		${enable_python_scripting}	${i_do_have_python_scripting}	${python_url}
  woff2			${fontforge_can_use_woff2}	${fontforge_has_woff2}	${woff2_url}

Graphical UI Choices	UseIt?	HaveIt?	WebsiteURL
  X Window System		${i_do_have_x}	${libxorg_url}
    cairo		${with_cairo}	${i_do_have_cairo}	${cairo_url}
  GDK backend		${fontforge_can_use_gdk}	${fontforge_gdk_version}	${gdk_url}
  Desktop theme		${themename}
])

#--------------------------------------------------------------------------