Bug 7717

Summary: Patches to build latest STSF on GNU/Linux
Product: STSF Reporter: suzuki toshiya <mpsuzuki>
Component: ST: Build configAssignee: STSF mailinglist <stsf>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: high    
Version: ST-HEAD   
Hardware: x86 (IA32)   
OS: Linux (All)   
URL: https://www.codeblog.org/blog/mpsuzuki/20060801.html
Whiteboard:
i915 platform: i915 features:

Description suzuki toshiya 2006-07-31 22:44:10 UTC
1)
I think, aclocal's inclusion of pkg-config pkg.m4 is enough, and
explicit inclusion of pkg.m4 in configure.ac is not essential.

--- orig/stsf/configure.ac
+++ mod/stsf/configure.ac
@@ -412,9 +412,6 @@
 AC_HELP_STRING([--disable-fontconfig],[do not usefontconfig])],
 	USE_FONTCONFIG="${enableval}",USE_FONTCONFIG="unset")
 
-dnl m4_include(/usr/share/aclocal/pkg.m4)
-m4_include(pkg.m4)
-
 if test "${USE_FONTCONFIG-unset}" != "no" ; then
     PKG_CHECK_MODULES(FONTCONFIG, fontconfig, 
 	FONTCONFIG_CFLAGS="-DHAVE_FONTCONFIG ${FONTCONFIG_CFLAGS}", 

2)
fontconfig is searched by pkg-config, so searching for FreeType2
can be improved. Following patch uses freetype-config or pkg-config
freetype2. In addition, check the availability of FT_GlyphSlot_Embolden().

--- orig/stsf/configure.ac
+++ mod/stsf/configure.ac
@@ -58,6 +58,7 @@
 LIBRARY_MODE=1
 
 # Override defaults for certain platforms
+
 FT2_INC=
 case "$target" in
 	*-*-solaris*)
@@ -82,12 +83,25 @@
                   [Define where stfsloader stores its PID])
 		;;
     *-*-linux*)
+	AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
+	if test x"$FREETYPE_CONFIG" != "xno"
+	then
+		FT2_PATH=`$FREETYPE_CONFIG --prefix`
+		FT2_INC=`$FREETYPE_CONFIG --cflags`
+		FT2_LIBS=`$FREETYPE_CONFIG --libs`
+	elif test x"$PKG_CONFIG" != "xno"
+	then
+		FT2_PATH=`$PKG_CONFIG --variable=prefix freetype2`
+		FT2_INC=`$PKG_CONFIG --cflags freetype2`
+		FT2_LIBS=`$PKG_CONFIG --libs freetype2`
+	else
 		FT2_PATH="${FT2PATH:-/usr}"
-        FT2_INC="-I/usr/include/freetype2"
-		LIBPATH_TEMPLATE="-L@P@"
+		FT2_INC="-I/usr/include/freetype2"
+	fi
+	LIBPATH_TEMPLATE="-L@P@"
         
         ;;
-	*)	# Not Solaris
+    *)	# Not Solaris
 		FT2_PATH="${FT2PATH:-/usr/local}"
 		LIBPATH_TEMPLATE="-L@P@"
 		;;
@@ -358,15 +372,26 @@
 
 FT_LIBS=
 FT_INC=${FT2_INC}
+LIBS_no_freetype2=${LIBS}
+LIBS="${LIBS} ${FT2_LIBS}"
 
 case "${DROPINS}" in
     *freetype2*)
 	save_LDFLAGS="${LDFLAGS}"
 	LDFLAGS="${LDFLAGS} ${FTLDFLAGS}"
 	AC_CHECK_LIB(freetype, FT_Init_FreeType, 
+	    [
+		BUILD_FT2="no"
+		if test x`echo ${FT2_LIBS} | tr ' ' ','` != x
+		then
+		    FT_LIBS="${FT2_LIBS}"
+		else
+		    FT_LIBS="${FTLDFLAGS} -lfreetype"
+		fi
+		AC_CHECK_FUNCS(FT_GlyphSlot_Embolden)
+	    ], 
 
-	    [ BUILD_FT2="no" ; FT_LIBS="${FTLDFLAGS} -lfreetype" ], 
-
+            LIBS=${LIBS_no_freetype2}
    	    AC_MSG_NOTICE([trying again - looking in ${FT2_PATH} this time...])
 	    FTLDFLAGS=`echo " ${LIBPATH_TEMPLATE}" | sed "s|@P@|${FT2_PATH}/lib|g"`
 	    LDFLAGS="${LDFLAGS} ${FTLDFLAGS}"
@@ -382,6 +407,8 @@
 	BUILD_FT2="no"
 	;;
 esac
+LIBS=${LIBS_no_freetype2}
+
 AC_SUBST([BUILD_FT2])
 AC_SUBST([FT_INC])
 AC_SUBST([FT_LIBS])
--- orig/stsf/interface/config.h.in
+++ mod/stsf/interface/config.h.in
@@ -25,6 +25,9 @@
    */
 #undef HAVE_DIRENT_H
 
+/* Define to 1 if you have the `FT_GlyphSlot_Embolden' function. */
+#undef HAVE_FT_GLYPHSLOT_EMBOLDEN
+
 /* Define to 1 if you have the `getaddrinfo' function. */
 #undef HAVE_GETADDRINFO
 
--- orig/stsf/STFontServer/dropins/freetype2/ftrenderglyph.inc
+++ mod/stsf/STFontServer/dropins/freetype2/ftrenderglyph.inc
@@ -135,11 +135,13 @@
     slot = face->glyph;
 
     if (aconv & 0x01) {
-        if (((FT_GlyphSlotRec *) slot)->format == FT_GLYPH_FORMAT_BITMAP) {
-            emboldenhack = 1;
-        } else {
+        emboldenhack = 1;
+#ifdef HAVE_FT_GLYPHSLOT_EMBOLDEN
+        if (((FT_GlyphSlotRec *) slot)->format != FT_GLYPH_FORMAT_BITMAP) {
+            emboldenhack = 0;
             FT_GlyphSlot_Embolden(slot);
         }
+#endif
     } else if (aconv & 0x04) {
         emboldenhack = 1;
     }
--- orig/stsf/STFontServer/dropins/freetype2/ft2_glue.c
+++ mod/stsf/STFontServer/dropins/freetype2/ft2_glue.c
@@ -65,6 +65,7 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 #include FT_OUTLINE_H
+#include <freetype/ftsynth.h>
 
 #define POS_TO_FLOAT(x) (((float) x) / 64.0)
 

3)
Searching of ICU library is almost hardwired. I add option to
specify the location of ICU, manually.

--- orig/stsf/configure.ac
+++ mod/stsf/configure.ac
@@ -429,22 +429,37 @@
 AC_HEADER_STDC
 AC_HEADER_STAT
 
-
 # Check for ICU
 dnl Shortcut - check for the header, and then take the library from the
 dnl same path without actually checking for it
+AC_ARG_WITH(icu-prefix, [  --with-icu-prefix=PATH     specify location of IBM
ICU (ICU4C) ])
+
 save_CFLAGS=${CFLAGS}
 save_CPPFLAGS=${CPPFLAGS}
-ICU_TRY2="/usr/local/include"
-ICU_TRY3="${ICUINC:-/opt/sfw/include}"
-ICU_INC=
-ICU_LIB="-licuuc"
-ICU_TRY2_LIB="/usr/local/lib"
-ICU_TRY3_LIB="${ICULIB:-/opt/sfw/lib}"
+if test "x${with_icu_prefix}" != "x"
+then
+  save_LIBS=${LIBS}
+  ICU_INC="-I${with_icu_prefix}/include"
+  ICU_LIB="-L${with_icu_prefix}/lib -licuuc"
+  CPPFLAGS="${CPPFLAGS} ${ICU_INC}"
+  CFLAGS="${CFLAGS} ${ICU_INC}"
+  CXXFLAGS="${CXXFLAGS} ${ICU_INC}"
+  LIBS="${LIBS} ${ICU_LIB}"
+  AC_CHECK_HEADER(unicode/ubidi.h, [],
+    [
+      AC_MSG_ERROR([cannot find ICU header in "${with_icu_prefix}"/include])
+    ])
+else
+  ICU_TRY2="/usr/local/include"
+  ICU_TRY3="${ICUINC:-/opt/sfw/include}"
+  ICU_INC=
+  ICU_LIB="-licuuc"
+  ICU_TRY2_LIB="/usr/local/lib"
+  ICU_TRY3_LIB="${ICULIB:-/opt/sfw/lib}"
 
-dnl AC_MSG_NOTICE([CFLAGS is: ${CFLAGS}])
+  dnl AC_MSG_NOTICE([CFLAGS is: ${CFLAGS}])
 
-AC_CHECK_HEADER(unicode/ubidi.h, [],
+  AC_CHECK_HEADER(unicode/ubidi.h, [],
     [
         AC_MSG_NOTICE([trying again, looking in ${ICU_TRY2} this time...])
         CFLAGS="${save_CFLAGS} -I${ICU_TRY2}"
@@ -466,6 +481,7 @@
             ])
         ])
     ])
+fi
 CFLAGS=${save_CFLAGS}
 
 dnl save_LDFLAGS="${LDFLAGS}"
--- orig/stsf/STClientLibrary/src/makefile
+++ mod/stsf/STClientLibrary/src/makefile
@@ -105,13 +105,13 @@
 	ln -s libST.so.1 libST.so
 
 #libtest: libtest.o libST.so.1
-#	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST
-L../../STFontServer/src -lSTFontServer -L../../stsflib -lstsf
-R.:../../STFontServer/src:../../stsflib -licudata -licui18n -licuuc -licutoolutil 
+#	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST
-L../../STFontServer/src -lSTFontServer -L../../stsflib -lstsf
-R.:../../STFontServer/src:../../stsflib $(ICU_LIB) -licudata -licui18n -licuuc
-licutoolutil
 
 stperf: stperf.o libST.so.1
-	$(LB) $(LDFLAGS) -o $@ stperf.o $(THREAD_LIBS) $(CHECKSUM_LIBS) -L. -lST
-L../../stsflib -lstsf $(STFONTSERVERLIB) -L/usr/local/lib -licudata -licui18n
-licuuc -licutoolutil  $(RUNPATH)
+	$(LB) $(LDFLAGS) -o $@ stperf.o $(THREAD_LIBS) $(CHECKSUM_LIBS) -L. -lST
-L../../stsflib -lstsf $(STFONTSERVERLIB) $(ICU_LIB) -licudata -licui18n -licuuc
-licutoolutil $(RUNPATH)
 
 libtest: libtest.o libST.so.1
-	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST -L../../stsflib
-lstsf $(STFONTSERVERLIB) -L/usr/local/lib -licudata -licui18n -licuuc
-licutoolutil $(RUNPATH)
+	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST -L../../stsflib
-lstsf $(STFONTSERVERLIB) $(ICU_LIB) -licudata -licui18n -licuuc -licutoolutil
$(RUNPATH)
 
 glyphmanagertest: GlyphManager.o
 	$(LB) $(LDFLAGS) -o $@ $+ -L../../stsflib -lstsf
-Wl,-R.:../../STFontServer/src:../../stsflib

3)
libicutoolutil is not provided anymore, in recent ICU.

--- orig/stsf/configure.ac
+++ mod/stsf/configure.ac
@@ -505,6 +505,14 @@
     [
       AC_MSG_ERROR([cannot find ICU header in "${with_icu_prefix}"/include])
     ])
+  CC_no_icu_ldflags=${CC}
+  CC="${CC} -L${with_icu_prefix}/lib -licuuc -licudata -licuuc -licudata"
+  AC_CHECK_LIB(icutoolutil, u_parseUTF8, [
+      LIBICUTOOLUTIL="-licutoolutil"
+    ], [
+      LIBICUTOOLUTIL=""
+    ])
+  CC=${CC_no_icu_ldflags}
 else
   ICU_TRY2="/usr/local/include"
   ICU_TRY3="${ICUINC:-/opt/sfw/include}"
@@ -512,6 +520,7 @@
   ICU_LIB="-licuuc"
   ICU_TRY2_LIB="/usr/local/lib"
   ICU_TRY3_LIB="${ICULIB:-/opt/sfw/lib}"
+  LIBICUTOOLUTIL="-licutoolutil"
 
   dnl AC_MSG_NOTICE([CFLAGS is: ${CFLAGS}])
 
@@ -573,6 +582,7 @@
 
 AC_SUBST([ICU_INC])
 AC_SUBST([ICU_LIB])
+AC_SUBST([LIBICUTOOLUTIL])
 
 
 # Checks for typedefs, structures, and compiler characteristics.
--- orig/stsf/config.mk.in
+++ mod/stsf/config.mk.in
@@ -84,6 +84,7 @@
 # Flags for compiling & linking things that need icuuc
 ICU_INC = @ICU_INC@
 ICU_LIB = @ICU_LIB@
+LIBICUTOOLUTIL = @LIBICUTOOLUTIL@
 
 # Solaris doors
 USE_DOORS = @USE_DOORS@
--- orig/stsf/STClientLibrary/src/makefile
+++ mod/stsf/STClientLibrary/src/makefile
@@ -105,13 +105,13 @@
 	ln -s libST.so.1 libST.so
 
 #libtest: libtest.o libST.so.1
-#	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST
-L../../STFontServer/src -lSTFontServer -L../../stsflib -lstsf
-R.:../../STFontServer/src:../../stsflib $(ICU_LIB) -licudata -licui18n -licuuc
-licutoolutil
+#	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST
-L../../STFontServer/src -lSTFontServer -L../../stsflib -lstsf
-R.:../../STFontServer/src:../../stsflib $(ICU_LIB) -licudata -licui18n -licuuc
$(LIBICUTOOLUTIL)
 
 stperf: stperf.o libST.so.1
-	$(LB) $(LDFLAGS) -o $@ stperf.o $(THREAD_LIBS) $(CHECKSUM_LIBS) -L. -lST
-L../../stsflib -lstsf $(STFONTSERVERLIB) $(ICU_LIB) -licudata -licui18n -licuuc
-licutoolutil $(RUNPATH)
+	$(LB) $(LDFLAGS) -o $@ stperf.o $(THREAD_LIBS) $(CHECKSUM_LIBS) -L. -lST
-L../../stsflib -lstsf $(STFONTSERVERLIB) $(ICU_LIB) -licudata -licui18n -licuuc
$(LIBICUTOOLUTIL) $(RUNPATH)
 
 libtest: libtest.o libST.so.1
-	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST -L../../stsflib
-lstsf $(STFONTSERVERLIB) $(ICU_LIB) -licudata -licui18n -licuuc -licutoolutil
$(RUNPATH)
+	$(LB) $(LDFLAGS) -o $@ libtest.o $(CHECKSUM_LIBS) -L. -lST -L../../stsflib
-lstsf $(STFONTSERVERLIB) $(ICU_LIB) -licudata -licui18n -licuuc
$(LIBICUTOOLUTIL) $(RUNPATH)
 
 glyphmanagertest: GlyphManager.o
 	$(LB) $(LDFLAGS) -o $@ $+ -L../../stsflib -lstsf
-Wl,-R.:../../STFontServer/src:../../stsflib

4)
By default, some linuxthreads (e.g. glibc-2.2) is not full-featured
PTHREAD. Appropriate CFLAGS is expected.

--- orig/stsf/configure.ac
+++ mod/stsf/configure.ac
@@ -456,6 +456,35 @@
 AC_HEADER_STDC
 AC_HEADER_STAT
 
+# Checks additional definition to use required pthread features
+if test "xyes" = x"${ac_cv_header_pthread_h}"
+then
+    save_CFLAGS=${CFLAGS}
+    AC_MSG_CHECKING([CFLAGS to use pthread_rwlock_t])
+    m_ok=
+    for m in DUMMY _XOPEN_SOURCE=500 _XOPEN_SOURCE=600 _GNU_SOURCE _BSD_SOURCE
_ISOC99_SOURCE
+    do
+       CFLAGS="${save_CFLAGS} -D${m}"
+       AC_TRY_COMPILE([#include <pthread.h>], [pthread_rwlock_t *rwlock = NULL], [
+           if test x"${m_ok}" = x
+           then
+               m_ok=${m}
+           fi
+           break
+       ], [
+       ])
+    done
+    if test "xDUMMY" = x"${m_ok}"
+    then
+       AC_MSG_RESULT([none needed])
+    elif test "x" != x"${m_ok}"
+    then
+       AC_MSG_RESULT([${m_ok}])
+    else
+       AC_MSG_ERROR([cannot use pthread_rwlock_t type])
+    fi
+fi
+
 # Check for ICU
 dnl Shortcut - check for the header, and then take the library from the
 dnl same path without actually checking for it

5)
there is small bug in debug macro.

--- orig/stsf/STFontServer/src/fontenumerator.c
+++ mod/stsf/STFontServer/src/fontenumerator.c
@@ -660,7 +660,7 @@
     }
 }
 #else
-#define DEBUG_PRINT_VIRTUAL_FONT(a, b)
+#define DEBUG_PRINT_VIRTUAL_FONT(a, b, c)
 #endif
 
     
6)
uint32_t can be declared more portably.
--- orig/stsf/stsflib/crc32.h
+++ mod/stsf/stsflib/crc32.h
@@ -43,7 +43,7 @@
  *
  */
 
-#include <sys/types.h>
+#include <sttypes.h>
 
 #ifdef __cplusplus
 extern "C"{

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.