-AUTOMAKE_OPTIONS = foreign
-SUBDIRS = mathed insets graphics support frontends
-DISTCLEANFILES= *.orig *.rej *~ *.bak core libintl.h config.h
-MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/config.h.in
-bin_PROGRAMS = lyx
-## libfrontends is given twice on the link line because it needs stuff
-## from FRONTEND_GUILIB and inversely. If you do not like it, feel
-## free to provide another solution... Maybe signals would solve that
-## magically, but I do not understand them much (JMarc)
-lyx_DEPENDENCIES = mathed/libmathed.la insets/libinsets.la \
+include $(top_srcdir)/config/common.am
+
+DISTCLEANFILES += config.h libintl.h version.C stamp-version version.C-tmp
+
+MAINTAINERCLEANFILES += $(srcdir)/config.h.in
+
+if BUILD_CLIENT_SUBDIR
+CLIENT = client
+endif
+
+SUBDIRS = mathed insets graphics support frontends . $(CLIENT) tex2lyx
+
+EXTRA_DIST = config.h.in stamp-h.in version.C.in \
+ Section.h \
+ Section.cpp \
+ Variables.cpp \
+ Variables.h \
+ paper.h \
+ pch.h
+
+LYX_PRE_LIBS = mathed/libmathed.la insets/libinsets.la \
+ frontends/libfrontends.la
+
+LYX_POST_LIBS = frontends/controllers/libcontrollers.la \