Commit 179c3995 authored by Keith Packard's avatar Keith Packard

Fix autoconf build process for fontconfig

parent 1ce2a1bb
#
# $XFree86$
#
# Copyright 2002 Keith Packard, member of The XFree86 Project, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of Keith Packard not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Keith Packard makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
SHELL = @SHELL@
srcdir=@srcdir@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
bindir=@bindir@
datadir=@datadir@
includedir=@includedir@
sysconfdir=@sysconfdir@
CDEBUGFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
DEFS=@DEFS@
DSO_LDOPTS=@DSO_LDOPTS@
DSO_CFLAGS=@DSO_CFLAGS@
DSO_PIC_CFLAGS=@DSO_PIC_CFLAGS@
INCLUDES=-I$(TOPDIR) -I$(srcdir)
CFLAGS=$(CDEBUGFLAGS) $(INCLUDES) $(DEFS) $(CPPFLAGS)
INSTALL=@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_SCRIPT=@INSTALL_SCRIPT@
INSTALL_DATA=@INSTALL_DATA@
MKSHLIB=@MKSHLIB@
LN_S=@LN_S@
# shared libraries
LIBDIR=$(libdir)
# programs
BINDIR=$(bindir)
# font configuration files
CONFDIR=$(sysconfdir)/fonts
LIBBASE=libfontconfig.so
LIBFILE=$(LIBBASE).@PACKAGE_MAJOR@.@PACKAGE_MINOR@
LIBMAJOR=$(LIBBASE).@PACKAGE_MAJOR@
LIBFONTCONFIG=-L$(SRCDIR) -lfontconfig
SRCDIR=$(TOPDIR)/src
This diff is collapsed.
This diff is collapsed.
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# $XFree86$
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
tranformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
#ifdef UseInstalled
/* building outside the tree, use private defines */
#include "../local.def"
#endif
INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
LOCAL_LIBRARIES=FontconfigClientLibs
......@@ -11,5 +16,5 @@ LinkBuildBinary(ProgramTargetName(fc-cache))
install::
if [ x$${DESTDIR} = x ]; then \
FC_DEBUG=128 $(FCCACHE) -v ;\
$(FCCACHE) -v -f;\
fi
#
# $XFree86$
#
# Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of Keith Packard not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Keith Packard makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
TOPDIR=..
include $(TOPDIR)/config/Makedefs
SRCS=fc-cache.c
OBJS=fc-cache.o
PROG=fc-cache
all:: $(PROG)
install:: $(BINDIR)/$(PROG)
$(BINDIR)/$(PROG): $(PROG)
$(INSTALL_PROGRAM) $(PROG) $(BINDIR)
clean::
rm -f $(PROG) $(OBJS)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBFONTCONFIG)
......@@ -46,6 +46,7 @@
#define _GNU_SOURCE
#include <getopt.h>
const struct option longopts[] = {
{"force", 0, 0, 'f'},
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
{"help", 0, 0, '?'},
......@@ -61,41 +62,134 @@ extern int optind, opterr, optopt;
static void
usage (char *program)
{
fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
fprintf (stderr, "usage: %s [-fvV?] [--force] [--verbose] [--version] [--help] [dirs]\n",
program);
fprintf (stderr, "Build font information caches in [dirs]\n"
"(all directories in font configuration by default).\n");
fprintf (stderr, "\n");
fprintf (stderr, " -v, --force scan directories with apparently valid caches\n");
fprintf (stderr, " -v, --verbose display status information while busy\n");
fprintf (stderr, " -V, --version display font config version and exit\n");
fprintf (stderr, " -?, --help display this help and exit\n");
exit (1);
}
int
main (int argc, char **argv)
static int
nsubdirs (FcStrSet *set)
{
FcStrList *list;
int n = 0;
list = FcStrListCreate (set);
if (!list)
return 0;
while (FcStrListNext (list))
n++;
FcStrListDone (list);
return n;
}
static int
scanDirs (FcStrList *list, char *program, FcBool force, FcBool verbose)
{
int ret = 0;
FcChar8 *dir;
FcFontSet *set;
FcChar8 **dirs;
int verbose = 0;
FcStrSet *subdirs;
FcStrList *sublist;
/*
* Now scan all of the directories into separate databases
* and write out the results
*/
while ((dir = FcStrListNext (list)))
{
if (verbose)
{
printf ("%s: \"%s\": ", program, dir);
fflush (stdout);
}
set = FcFontSetCreate ();
if (!set)
{
fprintf (stderr, "Can't create font set\n");
ret++;
continue;
}
subdirs = FcStrSetCreate ();
if (!subdirs)
{
fprintf (stderr, "Can't create directory set\n");
ret++;
continue;
}
if (!FcDirScan (set, subdirs, 0, FcConfigGetBlanks (0), dir, force))
{
fprintf (stderr, "Can't scan \"%s\"\n", dir);
ret++;
continue;
}
if (!force && FcDirCacheValid (dir))
{
if (verbose)
printf ("skipping, %d fonts, %d dirs\n",
set->nfont, nsubdirs(subdirs));
}
else
{
if (verbose)
printf ("caching, %d fonts, %d dirs\n",
set->nfont, nsubdirs (subdirs));
if (!FcDirSave (set, subdirs, dir))
{
fprintf (stderr, "Can't save cache in \"%s\"\n", dir);
ret++;
}
}
FcFontSetDestroy (set);
sublist = FcStrListCreate (subdirs);
if (!sublist)
{
fprintf (stderr, "Can't create subdir list in \"%s\"\n", dir);
ret++;
continue;
}
ret += scanDirs (sublist, program, force, verbose);
FcStrSetDestroy (subdirs);
}
FcStrListDone (list);
return ret;
}
int
main (int argc, char **argv)
{
FcStrSet *dirs;
FcStrList *list;
FcBool verbose = FcFalse;
FcBool force = FcFalse;
FcConfig *config;
int i;
int ret;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
while ((c = getopt_long (argc, argv, "fVv?", longopts, NULL)) != -1)
#else
while ((c = getopt (argc, argv, "Vv?")) != -1)
while ((c = getopt (argc, argv, "fVv?")) != -1)
#endif
{
switch (c) {
case 'f':
force = FcTrue;
break;
case 'V':
fprintf (stderr, "fontconfig version %d.%d.%d\n",
FC_MAJOR, FC_MINOR, FC_REVISION);
exit (0);
case 'v':
verbose = 1;
verbose = FcTrue;
break;
default:
usage (argv[0]);
......@@ -106,51 +200,36 @@ main (int argc, char **argv)
i = 1;
#endif
if (!FcInitConfig ())
config = FcInitLoadConfig ();
if (!config)
{
fprintf (stderr, "Can't init font config library\n");
fprintf (stderr, "%s: Can't init font config library\n", argv[0]);
return 1;
}
if (argv[i])
dirs = (FcChar8 **) (argv+i);
else
dirs = FcConfigGetDirs (0);
/*
* Now scan all of the directories into separate databases
* and write out the results
*/
while (dirs && *dirs)
{
if (verbose)
printf ("%s: Scanning directory \"%s\"\n", argv[0], *dirs);
set = FcFontSetCreate ();
if (!set)
dirs = FcStrSetCreate ();
if (!dirs)
{
fprintf (stderr, "Out of memory in \"%s\"\n", *dirs);
ret++;
fprintf (stderr, "%s: Can't create list of directories\n",
argv[0]);
return 1;
}
else
while (argv[i])
{
if (!FcDirScan (set, 0, FcConfigGetBlanks (0), *dirs, FcTrue))
if (!FcStrSetAdd (dirs, (FcChar8 *) argv[i]))
{
fprintf (stderr, "Can't scan directory \"%s\"\n", *dirs);
ret++;
fprintf (stderr, "%s: Can't add directory\n", argv[0]);
return 1;
}
else
{
if (verbose)
printf ("%s: Saving %d font names for \"%s\"\n",
argv[0], set->nfont, *dirs);
if (!FcDirSave (set, *dirs))
{
fprintf (stderr, "Can't save cache in \"%s\"\n", *dirs);
ret++;
}
}
FcFontSetDestroy (set);
i++;
}
++dirs;
list = FcStrListCreate (dirs);
FcStrSetDestroy (dirs);
}
else
list = FcConfigGetConfigDirs (config);
ret = scanDirs (list, argv[0], force, verbose);
if (verbose)
printf ("%s: %s\n", argv[0], ret ? "failed" : "succeeded");
return ret;
......
#
# $XFree86$
#
# Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of Keith Packard not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Keith Packard makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
TOPDIR=..
include $(TOPDIR)/config/Makedefs
SRCS=fc-list.c
OBJS=fc-list.o
PROG=fc-list
all:: $(PROG)
install:: $(BINDIR)/$(PROG)
$(BINDIR)/$(PROG): $(PROG)
$(INSTALL_PROGRAM) $(PROG) $(BINDIR)
clean::
rm -f $(PROG) $(OBJS)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBFONTCONFIG)
......@@ -228,6 +228,10 @@ typedef struct _FcFileCache FcFileCache;
typedef struct _FcBlanks FcBlanks;
typedef struct _FcStrList FcStrList;
typedef struct _FcStrSet FcStrSet;
_FCFUNCPROTOBEGIN
/* fcblanks.c */
......@@ -259,13 +263,19 @@ FcConfigSetCurrent (FcConfig *config);
FcConfig *
FcConfigGetCurrent (void);
FcBool
FcConfigUptoDate (FcConfig *config);
FcBool
FcConfigBuildFonts (FcConfig *config);
FcChar8 **
FcConfigGetDirs (FcConfig *config);
FcStrList *
FcConfigGetFontDirs (FcConfig *config);
FcStrList *
FcConfigGetConfigDirs (FcConfig *config);
FcChar8 **
FcStrList *
FcConfigGetConfigFiles (FcConfig *config);
FcChar8 *
......@@ -274,6 +284,12 @@ FcConfigGetCache (FcConfig *config);
FcBlanks *
FcConfigGetBlanks (FcConfig *config);
int
FcConfigGetRescanInverval (FcConfig *config);
FcBool
FcConfigSetRescanInverval (FcConfig *config, int rescanInterval);
FcFontSet *
FcConfigGetFonts (FcConfig *config,
FcSetName set);
......@@ -351,6 +367,7 @@ FcDefaultSubstitute (FcPattern *pattern);
/* fcdir.c */
FcBool
FcFileScan (FcFontSet *set,
FcStrSet *dirs,
FcFileCache *cache,
FcBlanks *blanks,
const FcChar8 *file,
......@@ -358,13 +375,17 @@ FcFileScan (FcFontSet *set,
FcBool
FcDirScan (FcFontSet *set,
FcStrSet *dirs,
FcFileCache *cache,
FcBlanks *blanks,
const FcChar8 *dir,
FcBool force);
FcBool
FcDirSave (FcFontSet *set, const FcChar8 *dir);
FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir);
FcBool
FcDirCacheValid (const FcChar8 *dir);
/* fcfreetype.c */
FcPattern *
......@@ -382,14 +403,20 @@ FcBool
FcFontSetAdd (FcFontSet *s, FcPattern *font);
/* fcinit.c */
FcConfig *
FcInitLoadConfig (void);
FcConfig *
FcInitLoadConfigAndFonts (void);
FcBool
FcInitFonts (void);
FcInit (void);
FcBool
FcInitConfig (void);
FcInitReinitialize (void);
FcBool
FcInit (void);
FcInitBringUptoDate (void);
/* fclist.c */
FcObjectSet *
......@@ -592,11 +619,17 @@ FcPatternBuild (FcPattern *orig, ...);
FcChar8 *
FcStrCopy (const FcChar8 *s);
FcChar8 *
FcStrCopyFilename (const FcChar8 *s);
#define FcToLower(c) (('A' <= (c) && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
int
FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
int
FcStrCmp (const FcChar8 *s1, const FcChar8 *s2);
int
FcUtf8ToUcs4 (FcChar8 *src_orig,
FcChar32 *dst,
......@@ -608,6 +641,39 @@ FcUtf8Len (FcChar8 *string,