prefix = @prefix@
exec_prefix = @exec_prefix@

sharedir = @prefix@/share/fontforge
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
VPATH = @srcdir@
bindir = @bindir@
libdir = @libdir@
plugindir = $(sharedir)/plugins

LIBTOOL = @LIBTOOL@
CC = @CC@

X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_11LIB = @X_11LIB@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
STATIC_LIBS = @STATIC_LIBS@

fontforge_LIBOBJECTS =  autohint.o autosave.o autowidth.o bitmapdlg.o \
 bitmapview.o bvedit.o charview.o charviewicons.o cursors.o \
 cvaddpoints.o cvexport.o cvgetinfo.o cvhints.o cvimages.o cvknife.o \
 cvpalettes.o cvpointer.o cvruler.o cvshapes.o cvstroke.o cvtranstools.o \
 cvundoes.o dumpbdf.o dumppfa.o fontinfo.o fontview.o fvcomposit.o \
 fvfonts.o fvimportbdf.o fvmetrics.o images.o metricsview.o \
 parsepfa.o parsettf.o prefs.o psread.o psunicodenames.o savefontdlg.o \
 sfd.o splashimage.o splinefill.o splineoverlap.o splinesave.o \
 splinesaveafm.o splinestroke.o splineutil.o splineutil2.o stamp.o \
 start.o tottf.o transform.o uiutil.o utils.o windowmenu.o  \
 zapfnomen.o othersubrs.o autotrace.o openfontdlg.o encoding.o print.o \
 problems.o metafont.o alignment.o parsettfbmf.o \
 macbinary.o crctab.o scripting.o freetype.o gotodlg.o search.o \
 combinations.o tilepath.o sftextfield.o displayfonts.o ikarus.o \
 cvhand.o cvfreehand.o simplifydlg.o winfonts.o tottfgpos.o tottfaat.o \
 charinfo.o splineorder2.o genttfinstrs.o ttfinstrs.o cvgridfit.o \
 cvdebug.o showatt.o kernclass.o nonlineartrans.o effects.o \
 histograms.o ttfspecial.o svg.o parsettfatt.o contextchain.o \
 macenc.o statemachine.o typofeatures.o splinerefigure.o mm.o \
 parsettfvar.o tottfvar.o pua.o stemdb.o anchorsaway.o palmfonts.o \
 cvdgloss.o groups.o parsepdf.o plugins.o bdfinfo.o \
 @FF_EXTRA_FILES@
DIFFOBJS = sfddiff.o sfd.o diffstubs.o stamp.o
ACORNOBJS = acorn2sfd.o sfd.o diffstubs.o psunicodenames.o stamp.o

_CFLAGS = -I$(top_srcdir)/inc -I$(srcdir) -I. @WFLAGS@ $(X_CFLAGS) \
    @DEFS@ '-DSHAREDIR="$(sharedir)"' -DLIBDIR='"$(libdir)"' \
    @CPPFLAGS@ '-DPREFIX="@prefix@"'
CFLAGS = @CFLAGS@ $(_CFLAGS)

LIBS = -rpath $(libdir) $(X_LIBS) ../libgdraw.la ../libgunicode.la \
    $(X_PRE_LIBS) $(X_11LIB) $(X_EXTRA_LIBS) @LIBS@ $(STATIC_LIBS) -L/usr/lib -lm
DLIBS = -rpath $(libdir) ../libgunicode.la @LIBS@ $(STATIC_LIBS) -lm

all: fontforge

fontforge: main.o $(fontforge_LIBOBJECTS)
	$(LIBTOOL) --mode=link $(CC) -export-dynamic -o fontforge main.o $(fontforge_LIBOBJECTS) $(LIBS)

sfddiff: $(DIFFOBJS)
	$(LIBTOOL) --mode=link $(CC) -o sfddiff $(DIFFOBJS) $(DLIBS)

acorn2sfd: $(ACORNOBJS)
	$(LIBTOOL) --mode=link $(CC) -o acorn2sfd $(ACORNOBJS) $(DLIBS)

# The slight error introduced occasionally by optimization turns out to have
# disasterous effects. This file may not be compiled with the optimizer.
# On the other hand we do need CPPFLAGS to get the right includes...
splinerefigure.o: $(srcdir)/splinerefigure.c
	$(CC) -g -c -o splinerefigure.o $(_CFLAGS) $(srcdir)/splinerefigure.c

splinerefigure.lo: $(srcdir)/splinerefigure.c
	$(LIBTOOL) --mode=compile $(CC) -g -c -o splinerefigure.lo $(_CFLAGS) $(srcdir)/splinerefigure.c

#%.o: %.c
#	$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $<


clean:
	-rm -f *.o *.o fontforge sfddiff po/*.mo
	-rm -rf .libs

distclean cleaner: clean
	-rm -f Makefile

install:
	( cd .. ; make install )

# xgettext has caniptions and strips any non-ASCII characters from my strings
# but I do occasionally want to use unicode characters (TeX, arrows, Increment)
# so I have put these messages in utf8.pot which I manage by hand. non-ASCII
# strings work just fine as keys. It does mean that my pot files should be
# viewed in utf8 though.

# I am told that new versions of xgettext support an option --from-code=UTF-8
# unfortunately this works on none of the systems I use, and I haven't found
# it documented. If it worked I would not need utf8.pot.
fontforge.pot: *.c utf8.pot
	xgettext -k_ -kN_ -kS_ -kP_:1,2 -ofontforge.pot *.c ../gdraw/*.c
	cat utf8.pot >> fontforge.pot
