shithub: freetype+ttf2subf

Download patch

ref: 8f4851997b76b5f80095e355cf2444d925cab328
parent: 0d0e5bb1e60ef013f40c8964731df6b698aa4fdf
author: Werner Lemberg <[email protected]>
date: Fri Nov 24 05:34:09 EST 2017

[unix] Install a massaged `ftoption.h' file (#51780).

* builds/unix/configure.raw (ftoption_set, ftoption_unset): New
auxiliary functions to construct...
(FTOPTION_H_SED): ... this new variable.
Apply it as a sed argument while copying `ftoption.h' to the
`builds/unix' directory (using `AC_CONFIG_FILES').
Simplify code of test that checks cpp's computation of bit length
(the test previously created an empty `ftoption.h' file and deleted
it immediately afterwards); without this change, it can happen on my
GNU/Linux box that `configure's execution of `config.status' doesn't
create `ftoption.h' (no idea why this happens).

* builds/unix/install.mk (install): Install
`builds/unix/ftoption.h'.

* builds/unix/unix-def.in (DISTCLEAN): Updated.

* builds/unix/.gitignore: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2017-11-24  Werner Lemberg  <[email protected]>
+
+	[unix] Install a massaged `ftoption.h' file (#51780).
+
+	* builds/unix/configure.raw (ftoption_set, ftoption_unset): New
+	auxiliary functions to construct...
+	(FTOPTION_H_SED): ... this new variable.
+	Apply it as a sed argument while copying `ftoption.h' to the
+	`builds/unix' directory (using `AC_CONFIG_FILES').
+	Simplify code of test that checks cpp's computation of bit length
+	(the test previously created an empty `ftoption.h' file and deleted
+	it immediately afterwards); without this change, it can happen on my
+	GNU/Linux box that `configure's execution of `config.status' doesn't
+	create `ftoption.h' (no idea why this happens).
+
+	* builds/unix/install.mk (install): Install
+	`builds/unix/ftoption.h'.
+
+	* builds/unix/unix-def.in (DISTCLEAN): Updated.
+
+	* builds/unix/.gitignore: Updated.
+
 2017-11-23  Tor Andersson  <[email protected]>
 
 	Silence unused function warnings (#52465).
--- a/builds/unix/.gitignore
+++ b/builds/unix/.gitignore
@@ -10,6 +10,7 @@
 freetype2.pc
 freetype-config
 ftconfig.h
+ftoption.h
 install-sh
 libtool
 ltmain.sh
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -112,15 +112,13 @@
 
 AC_MSG_CHECKING([whether cpp computation of bit length in ftconfig.in works])
 orig_CPPFLAGS="${CPPFLAGS}"
-CPPFLAGS="-I${srcdir} -I. ${CPPFLAGS}"
+CPPFLAGS="-I${srcdir} -I. -I${srcdir}/../../include/freetype/config ${CPPFLAGS}"
 
 ac_clean_files=
-for f in ft2build.h ftoption.h ftstdlib.h; do
-  if test ! -f $f; then
-    ac_clean_files="$ac_clean_files $f"
-    touch $f
-  fi
-done
+if test ! -f ft2build.h; then
+  ac_clean_files=ft2build.h
+  touch ft2build.h
+fi
 
 cat > conftest.c <<\_ACEOF
 #include <limits.h>
@@ -977,26 +975,62 @@
 # changing LDFLAGS value should only be done after
 # lt_cv_prog_compiler_static_works test
 
+ftoption_set()
+{
+  regexp="-e \\\"s|.*#.*def.*$1.*|#define $1|\\\""
+  FTOPTION_H_SED="$FTOPTION_H_SED $regexp"
+}
+
+ftoption_unset()
+{
+  regexp="-e \\\"s|.*#.*def.*$1.*|/* #undef $1 */|\\\""
+  FTOPTION_H_SED="$FTOPTION_H_SED $regexp"
+}
+
 if test "$have_zlib" != no; then
-  CFLAGS="$CFLAGS $ZLIB_CFLAGS -DFT_CONFIG_OPTION_SYSTEM_ZLIB"
+  CFLAGS="$CFLAGS $ZLIB_CFLAGS"
   LDFLAGS="$LDFLAGS $ZLIB_LIBS"
+  ftoption_set FT_CONFIG_OPTION_SYSTEM_ZLIB
+else
+  ftoption_unset FT_CONFIG_OPTION_SYSTEM_ZLIB
 fi
-
 if test "$have_bzip2" != no; then
-  CFLAGS="$CFLAGS $BZIP2_CFLAGS -DFT_CONFIG_OPTION_USE_BZIP2"
+  CFLAGS="$CFLAGS $BZIP2_CFLAGS"
   LDFLAGS="$LDFLAGS $BZIP2_LIBS"
+  ftoption_set FT_CONFIG_OPTION_USE_BZIP2
+else
+  ftoption_unset FT_CONFIG_OPTION_USE_BZIP2
 fi
 if test "$have_libpng" != no; then
-  CFLAGS="$CFLAGS $LIBPNG_CFLAGS -DFT_CONFIG_OPTION_USE_PNG"
+  CFLAGS="$CFLAGS $LIBPNG_CFLAGS"
   LDFLAGS="$LDFLAGS $LIBPNG_LIBS"
+  ftoption_set FT_CONFIG_OPTION_USE_PNG
+else
+  ftoption_unset FT_CONFIG_OPTION_USE_PNG
 fi
 if test "$have_harfbuzz" != no; then
-  CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS -DFT_CONFIG_OPTION_USE_HARFBUZZ"
+  CFLAGS="$CFLAGS $HARFBUZZ_CFLAGS"
   LDFLAGS="$LDFLAGS $HARFBUZZ_LIBS"
+  ftoption_set FT_CONFIG_OPTION_USE_HARFBUZZ
+else
+  ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ
 fi
 
 AC_SUBST([CFLAGS])
 AC_SUBST([LDFLAGS])
+
+# We don't want to use a template file for `ftoption.h', since compilation
+# should work without calling a configure script also.  For this reason, we
+# copy the `include/freetype/config/ftoption.h' file to the `unix/builds'
+# directory (using a dummy `AC_CONFIG_FILES' call) and apply the just
+# constructed $FTOPTION_H_SED regexp (using the post-action of
+# `AC_CONFIG_FILES'); this is also the version that gets installed later on.
+#
+AC_CONFIG_FILES([ftoption.h:${srcdir}/../../include/freetype/config/ftoption.h],
+  [mv ftoption.h ftoption.tmp
+   eval "sed $FTOPTION_H_SED < ftoption.tmp > ftoption.h"
+   rm ftoption.tmp],
+  [FTOPTION_H_SED="$FTOPTION_H_SED"])
 
 # configuration file -- stay in 8.3 limit
 #
--- a/builds/unix/install.mk
+++ b/builds/unix/install.mk
@@ -30,6 +30,9 @@
 #
 # We also remove `$(includedir)/ft2build.h' for the same reason.
 #
+# Note that some header files get handled twice for simplicity; a special,
+# configured version overwrites the generic one.
+#
 install: $(PROJECT_LIBRARY)
 	-$(DELDIR) $(DESTDIR)$(includedir)/freetype2
 	-$(DELETE) $(DESTDIR)$(includedir)/ft2build.h
@@ -55,6 +58,8 @@
           $(DESTDIR)$(includedir)/freetype2/freetype/config/ftconfig.h
 	$(INSTALL_DATA) $(OBJ_DIR)/ftmodule.h                          \
           $(DESTDIR)$(includedir)/freetype2/freetype/config/ftmodule.h
+	$(INSTALL_DATA) $(OBJ_BUILD)/ftoption.h                        \
+          $(DESTDIR)$(includedir)/freetype2/freetype/config/ftoption.h
 	$(INSTALL_SCRIPT) -m 755 $(OBJ_BUILD)/freetype-config \
           $(DESTDIR)$(bindir)/freetype-config
 	$(INSTALL_SCRIPT) -m 644 $(BUILD_DIR)/freetype2.m4 \
--- a/builds/unix/unix-def.in
+++ b/builds/unix/unix-def.in
@@ -43,6 +43,7 @@
              $(OBJ_BUILD)/unix-def.mk   \
              $(OBJ_BUILD)/unix-cc.mk    \
              $(OBJ_BUILD)/ftconfig.h    \
+             $(OBJ_BUILD)/ftoption.h    \
              $(LIBTOOL)                 \
              $(OBJ_BUILD)/Makefile
 
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -211,6 +211,10 @@
   /*   Do not #undef this macro here since the build system might define   */
   /*   it for certain configurations only.                                 */
   /*                                                                       */
+  /*   If you use a build system like cmake or the `configure' script,     */
+  /*   options set by those programs have precendence, overwriting the     */
+  /*   value here with the configured one.                                 */
+  /*                                                                       */
 /* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */
 
 
@@ -227,6 +231,10 @@
   /*                                                                       */
   /*   Define this macro if you want to enable this `feature'.             */
   /*                                                                       */
+  /*   If you use a build system like cmake or the `configure' script,     */
+  /*   options set by those programs have precendence, overwriting the     */
+  /*   value here with the configured one.                                 */
+  /*                                                                       */
 /* #define FT_CONFIG_OPTION_USE_BZIP2 */
 
 
@@ -252,6 +260,10 @@
   /*                                                                       */
   /*   Define this macro if you want to enable this `feature'.             */
   /*                                                                       */
+  /*   If you use a build system like cmake or the `configure' script,     */
+  /*   options set by those programs have precendence, overwriting the     */
+  /*   value here with the configured one.                                 */
+  /*                                                                       */
 /* #define FT_CONFIG_OPTION_USE_PNG */
 
 
@@ -264,6 +276,10 @@
   /*   by a font's character map will be hinted also.                      */
   /*                                                                       */
   /*   Define this macro if you want to enable this `feature'.             */
+  /*                                                                       */
+  /*   If you use a build system like cmake or the `configure' script,     */
+  /*   options set by those programs have precendence, overwriting the     */
+  /*   value here with the configured one.                                 */
   /*                                                                       */
 /* #define FT_CONFIG_OPTION_USE_HARFBUZZ */