Fix VPATH and out-of-tree builds


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3984 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/jpeg/Makefile.am b/common/jpeg/Makefile.am
index 26fe44c..622b362 100644
--- a/common/jpeg/Makefile.am
+++ b/common/jpeg/Makefile.am
@@ -30,16 +30,16 @@
 
 jpgtest_SOURCES = $(TSTHDRS) jpgtest.cxx bmp.h bmp.c turbojpegl.c
 
-jpgtest_LDADD = $(top_srcdir)/libjpeg.la
+jpgtest_LDADD = libjpeg.la
 
 jpegut_SOURCES = $(TSTHDRS) jpegut.c bmp.h bmp.c turbojpegl.c
 
-jpegut_LDADD = $(top_srcdir)/libjpeg.la
+jpegut_LDADD = libjpeg.la
 
 cjpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c cjpeg.c rdbmp.c rdgif.c \
 	rdppm.c rdswitch.c rdtarga.c 
 
-cjpeg_LDADD = $(top_srcdir)/libjpeg.la
+cjpeg_LDADD = libjpeg.la
 
 cjpeg_CFLAGS = -DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED \
 	-DTARGA_SUPPORTED
@@ -47,7 +47,7 @@
 djpeg_SOURCES = cdjpeg.h cderror.h cdjpeg.c djpeg.c rdcolmap.c rdswitch.c \
 	wrbmp.c wrgif.c wrppm.c wrtarga.c
 
-djpeg_LDADD = $(top_srcdir)/libjpeg.la
+djpeg_LDADD = libjpeg.la
 
 djpeg_CFLAGS = -DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED \
 	-DTARGA_SUPPORTED
diff --git a/common/jpeg/simd/Makefile.am b/common/jpeg/simd/Makefile.am
index 1df6143..e57c477 100644
--- a/common/jpeg/simd/Makefile.am
+++ b/common/jpeg/simd/Makefile.am
@@ -49,9 +49,11 @@
 jdmerss2.lo: jdmrgss2.asm
 endif
 
-.asm.lo:
-	$(LIBTOOL) --mode=compile --tag NASM ./nasm_lt.sh $(NASM) $(NAFLAGS) $< -o $@
+AM_CPPFLAGS = -I$(top_srcdir) 
 
-jsimdcfg.inc: jsimdcfg.inc.h ../jpeglib.h ../jconfig.h ../jmorecfg.h
-	$(CPP) jsimdcfg.inc.h | $(EGREP) ^[\;%] | sed 's%_cpp_protection_%%' > $@
+.asm.lo:
+	$(LIBTOOL) --mode=compile --tag NASM $(srcdir)/nasm_lt.sh $(NASM) $(NAFLAGS) -I$(srcdir) $< -o $@
+
+jsimdcfg.inc: $(srcdir)/jsimdcfg.inc.h ../jpeglib.h ../jconfig.h ../jmorecfg.h
+	$(CPP) -I$(top_builddir) -I$(top_builddir)/simd $(srcdir)/jsimdcfg.inc.h | $(EGREP) ^[\;%] | sed 's%_cpp_protection_%%' > $@
 
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index eec0076..4c14366 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -46,5 +46,5 @@
 
 if INCLUDED_JPEG
 librfb_la_CPPFLAGS += -I$(top_srcdir)/common/jpeg
-librfb_la_LIBADD += $(top_srcdir)/common/jpeg/libjpeg.la
+librfb_la_LIBADD += $(top_builddir)/common/jpeg/libjpeg.la
 endif
diff --git a/unix/vncconfig/Makefile.am b/unix/vncconfig/Makefile.am
index fc1c095..eae1b44 100644
--- a/unix/vncconfig/Makefile.am
+++ b/unix/vncconfig/Makefile.am
@@ -10,10 +10,10 @@
 # X_CFLAGS are really CPPFLAGS
 vncconfig_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/unix/tx @X_CFLAGS@
 
-vncconfig_LDADD = $(top_srcdir)/unix/tx/libtx.la \
-	$(top_srcdir)/common/rfb/librfb.la \
-	$(top_srcdir)/common/network/libnetwork.la \
-	$(top_srcdir)/common/rdr/librdr.la @X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext \
+vncconfig_LDADD = $(top_builddir)/unix/tx/libtx.la \
+	$(top_builddir)/common/rfb/librfb.la \
+	$(top_builddir)/common/network/libnetwork.la \
+	$(top_builddir)/common/rdr/librdr.la @X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext \
 	@X_EXTRA_LIBS@
 
 EXTRA_DIST = vncconfig.man
diff --git a/unix/vncpasswd/Makefile.am b/unix/vncpasswd/Makefile.am
index cad2859..00951be 100644
--- a/unix/vncpasswd/Makefile.am
+++ b/unix/vncpasswd/Makefile.am
@@ -6,7 +6,7 @@
 
 vncpasswd_CPPFLAGS = -I$(top_srcdir)/common
 
-vncpasswd_LDADD = $(top_srcdir)/common/rfb/librfb.la \
-	$(top_srcdir)/common/rdr/librdr.la
+vncpasswd_LDADD = $(top_builddir)/common/rfb/librfb.la \
+	$(top_builddir)/common/rdr/librdr.la
 
 EXTRA_DIST = vncpasswd.man
diff --git a/unix/vncviewer/Makefile.am b/unix/vncviewer/Makefile.am
index e5e0190..9690015 100644
--- a/unix/vncviewer/Makefile.am
+++ b/unix/vncviewer/Makefile.am
@@ -12,10 +12,10 @@
 	-I$(top_srcdir)/unix/tx -I$(top_srcdir)/intl \
 	-DLOCALEDIR=\"$(localedir)\" @X_CFLAGS@
 
-vncviewer_LDADD = $(top_srcdir)/unix/tx/libtx.la \
-	$(top_srcdir)/common/rfb/librfb.la \
-	$(top_srcdir)/common/network/libnetwork.la \
-	$(top_srcdir)/common/rdr/librdr.la \
+vncviewer_LDADD = $(top_builddir)/unix/tx/libtx.la \
+	$(top_builddir)/common/rfb/librfb.la \
+	$(top_builddir)/common/network/libnetwork.la \
+	$(top_builddir)/common/rdr/librdr.la \
 	@X_PRE_LIBS@ @X_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@ # @LIBINTL@
 
 EXTRA_DIST = vncviewer.man
diff --git a/unix/x0vncserver/Makefile.am b/unix/x0vncserver/Makefile.am
index 7959304..c947257 100644
--- a/unix/x0vncserver/Makefile.am
+++ b/unix/x0vncserver/Makefile.am
@@ -15,10 +15,10 @@
 	-I$(top_srcdir)/unix @XTEST_DEFINE@ @READDISPLAY_DEFINE@ \
 	@MITSHM_DEFINE@ @X_CFLAGS@
 
-x0vncserver_LDADD = $(top_srcdir)/common/rfb/librfb.la \
-	$(top_srcdir)/common/network/libnetwork.la \
-	$(top_srcdir)/common/rdr/librdr.la \
-	$(top_srcdir)/unix/tx/libtx.la @INET_LIB@ @X_PRE_LIBS@ @X_LIBS@ \
+x0vncserver_LDADD = $(top_builddir)/common/rfb/librfb.la \
+	$(top_builddir)/common/network/libnetwork.la \
+	$(top_builddir)/common/rdr/librdr.la \
+	$(top_builddir)/unix/tx/libtx.la @INET_LIB@ @X_PRE_LIBS@ @X_LIBS@ \
 	@XTEST_LIB@ -lXext -lX11 @X_EXTRA_LIBS@
 
 EXTRA_DIST = x0vncserver.man