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@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

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@

ffgtk_OBJECTS = fontview.o startgtk.o uiutil.o cursors.o windowmenu.o prefs.o \
    openfontdlg.o stamp.o pythonui.o
gtk_widget_OBJECTS = gwwvmenubar.o gwwvask.o gwwvprogress.o
glade_OBJECTS = ff_interface.o support.o

_CFLAGS = -I$(top_srcdir)/inc -I../inc -I$(srcdir) -I$(top_srcdir) @WFLAGS@ $(X_CFLAGS) \
    @DEFS@ '-DSHAREDIR="$(sharedir)"' -DLIBDIR='"$(libdir)"' \
    @CPPFLAGS@ '-DPREFIX="@prefix@"'
CFLAGS = @CFLAGS@ $(_CFLAGS) `pkg-config --cflags gtk+-2.0`
LDFLAGS = @LDFLAGS@
LIBS = -rpath $(libdir) ../libfontforge.la ../libgutils.la \
    ../libgunicode.la \
    `pkg-config --libs gtk+-2.0` `pkg-config --libs gmodule-2.0` \
    @LIBS@ $(STATIC_LIBS) -lm

all: fontforgegtk

fontforgegtk: $(ffgtk_OBJECTS) $(gtk_widget_OBJECTS) $(glade_OBJECTS) stubs.o
	$(LIBTOOL) --mode=link $(CC) -export-dynamic $(LDFLAGS) -o fontforgegtk \
		$(ffgtk_OBJECTS) $(gtk_widget_OBJECTS) $(glade_OBJECTS) stubs.o \
		`pkg-config --libs gtk+-2.0` `pkg-config --libs gmodule-2.0` $(LIBS)

#ff_interface.c: interface.c add-my-widgets.sed
#	sed -f add-my-widgets.sed < interface.c > ff_interface.c

%.o: %.c $(srcdir)../fontforge/splinefont.h $(srcdir)/viewsgtk.h  $(srcdir)/../fontforge/uiinterface.h $(srcdir)/../fontforge/fontforgevw.h
	$(CC) $(CFLAGS) -c $<

clean:
	-rm -f fontforgegtk
	-rm -f *.o
	-rm -rf .libs

distclean cleaner: clean
	-rm -f Makefile

install:
	mkdir -p $(sharedir)/pixmaps
	mkdir -p $(DESTDIR)$(bindir)
	-$(INSTALL_DATA) $(srcdir)/pixmaps/*.{png,xbm} $(sharedir)/pixmaps
	$(LIBTOOL) --mode=install $(INSTALL) -c fontforgegtk $(DESTDIR)$(bindir)
