Index: plugins/shell/src/tm_shell.cpp
===================================================================
--- plugins/shell/src/tm_shell.cpp	(revision 2477)
+++ plugins/shell/src/tm_shell.cpp	(working copy)
@@ -9,7 +9,7 @@
 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
 ******************************************************************************/
 
-#include "../../../src/System/config.h"
+#include "config.h"
 #include <iostream>
 #include <stdlib.h>
 #include <stdio.h>
Index: plugins/shell/Makefile
===================================================================
--- plugins/shell/Makefile	(revision 2477)
+++ plugins/shell/Makefile	(working copy)
@@ -14,7 +14,7 @@
 all: bin/tm_shell
 
 bin/tm_shell: src/tm_shell.cpp
-	$(CXX) -lutil src/tm_shell.cpp -o bin/tm_shell
+	$(CXX) -lutil -I$(builddir)/src/System src/tm_shell.cpp -o bin/tm_shell
 
 clean:
 	$(RM) bin/tm_shell
Index: plugins/r/src/tm_r.c
===================================================================
--- plugins/r/src/tm_r.c	(revision 2477)
+++ plugins/r/src/tm_r.c	(working copy)
@@ -8,9 +8,12 @@
 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
 ******************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <sys/select.h>
+#if HAVE_PTY_H
 #include <pty.h>
+#endif
 #include <utmp.h>
 #include <unistd.h>
 #include <termios.h>
Index: plugins/r/Makefile
===================================================================
--- plugins/r/Makefile	(revision 2477)
+++ plugins/r/Makefile	(working copy)
@@ -14,7 +14,7 @@
 all: bin/tm_r
 
 bin/tm_r: src/tm_r.c
-	$(CC) -lutil src/tm_r.c -o bin/tm_r
+	$(CC) -I$(builddir)/src/System -lutil src/tm_r.c -o bin/tm_r
 
 clean:
 	$(RM) bin/tm_r
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 2477)
+++ Makefile.in	(working copy)
@@ -15,6 +15,8 @@
 bindir = @bindir@
 datarootdir = @datarootdir@
 datadir = @datadir@
+srcdir = @srcdir@
+builddir = @builddir@
 mandir = @mandir@
 tmdir = @tmdir@
 tmtgz = @tmtgz@
@@ -38,31 +40,31 @@
 # Main makes
 ###############################################################################
 
-TEXMACS: EMPTY_DIRS
+TEXMACS: $(builddir)/TeXmacs EMPTY_DIRS 
 	cd src; $(MAKE) -f makefile link=shared
 	$(MAKE) -f Makefile PLUGINS
 	$(MAKE) -f Makefile EX_PLUGINS
 	$(CP) misc/scripts/fig2ps $(tmdir)/bin
 	$(CP) misc/scripts/texmacs $(tmdir)/bin
-	$(CP) misc/scripts/tm_gs $(tmdir)/bin
+	$(CP) $(srcdir)/misc/scripts/tm_gs $(tmdir)/bin
 	$(CHMOD) 755 $(tmdir)/bin/*
-	$(CHMOD) 755 plugins/*/bin/*
+	$(CHMOD) 755 $(srcdir)/plugins/*/bin/*
 	$(RM) $(tmdir)/plugins
-	$(LN) -s ../plugins $(tmdir)/plugins
+	$(LN) -s ../$(srcdir)/plugins $(tmdir)/plugins
 	@echo ----------------------------------------------------
 	@echo dynamic TeXmacs has been successfully compiled
 
-STATIC_TEXMACS: EMPTY_DIRS
+STATIC_TEXMACS: $(builddir)/TeXmacs EMPTY_DIRS
 	cd src; $(MAKE) -f makefile link=static
 	$(MAKE) -f Makefile PLUGINS
 	$(MAKE) -f Makefile EX_PLUGINS
 	$(CP) misc/scripts/fig2ps $(tmdir)/bin
 	$(CP) misc/scripts/texmacs $(tmdir)/bin
-	$(CP) misc/scripts/tm_gs $(tmdir)/bin
+	$(CP) $(srcdir)/misc/scripts/tm_gs $(tmdir)/bin
 	$(CHMOD) 755 $(tmdir)/bin/*
-	$(CHMOD) 755 plugins/*/bin/*
+	$(CHMOD) 755 $(srcdir)/plugins/*/bin/*
 	$(RM) $(tmdir)/plugins
-	$(LN) -s ../plugins $(tmdir)/plugins
+	$(LN) -s ../$(srcdir)/plugins $(tmdir)/plugins
 	@echo ----------------------------------------------------
 	@echo static TeXmacs has been successfully compiled
 
@@ -75,6 +77,12 @@
 	$(MKDIR) TeXmacs/bin
 	$(MKDIR) TeXmacs/lib
 
+# the next target copy the TeXmacs tree in case of out-of-place build 
+
+$(builddir)/TeXmacs : $(srcdir)/TeXmacs
+	$(CP) -r $(srcdir)/TeXmacs $(builddir)
+  
+
 .PHONY: TEXMACS STATIC_TEXMACS DEPS EXPERIMENTAL
 
 deps: DEPS
@@ -89,18 +97,20 @@
 # Plugins
 ###############################################################################
 
-PLUGINS_ALL := $(wildcard plugins/*)
-PLUGINS_MAKEFILE := $(wildcard plugins/*/Makefile)
+PLUGINS_ALL := $(wildcard $(srcdir)/plugins/*)
+PLUGINS_MAKEFILE := $(wildcard $(srcdir)/plugins/*/Makefile)
 PLUGINS_COMPILE := $(patsubst %Makefile,%COMPILE,$(PLUGINS_MAKEFILE))
 PLUGINS_CLEAN := $(patsubst %Makefile,%CLEAN,$(PLUGINS_MAKEFILE))
 
-plugins/%/COMPILE:
-	$(MKDIR) plugins/$*/bin
-	cd plugins/$*; $(MAKE) -i -f Makefile CC="@CC@" CXX="@CXX@"
+CURRENTDIR := $(shell pwd)
 
-plugins/%/CLEAN:
-	cd plugins/$*; $(MAKE) -i -f Makefile clean
+$(srcdir)/plugins/%/COMPILE:
+	$(MKDIR) $(srcdir)/plugins/$*/bin
+	cd $(srcdir)/plugins/$*; $(MAKE) -i -f Makefile CC="@CC@" CXX="@CXX@" builddir="$(CURRENTDIR)"
 
+$(srcdir)/plugins/%/CLEAN:
+	cd $(srcdir)/plugins/$*; $(MAKE) -i -f Makefile clean
+
 PLUGINS: $(PLUGINS_COMPILE)
 
 CLEAN_PLUGINS: $(PLUGINS_CLEAN)
@@ -198,10 +208,9 @@
 ###############################################################################
 # Make a bundle for Mac OS X
 ###############################################################################
-
-BUNDLE_SRC = misc/bundle
-BUNDLE_APP = ../distr/TeXmacs.app
-BUNDLE_DMG = ../distr/TeXmacs.dmg
+BUNDLE_SRC = $(srcdir)/misc/bundle
+BUNDLE_APP = TeXmacs.app
+BUNDLE_DMG = TeXmacs.dmg
 BUNDLE_CONTENTS = $(BUNDLE_APP)/Contents
 BUNDLE_RESOURCES = $(BUNDLE_CONTENTS)/Resources
 BUNDLE_TEXMACS = $(BUNDLE_RESOURCES)/share/TeXmacs
@@ -219,17 +228,17 @@
 	$(CP) TeXmacs/bin/texmacs.bin $(BUNDLE_CONTENTS)/MacOS
 	$(MKDIR) $(BUNDLE_RESOURCES)
 	$(CP) $(BUNDLE_SRC)/TeXmacs.icns $(BUNDLE_RESOURCES)
-	$(CP) src/Plugins/Cocoa/English.lproj $(BUNDLE_RESOURCES)
-	$(CP) src/Plugins/Cocoa/InputPanel.nib $(BUNDLE_RESOURCES)
-	$(CP) src/Plugins/Cocoa/InputDialog.nib $(BUNDLE_RESOURCES)
-	$(CP) src/Plugins/Cocoa/Segment.nib $(BUNDLE_RESOURCES)
+	$(CP) $(srcdir)/src/Plugins/Cocoa/English.lproj $(BUNDLE_RESOURCES)
+	$(CP) $(srcdir)/src/Plugins/Cocoa/InputPanel.nib $(BUNDLE_RESOURCES)
+	$(CP) $(srcdir)/src/Plugins/Cocoa/InputDialog.nib $(BUNDLE_RESOURCES)
+	$(CP) $(srcdir)/src/Plugins/Cocoa/Segment.nib $(BUNDLE_RESOURCES)
 	$(MKDIR) $(BUNDLE_RESOURCES)/bin
 	$(MKDIR) $(BUNDLE_RESOURCES)/lib
 	$(MKDIR) $(BUNDLE_RESOURCES)/share
 	$(CP) TeXmacs $(BUNDLE_RESOURCES)/share
 	$(RM) $(BUNDLE_TEXMACS)/bin/texmacs.bin
 	$(RM) -r $(BUNDLE_TEXMACS)/doc
-	$(CP) ../doc $(BUNDLE_TEXMACS)
+	$(CP) $(srcdir)/../doc $(BUNDLE_TEXMACS)
 	GUILE_DATA_PATH=`guile-config info pkgdatadir`; \
 	export GUILE_DATA_PATH; \
 	GUILE_LOAD_PATH=`find $$GUILE_DATA_PATH -type d | grep ice-9`; \
Index: src/makefile.in
===================================================================
--- src/makefile.in	(revision 2477)
+++ src/makefile.in	(working copy)
@@ -8,10 +8,15 @@
 
 default: all
 
-vpath %.cpp $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
-vpath %.m $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
-vpath %.mm $(shell find . -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
+srcdir = @srcdir@
+builddir = @builddir@
 
+VPATH = $(srcdir)
+
+vpath %.cpp $(shell find $(srcdir)  -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
+vpath %.m $(shell find $(srcdir) -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
+vpath %.mm $(shell find $(srcdir) -type d '!' -name Deps '!' -name Objects|tr '\n' ' ')
+
 ###############################################################################
 # Configuration variables
 ###############################################################################
@@ -77,14 +82,14 @@
 # make to find the sources files given only their file name.
 
 findsrc_in = \
-$(foreach dir,$(patsubst %,$(1)/%,$(2)),\
+$(foreach dir,$(patsubst %,$(srcdir)/$(1)/%,$(2)),\
 $(notdir $(wildcard $(dir)/*.cpp $(dir)/*/*.cpp)))
 findsrc = $(call findsrc_in,$(1),*)
 findm_in = \
-$(foreach dir,$(patsubst %,$(1)/%,$(2)),\
+$(foreach dir,$(patsubst %,$(srcdir)/$(1)/%,$(2)),\
 $(notdir $(wildcard $(dir)/*.m $(dir)/*/*.m)))
 findmm_in = \
-$(foreach dir,$(patsubst %,$(1)/%,$(2)),\
+$(foreach dir,$(patsubst %,$(srcdir)/$(1)/%,$(2)),\
 $(notdir $(wildcard $(dir)/*.mm $(dir)/*/*.mm)))
 
 kernel_src   := $(call findsrc,Kernel)
@@ -127,9 +132,9 @@
 # Include files
 ###############################################################################
 
-incl_flags = $(patsubst %,-I%,$(1))
+incl_flags = $(patsubst %,-I$(srcdir)/%,$(1))
 
-system_incl   := $(call incl_flags,System System/Boot System/Classes System/Files System/Link System/Misc System/Language Kernel/Abstractions Kernel/Containers Kernel/Types Data/Convert Data/Drd Data/Observers Data/String Data/Tmfs Data/Tree Guile Graphics/Bitmap_fonts Graphics/Fonts Graphics/Gui Graphics/Mathematics Graphics/Renderer Plugins)
+system_incl   := -ISystem $(call incl_flags,System System/Boot System/Classes System/Files System/Link System/Misc System/Language Kernel/Abstractions Kernel/Containers Kernel/Types Data/Convert Data/Drd Data/Observers Data/String Data/Tmfs Data/Tree Guile Graphics/Bitmap_fonts Graphics/Fonts Graphics/Gui Graphics/Mathematics Graphics/Renderer Plugins)
 kernel_incl   := $(system_incl)
 data_incl     := $(system_incl)
 graphics_incl := $(system_incl)
@@ -157,21 +162,21 @@
 endif
 
 qt_moc_src = $(patsubst %.hpp, moc_%.cpp,$(qt_moc))
-qt_moc_paths = $(patsubst %,./Plugins/Qt/%,$(qt_moc_src))
+qt_moc_paths = $(patsubst %,$(srcdir)/Plugins/Qt/%,$(qt_moc_src))
 
 
-$(qt_moc_paths): ./Plugins/Qt/moc_%.cpp: ./Plugins/Qt/%.hpp
+$(qt_moc_paths): $(srcdir)/Plugins/Qt/moc_%.cpp: $(srcdir)/Plugins/Qt/%.hpp
 	$(MOC) $(MOCFLAGS) $< -o $@
 
 ###############################################################################
 # Dependencies
 ###############################################################################
 
-deps_incl = $(call incl_flags,System System/Boot System/Classes System/Files System/Link System/Misc System/Language Kernel/Abstractions Kernel/Containers Kernel/Types Data/Convert Data/Drd Data/Observers Data/String Data/Tmfs Data/Tree Graphics Plugins Style/Memorizer Typeset Edit Texmacs Guile Graphics/Bitmap_fonts Graphics/Fonts Graphics/Gui Graphics/Mathematics Graphics/Renderer)
+deps_incl = -ISystem $(call incl_flags,System System/Boot System/Classes System/Files System/Link System/Misc System/Language Kernel/Abstractions Kernel/Containers Kernel/Types Data/Convert Data/Drd Data/Observers Data/String Data/Tmfs Data/Tree Graphics Plugins Style/Memorizer Typeset Edit Texmacs Guile Graphics/Bitmap_fonts Graphics/Fonts Graphics/Gui Graphics/Mathematics Graphics/Renderer)
 
 deps_flags = $(deps_incl)\
  $(CPPFLAGS) $(CXXAXEL) $(CXXCAIRO) $(CXXIMLIB2) $(CXXFREETYPE) $(CXXICONV) $(CXXGUILE) \
- -I$(tmsrc)/include $(CXXGUI)
+ -I$(srcdir)/../TeXmacs/include  $(CXXGUI)
 # we should use -I- to separate local includes from system includes, but
 # headers of guile 1.6.0 use includes in quotes with names relative to the
 # current directory, and that feature is disable by -I-.
@@ -237,11 +242,11 @@
   $(CXXGUILE) $(CPPFLAGS) $(CXXFLAGS)) 
 
 $(system_obj): Objects/%.o: %.cpp
-	$(call cxx_incl,$(system_incl) -I$(tmsrc)/include)
+	$(call cxx_incl,$(system_incl) -I$(srcdir)/../TeXmacs/include)
 $(kernel_obj): Objects/%.o: %.cpp
 	$(call cxx_incl,$(kernel_incl))
 $(data_obj): Objects/%.o: %.cpp
-	$(call cxx_incl,$(data_incl) -I$(tmsrc)/include)
+	$(call cxx_incl,$(data_incl) -I$(srcdir)/../TeXmacs/include)
 $(edit_obj): Objects/%.o: %.cpp
 	$(call cxx_incl,$(edit_incl))
 $(guile_obj): Objects/%.o: %.cpp
Index: misc/admin/admin.makefile
===================================================================
--- misc/admin/admin.makefile	(revision 2477)
+++ misc/admin/admin.makefile	(working copy)
@@ -8,7 +8,7 @@
 # in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
 ###############################################################################
 
-prefix = /usr/local
+prefix = /Users/mgubi/t/local/
 exec_prefix = ${prefix}
 includedir = ${prefix}/include
 libdir = ${exec_prefix}/lib
@@ -19,8 +19,8 @@
 tmdir = TeXmacs
 tmtgz = TeXmacs-1.0.7
 tmrpm = TeXmacs-1.0.7-1
-tmorig = /Users/vdhoeven/texmacs/src
-tmsrc = /Users/vdhoeven/texmacs/src/TeXmacs
+tmorig = /Users/mgubi/t/src
+tmsrc = /Users/mgubi/t/src/TeXmacs
 tmbin = ${exec_prefix}/libexec/TeXmacs
 tmdata = ${datarootdir}/TeXmacs
 so = so
@@ -33,6 +33,6 @@
 LN = ln -f
 CHMOD = chmod -f
 GZIP = gzip -f
-STRIP = strip
+STRIP = true
 TOUCH = touch
 TAR = tar
