Switch from using $(DIST)/bin, $(DIST)/lib, etc to using $(bindir), $(includedir). This gives us the advantage of being able to set different directories for libs & headers as needed. r=bryner
authorcls%seawood.org
Sun, 21 Jan 2001 06:37:45 +0000
changeset 1680 b33984a31d8a8c2ea458b8cb86ec05b55e56a345
parent 1678 8a27a4f4179375ff7bace6f17d5d3745498a24bc
child 1682 478ad06810749ad7e6350f5b9199bebe7260758f
push idunknown
push userunknown
push dateunknown
reviewersbryner
Switch from using $(DIST)/bin, $(DIST)/lib, etc to using $(bindir), $(includedir). This gives us the advantage of being able to set different directories for libs & headers as needed. r=bryner
Makefile
Makefile.in
config/autoconf.mk.in
config/config.mk
lib/ds/Makefile
lib/ds/Makefile.in
lib/libc/include/Makefile
lib/libc/include/Makefile.in
lib/libc/src/Makefile
lib/libc/src/Makefile.in
lib/msgc/include/Makefile
lib/msgc/include/Makefile.in
lib/msgc/src/Makefile
lib/msgc/src/Makefile.in
lib/msgc/tests/Makefile
lib/msgc/tests/Makefile.in
lib/prstreams/Makefile
lib/prstreams/Makefile.in
lib/prstreams/tests/testprstrm/Makefile
lib/prstreams/tests/testprstrm/Makefile.in
lib/tests/Makefile
lib/tests/Makefile.in
pr/include/Makefile
pr/include/Makefile.in
pr/include/md/Makefile
pr/include/md/Makefile.in
pr/include/obsolete/Makefile
pr/include/obsolete/Makefile.in
pr/include/private/Makefile
pr/include/private/Makefile.in
pr/src/Makefile
pr/src/Makefile.in
pr/src/bthreads/Makefile
pr/src/bthreads/Makefile.in
pr/src/cplus/Makefile
pr/src/cplus/Makefile.in
pr/src/cplus/tests/Makefile
pr/src/cplus/tests/Makefile.in
pr/src/io/Makefile
pr/src/io/Makefile.in
pr/src/linking/Makefile
pr/src/linking/Makefile.in
pr/src/malloc/Makefile
pr/src/malloc/Makefile.in
pr/src/md/Makefile
pr/src/md/Makefile.in
pr/src/md/beos/Makefile
pr/src/md/beos/Makefile.in
pr/src/md/os2/Makefile
pr/src/md/os2/Makefile.in
pr/src/md/unix/Makefile
pr/src/md/unix/Makefile.in
pr/src/md/windows/Makefile
pr/src/md/windows/Makefile.in
pr/src/memory/Makefile
pr/src/memory/Makefile.in
pr/src/misc/Makefile
pr/src/misc/Makefile.in
pr/src/pthreads/Makefile
pr/src/pthreads/Makefile.in
pr/src/threads/Makefile
pr/src/threads/Makefile.in
pr/src/threads/combined/Makefile
pr/src/threads/combined/Makefile.in
pr/tests/Makefile
pr/tests/Makefile.in
pr/tests/dll/Makefile
pr/tests/dll/Makefile.in
pr/tests/w16gui/Makefile
pr/tests/w16gui/Makefile.in
tools/Makefile
tools/Makefile.in
--- a/Makefile
+++ b/Makefile
@@ -50,18 +50,18 @@ include $(MOD_DEPTH)/config/rules.mk
 ifeq ($(OS_ARCH),WINNT)
 ZIP_ASCII_OPT = -ll
 endif
 
 ifdef PR_CLIENT_BUILD
 export::
 	rm -r -f $(DIST)/../public/nspr
 ifdef PR_CLIENT_BUILD_UNIX
-	rm -f $(DIST)/lib/libnspr.a
-	rm -f $(DIST)/bin/libnspr.$(DLL_SUFFIX)
+	rm -f $(libdir)/libnspr.a
+	rm -f $(bindir)/libnspr.$(DLL_SUFFIX)
 endif
 endif
 
 distclean::
 	@echo "cd pr/tests; $(MAKE) $@"
 	@$(MAKE) -C pr/tests $@
 	rm -f config/my_config.mk config/my_overrides.mk
 
--- a/Makefile.in
+++ b/Makefile.in
@@ -58,18 +58,18 @@ include $(topsrcdir)/config/rules.mk
 ifeq ($(OS_ARCH),WINNT)
 ZIP_ASCII_OPT = -ll
 endif
 
 ifdef PR_CLIENT_BUILD
 export::
 	rm -r -f $(DIST)/../public/nspr
 ifdef PR_CLIENT_BUILD_UNIX
-	rm -f $(DIST)/lib/libnspr.a
-	rm -f $(DIST)/bin/libnspr.$(DLL_SUFFIX)
+	rm -f $(libdir)/libnspr.a
+	rm -f $(bindir)/libnspr.$(DLL_SUFFIX)
 endif
 endif
 
 # Delete config/autoconf.mk last because it is included by every makefile.
 distclean::
 	@echo "cd pr/tests; $(MAKE) $@"
 	@$(MAKE) -C pr/tests $@
 	rm -f config/autoconf.mk
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -1,12 +1,19 @@
 
+INCLUDED_AUTOCONF_MK = 1
 USE_AUTOCONF	= 1
 MOZILLA_CLIENT	= @MOZILLA_CLIENT@
 DIST		= @prefix@
+prefix		= @prefix@
+exec_prefix	= @exec_prefix@
+bindir		= @bindir@
+includedir	= @includedir@
+libdir		= @libdir@
+
 OBJDIR_NAME	= @OBJDIR_NAME@
 OBJDIR		= @OBJDIR@
 OBJ_SUFFIX	= @OBJ_SUFFIX@
 LIB_SUFFIX	= @LIB_SUFFIX@
 DLL_SUFFIX	= @DLL_SUFFIX@
 MOD_VERSION	= @NSPR_VERSION@
 MOD_NAME	= @NSPR_MODNAME@
 
--- a/config/config.mk
+++ b/config/config.mk
@@ -172,16 +172,23 @@ include $(MOD_DEPTH)/config/$(OS_TARGET)
 BUILD		= $(OBJDIR_NAME)
 OBJDIR		= $(OBJDIR_NAME)
 DIST		= $(NSDEPTH)/dist/$(OBJDIR_NAME)
 ifeq ($(MOZ_BITS),16)
 MOZ_INCL	= $(NSDEPTH)/dist/public/win16
 MOZ_DIST	= $(NSDEPTH)/dist/WIN16D_D.OBJ
 endif
 
+# if not using autoconf, set these values accordingly
+prefix		= $(DIST)
+exec_prefix	= $(prefix)
+bindir		= $(prefix)/bin
+includedir	= $(prefix)/include
+libdir		= $(prefix)/lib
+
 VPATH		= $(OBJDIR)
 DEPENDENCIES	= $(OBJDIR)/.md
 
 ifdef BUILD_DEBUG_GC
 DEFINES		+= -DDEBUG_GC
 endif
 
 GARBAGE		+= $(DEPENDENCIES) core $(wildcard core.[0-9]*)
--- a/lib/ds/Makefile
+++ b/lib/ds/Makefile
@@ -39,68 +39,68 @@ include $(MOD_DEPTH)/config/config.mk
 
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include
 
 CSRCS = \
 	plarena.c \
 	plhash.c \
 	plvrsion.c \
 	$(NULL)
 
 HEADERS = \
 	plarenas.h \
 	plarena.h \
 	plhash.h \
 	$(NULL)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
 # OS_CFLAGS = $(OS_EXE_CFLAGS)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 else
 DLLBASE=/BASE:0x30000000
 RES=$(OBJDIR)/plds.res
 RESNAME=plds.rc
 OS_LIBS = user32.lib
 ifeq ($(OS_TARGET),WIN95)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
-EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
 endif
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 else
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -159,32 +159,32 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 endif
 endif
 #
 # Version information generation (end)
 #
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
--- a/lib/ds/Makefile.in
+++ b/lib/ds/Makefile.in
@@ -46,17 +46,17 @@ ifndef USE_AUTOCONF
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 endif #!USE_AUTOCONF
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include
 
 CSRCS = \
 	plarena.c \
 	plhash.c \
 	plvrsion.c \
 	$(NULL)
 
 HEADERS = \
@@ -65,52 +65,52 @@ HEADERS = \
 	plhash.h \
 	$(NULL)
 
 HEADERS := $(addprefix $(srcdir)/, $(HEADERS))
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
 # OS_CFLAGS = $(OS_EXE_CFLAGS)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 else
 DLLBASE=/BASE:0x30000000
 RES=$(OBJDIR)/plds.res
 RESNAME=plds.rc
 OS_LIBS = user32.lib
 ifeq ($(OS_TARGET),WIN95)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
-EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
 endif
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 ifndef USE_AUTOCONF
 
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -118,17 +118,17 @@ ifeq ($(OS_ARCH),NCR)
 EXTRA_LIBS =
 endif
 ifeq ($(OS_ARCH),SCOOS)
 EXTRA_LIBS =
 endif
 endif #!USE_AUTOCONF
 
 ifdef RESOLVE_LINK_SYMBOLS
-EXTRA_LIBS := -L$(DIST)/lib -lnspr$(MOD_VERSION) $(OS_LIBS)
+EXTRA_LIBS := -L$(libdir) -lnspr$(MOD_VERSION) $(OS_LIBS)
 endif
 
 LIBRARY_NAME	= plds
 LIBRARY_VERSION	= $(MOD_VERSION)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 RELEASE_LIBS	= $(TARGETS)
@@ -174,32 +174,32 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
 endif
 endif
 #
 # Version information generation (end)
 #
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
--- a/lib/libc/include/Makefile
+++ b/lib/libc/include/Makefile
@@ -39,15 +39,15 @@ include $(MOD_DEPTH)/config/config.mk
 HEADERS = $(wildcard *.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(HEADERS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
 endif
 
 install:: export
 
--- a/lib/libc/include/Makefile.in
+++ b/lib/libc/include/Makefile.in
@@ -44,15 +44,15 @@ include $(topsrcdir)/config/config.mk
 HEADERS = $(wildcard $(srcdir)/*.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(HEADERS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
 endif
 
 install:: export
 
--- a/lib/libc/src/Makefile
+++ b/lib/libc/src/Makefile
@@ -39,17 +39,17 @@ include $(MOD_DEPTH)/config/config.mk
 
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 CSRCS =\
 	plvrsion.c  \
 	strlen.c  \
 	strcpy.c  \
 	strdup.c  \
 	strcat.c  \
 	strcmp.c  \
@@ -65,50 +65,50 @@ CSRCS =\
 
 LIBRARY_NAME	= plc
 LIBRARY_VERSION	= $(MOD_VERSION)
 
 RELEASE_LIBS = $(TARGETS)
 
 ifeq ($(OS_ARCH),WINNT)
 ifeq ($(OS_TARGET), WIN16)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
 DLLBASE=/BASE:0x30000000
 RES=$(OBJDIR)/plc.res
 RESNAME=plc.rc
 ifeq ($(OS_TARGET),WIN95)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
-EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
 endif
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 else
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -160,31 +160,31 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 endif
 endif
 #
 # Version information generation (end)
 #
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
 install:: export
--- a/lib/libc/src/Makefile.in
+++ b/lib/libc/src/Makefile.in
@@ -47,17 +47,17 @@ ifndef USE_AUTOCONF
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 endif #!USE_AUTOCONF
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 CSRCS =\
 	plvrsion.c  \
 	strlen.c  \
 	strcpy.c  \
 	strdup.c  \
 	strcat.c  \
 	strcmp.c  \
@@ -73,51 +73,51 @@ CSRCS =\
 
 LIBRARY_NAME	= plc
 LIBRARY_VERSION	= $(MOD_VERSION)
 
 RELEASE_LIBS = $(TARGETS)
 
 ifeq ($(OS_ARCH),WINNT)
 ifeq ($(OS_TARGET), WIN16)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
 DLLBASE=/BASE:0x30000000
 RES=$(OBJDIR)/plc.res
 RESNAME=plc.rc
 ifeq ($(OS_TARGET),WIN95)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
 else
-EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
 endif
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 ifndef USE_AUTOCONF
 
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -125,17 +125,17 @@ ifeq ($(OS_ARCH),NCR)
 EXTRA_LIBS =
 endif
 ifeq ($(OS_ARCH),SCOOS)
 EXTRA_LIBS =
 endif
 endif #!USE_AUTOCONF
 
 ifdef RESOLVE_LINK_SYMBOLS
-EXTRA_LIBS := -L$(DIST)/lib -lnspr$(MOD_VERSION) $(OS_LIBS)
+EXTRA_LIBS := -L$(libdir) -lnspr$(MOD_VERSION) $(OS_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 #
 # Version information generation (begin)
 #
 ECHO = echo
@@ -174,31 +174,31 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
 endif
 endif
 #
 # Version information generation (end)
 #
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
 install:: export
--- a/lib/msgc/include/Makefile
+++ b/lib/msgc/include/Makefile
@@ -40,14 +40,14 @@ EXPORT_HEADERS = prgc.h
 HEADERS = $(EXPORT_HEADERS) gcint.h
 
 RELEASE_HEADERS = $(EXPORT_HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(EXPORT_HEADERS)
-	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(DIST)/include
+	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(includedir)
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(MOZ_INCL)
 endif
 
 install:: export
--- a/lib/msgc/include/Makefile.in
+++ b/lib/msgc/include/Makefile.in
@@ -45,14 +45,14 @@ EXPORT_HEADERS = prgc.h
 HEADERS = $(EXPORT_HEADERS) gcint.h
 
 RELEASE_HEADERS = $(EXPORT_HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(EXPORT_HEADERS)
-	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(DIST)/include
+	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(includedir)
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(EXPORT_HEADERS) $(MOZ_INCL)
 endif
 
 install:: export
--- a/lib/msgc/src/Makefile
+++ b/lib/msgc/src/Makefile
@@ -39,17 +39,17 @@ include $(MOD_DEPTH)/config/config.mk
 
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
-INCLUDES = -I$(DIST)/include -I../include
+INCLUDES = -I$(includedir) -I../include
 
 CSRCS = prgcapi.c prmsgc.c
 
 ifeq ($(OS_ARCH),WINNT)
 ifeq ($(OS_TARGET),WIN16)
 CSRCS += win16gc.c
 else
 CSRCS += win32gc.c
@@ -61,47 +61,47 @@ else
 CSRCS += unixgc.c
 endif
 endif
 
 NSPR_VERSION = $(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-EXTRA_LIBS = $(DIST)/lib/nspr$(NSPR_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(NSPR_VERSION).lib
 else
 DLLBASE=/BASE:0x30000000
 #RES=$(OBJDIR)/ds.res
 #RESNAME=$(MOD_DEPTH)/pr/src/nspr.rc
 #OS_LIBS = user32.lib
-EXTRA_LIBS = $(DIST)/lib/libnspr$(NSPR_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(NSPR_VERSION).lib
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 else
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(NSPR_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(NSPR_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(NSPR_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(NSPR_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(NSPR_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(NSPR_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -115,23 +115,23 @@ endif
 LIBRARY_NAME = msgc
 LIBRARY_VERSION = $(MOD_VERSION)
 
 RELEASE_LIBS = $(TARGETS)
 
 include $(MOD_DEPTH)/config/rules.mk
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif	
 
 install:: export
--- a/lib/msgc/src/Makefile.in
+++ b/lib/msgc/src/Makefile.in
@@ -44,17 +44,17 @@ include $(topsrcdir)/config/config.mk
 
 # Disable optimization of the nspr on SunOS4.1.3
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
-INCLUDES = -I$(DIST)/include -I../include
+INCLUDES = -I$(includedir) -I../include
 
 CSRCS = prgcapi.c prmsgc.c
 
 ifeq ($(OS_ARCH),WINNT)
 ifeq ($(OS_TARGET),WIN16)
 CSRCS += win16gc.c
 else
 CSRCS += win32gc.c
@@ -66,47 +66,47 @@ else
 CSRCS += unixgc.c
 endif
 endif
 
 NSPR_VERSION = $(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-EXTRA_LIBS = $(DIST)/lib/nspr$(NSPR_VERSION).lib
+EXTRA_LIBS = $(libdir)/nspr$(NSPR_VERSION).lib
 else
 DLLBASE=/BASE:0x30000000
 #RES=$(OBJDIR)/ds.res
 #RESNAME=$(MOD_DEPTH)/pr/src/nspr.rc
 #OS_LIBS = user32.lib
-EXTRA_LIBS = $(DIST)/lib/libnspr$(NSPR_VERSION).lib
+EXTRA_LIBS = $(libdir)/libnspr$(NSPR_VERSION).lib
 
 ifdef MOZ_DEBUG
 ifdef GLOWCODE
 EXTRA_LIBS += $(GLOWDIR)/glowcode.lib
 endif
 endif
 endif
 
 else
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
-EXTRA_LIBS = $(DIST)/lib/nspr$(NSPR_VERSION).$(LIB_SUFFIX)
+EXTRA_LIBS = $(libdir)/nspr$(NSPR_VERSION).$(LIB_SUFFIX)
 
 else
 ifeq ($(OS_ARCH), AIX)
 ifeq ($(CLASSIC_NSPR),1)
 OS_LIBS += -lc
 else
 OS_LIBS += -lc_r
 endif
 endif
 ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(NSPR_VERSION)_shr
+EXTRA_LIBS = -L$(libdir) -lnspr$(NSPR_VERSION)_shr
 else
-EXTRA_LIBS = -L$(DIST)/lib -lnspr$(NSPR_VERSION)
+EXTRA_LIBS = -L$(libdir) -lnspr$(NSPR_VERSION)
 endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the .o files.
@@ -120,23 +120,23 @@ endif
 LIBRARY_NAME = msgc
 LIBRARY_VERSION = $(MOD_VERSION)
 
 RELEASE_LIBS = $(TARGETS)
 
 include $(topsrcdir)/config/rules.mk
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif	
 
 install:: export
--- a/lib/msgc/tests/Makefile
+++ b/lib/msgc/tests/Makefile
@@ -53,106 +53,106 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 NSPR_VERSION = $(MOD_VERSION)
 GC_VERSION = $(MOD_VERSION)
 LIBPR = -lnspr$(NSPR_VERSION)
 LIBPLC = -lplc$(NSPR_VERSION)
 LIBGC = -lmsgc$(GC_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-  LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib
-  LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib
+  LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+  LIBPLC = $(libdir)/plc$(NSPR_VERSION).lib
+  LIBGC= $(libdir)/msgc$(GC_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
-  LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
-  LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
-  LIBGC= $(DIST)/lib/libmsgc$(GC_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
+  LIBPLC = $(libdir)/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
+  LIBGC= $(libdir)/libmsgc$(GC_VERSION).$(LIB_SUFFIX)
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
   LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-  LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-  LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib
-  LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib
+  LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+  LIBPLC = $(libdir)/plc$(NSPR_VERSION).lib
+  LIBGC= $(libdir)/msgc$(GC_VERSION).lib
 else
   LDOPTS += -Zomf -Zlinker /PM:VIO
 endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib -rdata_shared
+LDOPTS += -rpath $(PWD)/$(libdir) -rdata_shared
 
 # For 6.x machines, include this flag
 ifeq ($(basename $(OS_RELEASE)),6)
 ifeq ($(USE_N32),1)
 LDOPTS += -n32
 else
 LDOPTS += -32
 endif
 endif
 
 endif
 
 ifeq ($(OS_ARCH), OSF1)
 # I haven't figured out how to pass -rpath to cc on OSF1 V3.2, so
 # we do static linking.
 ifeq ($(OS_RELEASE), V3.2)
-  LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).a
-  LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).a
-  LIBGC = $(DIST)/lib/libmsgc$(GC_VERSION).a
+  LIBPR = $(libdir)/libnspr$(NSPR_VERSION).a
+  LIBPLC = $(libdir)/libplc$(NSPR_VERSION).a
+  LIBGC = $(libdir)/libmsgc$(GC_VERSION).a
   EXTRA_LIBS = -lc_r
 else
-  LDOPTS += -rpath $(PWD)/$(DIST)/lib
+  LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -z -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -z -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
 LIBPR = -lnspr$(NSPR_VERSION)_shr
 LIBPLC = -lplc$(NSPR_VERSION)_shr
 LIBGC = -lmsgc$(GC_VERSION)_shr
 else
 LDOPTS += -brtl
 EXTRA_LIBS = -ldl
 endif
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 endif
 endif
 
 ifneq ($(LOCAL_THREADS_ONLY),1)
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
 ifeq ($(OS_RELEASE), 5.4)
@@ -169,64 +169,64 @@ endif
 endif # LOCAL_THREADS_ONLY
 endif # SunOS
 
 ifeq ($(OS_ARCH),NEC)
 EXTRA_LIBS = $(OS_LIBS)
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).a
-LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).a
-LIBGC = $(DIST)/lib/libmsgc$(GC_VERSION).a
+LIBPR = $(libdir)/libnspr$(NSPR_VERSION).a
+LIBPLC = $(libdir)/libplc$(NSPR_VERSION).a
+LIBGC = $(libdir)/libmsgc$(GC_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), Linux)
 ifeq ($(OS_RELEASE), 1.2)
 EXTRA_LIBS = -ldl
 endif
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH),SINIX)
 EXTRA_LIBS = -lsocket -lnsl -lresolv -ldl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH),BSD_OS)
 EXTRA_LIBS = -ldl
 endif
 
 ifeq ($(OS_ARCH),DGUX)
 EXTRA_LIBS = -lsocket -lnsl -ldl
@@ -257,17 +257,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(NSPR_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(NSPR_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/lib/msgc/tests/Makefile.in
+++ b/lib/msgc/tests/Makefile.in
@@ -58,106 +58,106 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 NSPR_VERSION = $(MOD_VERSION)
 GC_VERSION = $(MOD_VERSION)
 LIBPR = -lnspr$(NSPR_VERSION)
 LIBPLC = -lplc$(NSPR_VERSION)
 LIBGC = -lmsgc$(GC_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-  LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib
-  LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib
+  LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+  LIBPLC = $(libdir)/plc$(NSPR_VERSION).lib
+  LIBGC= $(libdir)/msgc$(GC_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
-  LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
-  LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
-  LIBGC= $(DIST)/lib/libmsgc$(GC_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
+  LIBPLC = $(libdir)/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
+  LIBGC= $(libdir)/libmsgc$(GC_VERSION).$(LIB_SUFFIX)
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
   LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-  LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-  LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib
-  LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib
+  LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+  LIBPLC = $(libdir)/plc$(NSPR_VERSION).lib
+  LIBGC= $(libdir)/msgc$(GC_VERSION).lib
 else
   LDOPTS += -Zomf -Zlinker /PM:VIO
 endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib -rdata_shared
+LDOPTS += -rpath $(PWD)/$(libdir) -rdata_shared
 
 # For 6.x machines, include this flag
 ifeq ($(basename $(OS_RELEASE)),6)
 ifeq ($(USE_N32),1)
 LDOPTS += -n32
 else
 LDOPTS += -32
 endif
 endif
 
 endif
 
 ifeq ($(OS_ARCH), OSF1)
 # I haven't figured out how to pass -rpath to cc on OSF1 V3.2, so
 # we do static linking.
 ifeq ($(OS_RELEASE), V3.2)
-  LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).a
-  LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).a
-  LIBGC = $(DIST)/lib/libmsgc$(GC_VERSION).a
+  LIBPR = $(libdir)/libnspr$(NSPR_VERSION).a
+  LIBPLC = $(libdir)/libplc$(NSPR_VERSION).a
+  LIBGC = $(libdir)/libmsgc$(GC_VERSION).a
   EXTRA_LIBS = -lc_r
 else
-  LDOPTS += -rpath $(PWD)/$(DIST)/lib
+  LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -z -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -z -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
 LIBPR = -lnspr$(NSPR_VERSION)_shr
 LIBPLC = -lplc$(NSPR_VERSION)_shr
 LIBGC = -lmsgc$(GC_VERSION)_shr
 else
 LDOPTS += -brtl
 EXTRA_LIBS = -ldl
 endif
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 endif
 endif
 
 ifneq ($(LOCAL_THREADS_ONLY),1)
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
 ifeq ($(OS_RELEASE), 5.4)
@@ -174,64 +174,64 @@ endif
 endif # LOCAL_THREADS_ONLY
 endif # SunOS
 
 ifeq ($(OS_ARCH),NEC)
 EXTRA_LIBS = $(OS_LIBS)
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).a
-LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).a
-LIBGC = $(DIST)/lib/libmsgc$(GC_VERSION).a
+LIBPR = $(libdir)/libnspr$(NSPR_VERSION).a
+LIBPLC = $(libdir)/libplc$(NSPR_VERSION).a
+LIBGC = $(libdir)/libmsgc$(GC_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), Linux)
 ifeq ($(OS_RELEASE), 1.2)
 EXTRA_LIBS = -ldl
 endif
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH),SINIX)
 EXTRA_LIBS = -lsocket -lnsl -lresolv -ldl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH),BSD_OS)
 EXTRA_LIBS = -ldl
 endif
 
 ifeq ($(OS_ARCH),DGUX)
 EXTRA_LIBS = -lsocket -lnsl -ldl
@@ -262,17 +262,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(NSPR_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(NSPR_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/lib/prstreams/Makefile
+++ b/lib/prstreams/Makefile
@@ -59,50 +59,50 @@ ifeq ($(OS_ARCH), IRIX)
         CCC_ONLY_FLAGS += -exceptions
     endif
 endif
 
 ifeq ($(OS_ARCH), BeOS)
     CFLAGS += -frtti -fexceptions
 endif
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 HEADERS = $(wildcard *.h)
 
 CSRCS = \
 	plvrsion.c \
 	$(NULL)
 
 CXXSRCS = \
 	prstrms.cpp \
 	$(NULL)
 
 OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)) $(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))
 
 ifeq ($(OS_ARCH), WINNT)
     ifeq ($(OS_TARGET), WIN16)
-        EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+        EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
     else
         DLLBASE=/BASE:0x30000000
         RES=$(OBJDIR)/prstrms.res
         RESNAME=prstrms.rc
         OS_LIBS = user32.lib
         ifeq ($(OS_TARGET), WIN95)
-            EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+            EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
         else
-            EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+            EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
         endif
     endif
 else
     ifeq ($(OS_ARCH),OS2)
       ifeq ($(MOZ_OS2_TOOLS),VACPP)
-         EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+         EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
       else
-         EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) -lstdcpp
+         EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION) -lstdcpp
       endif
     else
     ifeq ($(OS_ARCH), AIX)
       ifeq ($(OS_RELEASE), 4.1)
         ifeq ($(CLASSIC_NSPR),1)
             OS_LIBS += -lC -lc
         else
             OS_LIBS += -lC_r -lc_r
@@ -114,35 +114,35 @@ else
             MKSHLIB = makeC++SharedLib -p 0
         else
             MKSHLIB = makeC++SharedLib_r -p 0
         endif
         OS_LIBS += -ldl
       endif
     endif
     ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-        EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+        EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
     else
-        EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+        EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
     endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the object files.
 ifeq ($(OS_ARCH),NCR)
     EXTRA_LIBS =
 endif
 ifeq ($(OS_ARCH),SCOOS)
     EXTRA_LIBS =
 endif
 ifeq ($(OS_ARCH),BeOS)
-    EXTRA_LIBS = -lstdc++.r4 -L$(DIST)/lib -lnspr$(MOD_VERSION)
+    EXTRA_LIBS = -lstdc++.r4 -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
     OS_LIBS += -lC
 endif
 
 LIBRARY_NAME    = prstrms
 LIBRARY_VERSION = $(MOD_VERSION)
@@ -190,26 +190,26 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 endif
 endif
 #
 # Version information generation (end)
 #
 
 export:: $(TARGETS) $(HEADERS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifeq ($(OS_ARCH),OS2)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/bin
+	$(INSTALL) -m 444 $(TARGETS) $(bindir)
 endif
 ifeq ($(OS_ARCH),HP-UX)
 ifdef SHARED_LIBRARY
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
 endif
 endif
 ifeq ($(OS_ARCH),OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(libdir)
 ifdef SHARED_LIBRARY
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 
 install:: export
--- a/lib/prstreams/Makefile.in
+++ b/lib/prstreams/Makefile.in
@@ -66,51 +66,51 @@ ifeq ($(OS_ARCH), IRIX)
     endif
 endif
 
 ifeq ($(OS_ARCH), BeOS)
     CFLAGS += -frtti -fexceptions
 endif
 endif # !USE_AUTOCONF
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 HEADERS = $(wildcard $(srcdir)/*.h)
 
 CSRCS = \
 	plvrsion.c \
 	$(NULL)
 
 CXXSRCS = \
 	prstrms.cpp \
 	$(NULL)
 
 OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)) $(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))
 
 ifndef USE_AUTOCONF
 ifeq ($(OS_ARCH), WINNT)
     ifeq ($(OS_TARGET), WIN16)
-        EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+        EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
     else
         DLLBASE=/BASE:0x30000000
         RES=$(OBJDIR)/prstrms.res
         RESNAME=prstrms.rc
         OS_LIBS = user32.lib
         ifeq ($(OS_TARGET), WIN95)
-            EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib
+            EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).lib
         else
-            EXTRA_LIBS = $(DIST)/lib/libnspr$(MOD_VERSION).lib
+            EXTRA_LIBS = $(libdir)/libnspr$(MOD_VERSION).lib
         endif
     endif
 else
     ifeq ($(OS_ARCH),OS2)
       ifeq ($(MOZ_OS2_TOOLS),VACPP)
-         EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+         EXTRA_LIBS = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
       else
-         EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) -lstdcpp
+         EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION) -lstdcpp
       endif
     else
     ifeq ($(OS_ARCH), AIX)
       ifeq ($(OS_RELEASE), 4.1)
         ifeq ($(CLASSIC_NSPR),1)
             OS_LIBS += -lC -lc
         else
             OS_LIBS += -lC_r -lc_r
@@ -122,44 +122,44 @@ else
             MKSHLIB = makeC++SharedLib -p 0
         else
             MKSHLIB = makeC++SharedLib_r -p 0
         endif
         OS_LIBS += -ldl
       endif
     endif
     ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
-        EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)_shr
+        EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)_shr
     else
-        EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION)
+        EXTRA_LIBS = -L$(libdir) -lnspr$(MOD_VERSION)
     endif
 endif
 endif
 
 # On NCR and SCOOS, we can't link with extra libraries when
 # we build a shared library.  If we do so, the linker doesn't
 # complain, but we would run into weird problems at run-time.
 # Therefore on these platforms, we link just the object files.
 ifeq ($(OS_ARCH),NCR)
     EXTRA_LIBS =
 endif
 ifeq ($(OS_ARCH),SCOOS)
     EXTRA_LIBS =
 endif
 ifeq ($(OS_ARCH),BeOS)
-    EXTRA_LIBS = -lstdc++.r4 -L$(DIST)/lib -lnspr$(MOD_VERSION)
+    EXTRA_LIBS = -lstdc++.r4 -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
     OS_LIBS += -lC
 endif
 endif # !USE_AUTOCONF
 
 ifdef RESOLVE_LINK_SYMBOLS
-EXTRA_LIBS := -L$(DIST)/lib -lnspr$(MOD_VERSION)
+EXTRA_LIBS := -L$(libdir) -lnspr$(MOD_VERSION)
 endif
 
 LIBRARY_NAME    = prstrms
 LIBRARY_VERSION = $(MOD_VERSION)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 RELEASE_LIBS    = $(TARGETS)
@@ -203,26 +203,26 @@ else
 	$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c
 endif
 endif
 #
 # Version information generation (end)
 #
 
 export:: $(TARGETS) $(HEADERS)
-	$(INSTALL) -m 444 $(HEADERS) $(DIST)/include
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(HEADERS) $(includedir)
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifeq ($(OS_ARCH),OS2)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/bin
+	$(INSTALL) -m 444 $(TARGETS) $(bindir)
 endif
 ifeq ($(OS_ARCH),HP-UX)
 ifdef SHARED_LIBRARY
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
 endif
 endif
 ifeq ($(OS_ARCH),OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(libdir)
 ifdef SHARED_LIBRARY
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 
 install:: export
--- a/lib/prstreams/tests/testprstrm/Makefile
+++ b/lib/prstreams/tests/testprstrm/Makefile
@@ -52,127 +52,127 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPRSTRMS = -lprstrms$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPRSTRMS = $(libdir)/prstrms$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifeq ($(OS_TARGET), WIN95)
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPRSTRMS = $(libdir)/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
   else
-    LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPRSTRMS = $(DIST)/lib/libprstrms$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPRSTRMS = $(libdir)/libprstrms$(MOD_VERSION).$(LIB_SUFFIX)
   endif
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO /S:32768
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-    LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+    LIBPRSTRMS = $(libdir)/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
 LIBPR = -lnspr$(MOD_VERSION)_shr
 LIBPRSTRMS = -lprstrms$(MOD_VERSION)_shr
 else
 LDOPTS += -brtl
 EXTRA_LIBS = -ldl
 endif
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 # CC on SunOS 5.4 and 5.5.x need to link with -lthread or -lpthread
 # (or use the -mt switch) even though we already linked with these
 # system libraries when we built libnspr.so.
 ifdef USE_PTHREADS
 EXTRA_LIBS = -lpthread
 else
 EXTRA_LIBS = -lthread
 endif # USE_PTHREADS
 endif # NS_USE_GCC
 endif # 4.1.3_U1
 endif # SunOS
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-LIBPRSTRMS = $(DIST)/lib/libprstrms$(MOD_VERSION).a
+LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+LIBPRSTRMS = $(libdir)/libprstrms$(MOD_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -195,17 +195,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/lib/prstreams/tests/testprstrm/Makefile.in
+++ b/lib/prstreams/tests/testprstrm/Makefile.in
@@ -57,127 +57,127 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPRSTRMS = -lprstrms$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPRSTRMS = $(libdir)/prstrms$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifeq ($(OS_TARGET), WIN95)
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPRSTRMS = $(libdir)/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
   else
-    LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPRSTRMS = $(DIST)/lib/libprstrms$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPRSTRMS = $(libdir)/libprstrms$(MOD_VERSION).$(LIB_SUFFIX)
   endif
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO /S:32768
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-    LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+    LIBPRSTRMS = $(libdir)/prstrms$(MOD_VERSION).$(LIB_SUFFIX)
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
 LIBPR = -lnspr$(MOD_VERSION)_shr
 LIBPRSTRMS = -lprstrms$(MOD_VERSION)_shr
 else
 LDOPTS += -brtl
 EXTRA_LIBS = -ldl
 endif
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 # CC on SunOS 5.4 and 5.5.x need to link with -lthread or -lpthread
 # (or use the -mt switch) even though we already linked with these
 # system libraries when we built libnspr.so.
 ifdef USE_PTHREADS
 EXTRA_LIBS = -lpthread
 else
 EXTRA_LIBS = -lthread
 endif # USE_PTHREADS
 endif # NS_USE_GCC
 endif # 4.1.3_U1
 endif # SunOS
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-LIBPRSTRMS = $(DIST)/lib/libprstrms$(MOD_VERSION).a
+LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+LIBPRSTRMS = $(libdir)/libprstrms$(MOD_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -200,17 +200,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/lib/tests/Makefile
+++ b/lib/tests/Makefile
@@ -58,96 +58,96 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPLC = -lplc$(MOD_VERSION)
 LIBPLDS = -lplds$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).lib
-  LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPLC= $(libdir)/plc$(MOD_VERSION).lib
+  LIBPLDS= $(libdir)/plds$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifeq ($(OS_TARGET), WIN95)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLC= $(libdir)/plc$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLDS= $(libdir)/plds$(MOD_VERSION).$(LIB_SUFFIX)
   else
-  LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLC= $(DIST)/lib/libplc$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLDS= $(DIST)/lib/libplds$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLC= $(libdir)/libplc$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLDS= $(libdir)/libplds$(MOD_VERSION).$(LIB_SUFFIX)
   endif
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO /S:32768
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-    LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib
-    LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).$(LIB_SUFFIX)	
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+    LIBPLC = $(libdir)/plc$(MOD_VERSION).lib
+    LIBPLDS= $(libdir)/plds$(MOD_VERSION).$(LIB_SUFFIX)	
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), Linux)
     ifeq ($(OS_RELEASE), 1.2)
         EXTRA_LIBS = -ldl
     else
-        LDOPTS += -Xlinker -rpath $(PWD)/$(DIST)/lib
+        LDOPTS += -Xlinker -rpath $(PWD)/$(libdir)
         ifeq ($(USE_PTHREADS),1)
             EXTRA_LIBS = -lpthread
         endif
     endif
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib -lpthread
+LDOPTS += -rpath $(PWD)/$(libdir) -lpthread
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 LIBPR = -lnspr$(MOD_VERSION)_shr
 LIBPLC = -lplc$(MOD_VERSION)_shr
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 endif
 endif
 
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
 ifeq ($(OS_RELEASE), 5.4)
 EXTRA_LIBS = -lthread
@@ -165,17 +165,17 @@ endif # SunOS
 ifeq ($(OS_ARCH), NCR)
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -198,17 +198,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/lib/tests/Makefile.in
+++ b/lib/tests/Makefile.in
@@ -63,96 +63,96 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPLC = -lplc$(MOD_VERSION)
 LIBPLDS = -lplds$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).lib
-  LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPLC= $(libdir)/plc$(MOD_VERSION).lib
+  LIBPLDS= $(libdir)/plds$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifeq ($(OS_TARGET), WIN95)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLC= $(libdir)/plc$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLDS= $(libdir)/plds$(MOD_VERSION).$(LIB_SUFFIX)
   else
-  LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLC= $(DIST)/lib/libplc$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPLDS= $(DIST)/lib/libplds$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLC= $(libdir)/libplc$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPLDS= $(libdir)/libplds$(MOD_VERSION).$(LIB_SUFFIX)
   endif
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO /S:32768
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-    LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib
-    LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).$(LIB_SUFFIX)	
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+    LIBPLC = $(libdir)/plc$(MOD_VERSION).lib
+    LIBPLDS= $(libdir)/plds$(MOD_VERSION).$(LIB_SUFFIX)	
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), Linux)
     ifeq ($(OS_RELEASE), 1.2)
         EXTRA_LIBS = -ldl
     else
-        LDOPTS += -Xlinker -rpath $(PWD)/$(DIST)/lib
+        LDOPTS += -Xlinker -rpath $(PWD)/$(libdir)
         ifeq ($(USE_PTHREADS),1)
             EXTRA_LIBS = -lpthread
         endif
     endif
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib -lpthread
+LDOPTS += -rpath $(PWD)/$(libdir) -lpthread
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 LIBPR = -lnspr$(MOD_VERSION)_shr
 LIBPLC = -lplc$(MOD_VERSION)_shr
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 endif
 endif
 
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
 ifeq ($(OS_RELEASE), 5.4)
 EXTRA_LIBS = -lthread
@@ -170,17 +170,17 @@ endif # SunOS
 ifeq ($(OS_ARCH), NCR)
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -203,17 +203,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/pr/include/Makefile
+++ b/pr/include/Makefile
@@ -43,12 +43,12 @@ include $(MOD_DEPTH)/config/config.mk
 HEADERS = $(wildcard *.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(RELEASE_HEADERS)
-	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(DIST)/include
+	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(includedir)
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(MOZ_INCL)
 endif
--- a/pr/include/Makefile.in
+++ b/pr/include/Makefile.in
@@ -47,12 +47,12 @@ include $(topsrcdir)/config/config.mk
 HEADERS = $(wildcard $(srcdir)/*.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(RELEASE_HEADERS)
-	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(DIST)/include
+	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(includedir)
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(MOZ_INCL)
 endif
--- a/pr/include/md/Makefile
+++ b/pr/include/md/Makefile
@@ -171,29 +171,29 @@ ifeq ($(OS_TARGET),NTO)
 MDCPUCFG_H = _nto.cfg
 endif
 
 ifeq ($(OS_ARCH),BeOS)
 MDCPUCFG_H = _beos.cfg
 endif
 
 export:: $(MDCPUCFG_H)
-	$(INSTALL) -m 444 $(MDCPUCFG_H) $(DIST)/include
+	$(INSTALL) -m 444 $(MDCPUCFG_H) $(includedir)
 ifeq ($(MOZ_BITS),16)
-	cp $(DIST)/include/$(MDCPUCFG_H) $(DIST)/include/prcpucfg.h
+	cp $(includedir)/$(MDCPUCFG_H) $(includedir)/prcpucfg.h
 	$(INSTALL) -m 444 $(MDCPUCFG_H) $(MOZ_INCL)
-	mv -f $(DIST)/include/$(MDCPUCFG_H) $(MOZ_INCL)/prcpucfg.h
+	mv -f $(includedir)/$(MDCPUCFG_H) $(MOZ_INCL)/prcpucfg.h
 else
 ifneq ($(OS_ARCH),OpenVMS)
-	mv -f $(DIST)/include/$(MDCPUCFG_H) $(DIST)/include/prcpucfg.h
+	mv -f $(includedir)/$(MDCPUCFG_H) $(includedir)/prcpucfg.h
 else
 # mv'ing a link causes the file itself to move, not the link.
-	rm -f $(DIST)/include/$(MDCPUCFG_H)
-	rm -f $(DIST)/include/prcpucfg.h
-	ln -fs `pwd`/$(MDCPUCFG_H) $(DIST)/include/prcpucfg.h
+	rm -f $(includedir)/$(MDCPUCFG_H)
+	rm -f $(includedir)/prcpucfg.h
+	ln -fs `pwd`/$(MDCPUCFG_H) $(includedir)/prcpucfg.h
 endif
 endif
 
 release:: export
 	@echo "Copying machine-dependent prcpucfg.h"
 	@if test -z "$(BUILD_NUMBER)"; then \
 		echo "BUILD_NUMBER must be defined"; \
 		false; \
--- a/pr/include/md/Makefile.in
+++ b/pr/include/md/Makefile.in
@@ -183,29 +183,29 @@ endif
 ifeq ($(OS_ARCH),BeOS)
 MDCPUCFG_H = _beos.cfg
 endif
 
 endif # ! USE_AUTOCONF
 
 export:: $(MDCPUCFG_H)
 ifeq ($(MOZ_BITS),16)
-	cp $(DIST)/include/$(MDCPUCFG_H) $(DIST)/include/prcpucfg.h
+	cp $(includedir)/$(MDCPUCFG_H) $(includedir)/prcpucfg.h
 	$(INSTALL) -m 444 $(MDCPUCFG_H) $(MOZ_INCL)
-	mv -f $(DIST)/include/$(MDCPUCFG_H) $(MOZ_INCL)/prcpucfg.h
+	mv -f $(includedir)/$(MDCPUCFG_H) $(MOZ_INCL)/prcpucfg.h
 else
-	$(INSTALL) -m 444 $(CONFIGS) $(DIST)/include/md
-	$(INSTALL) -m 444 $(srcdir)/$(MDCPUCFG_H) $(DIST)/include
+	$(INSTALL) -m 444 $(CONFIGS) $(includedir)/md
+	$(INSTALL) -m 444 $(srcdir)/$(MDCPUCFG_H) $(includedir)
 ifneq ($(OS_ARCH),OpenVMS)
-	mv -f $(DIST)/include/$(MDCPUCFG_H) $(DIST)/include/prcpucfg.h
+	mv -f $(includedir)/$(MDCPUCFG_H) $(includedir)/prcpucfg.h
 else
 # mv'ing a link causes the file itself to move, not the link.
-	rm -f $(DIST)/include/$(MDCPUCFG_H)
-	rm -f $(DIST)/include/prcpucfg.h
-	ln -fs `pwd`/$(MDCPUCFG_H) $(DIST)/include/prcpucfg.h
+	rm -f $(includedir)/$(MDCPUCFG_H)
+	rm -f $(includedir)/prcpucfg.h
+	ln -fs `pwd`/$(MDCPUCFG_H) $(includedir)/prcpucfg.h
 endif
 endif
 
 release:: export
 	@echo "Copying machine-dependent prcpucfg.h"
 	@if test -z "$(BUILD_NUMBER)"; then \
 		echo "BUILD_NUMBER must be defined"; \
 		false; \
--- a/pr/include/obsolete/Makefile
+++ b/pr/include/obsolete/Makefile
@@ -41,12 +41,12 @@ include $(MOD_DEPTH)/config/config.mk
 HEADERS = $(wildcard *.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/obsolete
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(RELEASE_HEADERS)
-	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(DIST)/include/obsolete
+	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(includedir)/obsolete
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(MOZ_INCL)/obsolete
 endif
--- a/pr/include/obsolete/Makefile.in
+++ b/pr/include/obsolete/Makefile.in
@@ -46,12 +46,12 @@ include $(topsrcdir)/config/config.mk
 HEADERS = $(wildcard $(srcdir)/*.h)
 
 RELEASE_HEADERS = $(HEADERS)
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/obsolete
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(RELEASE_HEADERS)
-	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(DIST)/include/obsolete
+	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(includedir)/obsolete
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(MOZ_INCL)/obsolete
 endif
--- a/pr/include/private/Makefile
+++ b/pr/include/private/Makefile
@@ -40,12 +40,12 @@ include $(MOD_DEPTH)/config/config.mk
 RELEASE_HEADERS = pprio.h pprthred.h prpriv.h
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/private
 
 HEADERS = $(RELEASE_HEADERS) pprmwait.h primpl.h
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(RELEASE_HEADERS)
-	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(DIST)/include/private
+	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(includedir)/private
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(MOZ_INCL)/private
 endif
--- a/pr/include/private/Makefile.in
+++ b/pr/include/private/Makefile.in
@@ -47,12 +47,12 @@ RELEASE_HEADERS = pprio.h pprthred.h prp
 RELEASE_HEADERS := $(addprefix $(srcdir)/, $(RELEASE_HEADERS))
 RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/private
 
 HEADERS = $(RELEASE_HEADERS) $(srcdir)/pprmwait.h $(srcdir)/primpl.h
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(RELEASE_HEADERS)
-	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(DIST)/include/private
+	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(includedir)/private
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(RELEASE_HEADERS) $(MOZ_INCL)/private
 endif
--- a/pr/src/Makefile
+++ b/pr/src/Makefile
@@ -157,17 +157,17 @@ endif
 
 ifeq ($(OS_ARCH),WINNT)
 ifneq ($(OS_TARGET),WIN16)
 OS_LIBS		= advapi32.lib wsock32.lib
 endif
 endif
 
 ifdef GC_LEAK_DETECTOR
-OS_LIBS		+= -L$(DIST)/lib -lboehm
+OS_LIBS		+= -L$(libdir) -lboehm
 endif
 
 #
 # Define platform-dependent OBJS
 #
 
 OBJS = \
     $(OBJDIR)/prvrsion.$(OBJ_SUFFIX) \
@@ -372,17 +372,17 @@ ifeq ($(BUILD_AIX_RTL_LIBC),1)
 TARGETS		+= $(AIX_RTL_LIBC)
 # XXX is this a shared library?
 endif
 
 #
 # Version information generation (begin)
 #
 ECHO = echo
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 TINC = $(OBJDIR)/_pr_bld.h
 
 ifeq ($(OS_TARGET),OS2)
 PROD = nspr$(MOD_VERSION).$(DLL_SUFFIX)
 else
 PROD = $(notdir $(SHARED_LIBRARY))
 endif
 
@@ -422,31 +422,31 @@ else
 endif
 endif
 #
 # Version information generation (end)
 #
 
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir),
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
 ifeq ($(BUILD_AIX_RTL_LIBC),1)
--- a/pr/src/Makefile.in
+++ b/pr/src/Makefile.in
@@ -158,17 +158,17 @@ ifeq ($(OS_ARCH),UNIXWARE)
 OS_LIBS		= -lsocket -lc
 endif
 
 ifeq ($(OS_ARCH),NEWS-OS)
 OS_LIBS		= -lsocket -lnsl -lgen -lresolv
 endif
 
 ifdef GC_LEAK_DETECTOR
-OS_LIBS		+= -L$(DIST)/lib -lboehm
+OS_LIBS		+= -L$(libdir) -lboehm
 endif
 
 endif # USE_AUTOCONF
 
 ifeq ($(OS_ARCH),WINNT)
 ifneq ($(OS_TARGET),WIN16)
 OS_LIBS		= advapi32.lib wsock32.lib
 endif
@@ -393,17 +393,17 @@ ifeq ($(BUILD_AIX_RTL_LIBC),1)
 TARGETS		+= $(AIX_RTL_LIBC)
 # XXX is this a shared library?
 endif
 
 #
 # Version information generation (begin)
 #
 ECHO = echo
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 TINC = $(OBJDIR)/_pr_bld.h
 
 ifeq ($(OS_TARGET),OS2)
 PROD = nspr$(MOD_VERSION).$(DLL_SUFFIX)
 else
 PROD = $(notdir $(SHARED_LIBRARY))
 endif
 
@@ -443,31 +443,31 @@ else
 endif
 endif
 #
 # Version information generation (end)
 #
 
 
 #
-# The Client build wants the shared libraries in $(DIST)/bin,
+# The Client build wants the shared libraries in $(bindir)
 # so we also install them there.
 #
 
 export:: $(TARGETS)
-	$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
+	$(INSTALL) -m 444 $(TARGETS) $(libdir)
 ifdef SHARED_LIBRARY
 ifeq ($(OS_ARCH),HP-UX)
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib
-	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(libdir)
+	$(INSTALL) -m 755 $(SHARED_LIBRARY) $(bindir)
 else
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(bindir)
 endif
 ifeq ($(OS_ARCH), OpenVMS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY:.$(DLL_SUFFIX)=.vms) $(libdir)
 endif
 endif
 ifeq ($(MOZ_BITS),16)
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
 	$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
 endif
 
 ifeq ($(BUILD_AIX_RTL_LIBC),1)
--- a/pr/src/bthreads/Makefile
+++ b/pr/src/bthreads/Makefile
@@ -38,17 +38,17 @@ MOD_DEPTH = ../../..
 
 include $(MOD_DEPTH)/config/config.mk
 
 include bsrcs.mk
 CSRCS += $(BTCSRCS)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 include $(MOD_DEPTH)/config/rules.mk
 
 DEFINES     += -D_NSPR_BUILD_
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/bthreads/Makefile.in
+++ b/pr/src/bthreads/Makefile.in
@@ -43,17 +43,17 @@ include $(MOD_DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/config.mk
 
 include $(srcdir)/bsrcs.mk
 CSRCS += $(BTCSRCS)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES		+= -D_NSPR_BUILD_
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/cplus/Makefile
+++ b/pr/src/cplus/Makefile
@@ -50,17 +50,17 @@ CXXSRCS =           \
 	rcthread.cpp	\
 	rctime.cpp      \
 	$(NULL)
 
 OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 HEADERS = $(wildcard *.h)
 
 export:: $(TARGETS)
--- a/pr/src/cplus/Makefile.in
+++ b/pr/src/cplus/Makefile.in
@@ -54,17 +54,17 @@ CXXSRCS =           \
 	rcthread.cpp	\
 	rctime.cpp      \
 	$(NULL)
 
 OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX)))
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES	+= -D_NSPR_BUILD_
 
 HEADERS = $(srcdir)/*.h
 
 export:: $(TARGETS)
--- a/pr/src/cplus/tests/Makefile
+++ b/pr/src/cplus/tests/Makefile
@@ -59,26 +59,26 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I.. -I$(DIST)/include
+INCLUDES = -I.. -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPL = -lplc$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), IRIX)
-    LDOPTS += -rpath $(PWD)/$(DIST)/lib -rdata_shared
+    LDOPTS += -rpath $(PWD)/$(libdir) -rdata_shared
     # For 6.x machines, include this flag
     ifeq ($(basename $(OS_RELEASE)),6)
         ifeq ($(USE_N32),1)
             LDOPTS += -n32
         else
             LDOPTS += -32
         endif
 
@@ -89,19 +89,19 @@ ifeq ($(OS_ARCH), IRIX)
         endif
     endif
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
     ifneq ($(OS_RELEASE), 4.1.3_U1)
         ifdef NS_USE_GCC
-            LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+            LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
         else
-            LDOPTS += -R $(PWD)/$(DIST)/lib
+            LDOPTS += -R $(PWD)/$(libdir)
         endif
     endif
 
     ifneq ($(LOCAL_THREADS_ONLY),1)
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
         ifeq ($(OS_RELEASE), 5.4)
@@ -115,100 +115,100 @@ ifeq ($(OS_ARCH), SunOS)
                 EXTRA_LIBS = -lthread
             endif
         endif
     endif # LOCAL_THREADS_ONLY
 endif # SunOS
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPL = $(DIST)/lib/plc$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPL = $(libdir)/plc$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
-  LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPL = $(DIST)/lib/libplc$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPL = $(libdir)/libplc$(MOD_VERSION).$(LIB_SUFFIX)
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-    LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+    LIBPLC = $(libdir)/plc$(MOD_VERSION).lib
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-    LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+    LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-    LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+    LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
     ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
         LIBPR = -lnspr$(MOD_VERSION)_shr
         LIBPLC = -lplc$(MOD_VERSION)_shr
     else
         LDOPTS += -brtl
         EXTRA_LIBS = -ldl
     endif
 endif
 
 ifeq ($(OS_ARCH), Linux)
     ifeq ($(OS_RELEASE), 1.2)
         EXTRA_LIBS = -ldl
     else
-        LDOPTS += -Xlinker -rpath $(PWD)/$(DIST)/lib
+        LDOPTS += -Xlinker -rpath $(PWD)/$(libdir)
         ifeq ($(USE_PTHREADS),1)
             EXTRA_LIBS = -lpthread
         endif
     endif
 endif
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-LIBPL = $(DIST)/lib/libplc$(MOD_VERSION).a
+LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+LIBPL = $(libdir)/libplc$(MOD_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), SCO_SV)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -231,17 +231,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/pr/src/cplus/tests/Makefile.in
+++ b/pr/src/cplus/tests/Makefile.in
@@ -64,26 +64,26 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CXXSRCS:.cpp=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS) $(OBJS)
 
-INCLUDES = -I.. -I$(DIST)/include
+INCLUDES = -I.. -I$(includedir)
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPL = -lplc$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), IRIX)
-    LDOPTS += -rpath $(PWD)/$(DIST)/lib -rdata_shared
+    LDOPTS += -rpath $(PWD)/$(libdir) -rdata_shared
     # For 6.x machines, include this flag
     ifeq ($(basename $(OS_RELEASE)),6)
         ifeq ($(USE_N32),1)
             LDOPTS += -n32
         else
             LDOPTS += -32
         endif
 
@@ -94,19 +94,19 @@ ifeq ($(OS_ARCH), IRIX)
         endif
     endif
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
     ifneq ($(OS_RELEASE), 4.1.3_U1)
         ifdef NS_USE_GCC
-            LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+            LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
         else
-            LDOPTS += -R $(PWD)/$(DIST)/lib
+            LDOPTS += -R $(PWD)/$(libdir)
         endif
     endif
 
     ifneq ($(LOCAL_THREADS_ONLY),1)
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
         ifeq ($(OS_RELEASE), 5.4)
@@ -120,100 +120,100 @@ ifeq ($(OS_ARCH), SunOS)
                 EXTRA_LIBS = -lthread
             endif
         endif
     endif # LOCAL_THREADS_ONLY
 endif # SunOS
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPL = $(DIST)/lib/plc$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPL = $(libdir)/plc$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
-  LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-  LIBPL = $(DIST)/lib/libplc$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+  LIBPL = $(libdir)/libplc$(MOD_VERSION).$(LIB_SUFFIX)
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-    LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+    LIBPLC = $(libdir)/plc$(MOD_VERSION).lib
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-    LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+    LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-    LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+    LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
     ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
         LIBPR = -lnspr$(MOD_VERSION)_shr
         LIBPLC = -lplc$(MOD_VERSION)_shr
     else
         LDOPTS += -brtl
         EXTRA_LIBS = -ldl
     endif
 endif
 
 ifeq ($(OS_ARCH), Linux)
     ifeq ($(OS_RELEASE), 1.2)
         EXTRA_LIBS = -ldl
     else
-        LDOPTS += -Xlinker -rpath $(PWD)/$(DIST)/lib
+        LDOPTS += -Xlinker -rpath $(PWD)/$(libdir)
         ifeq ($(USE_PTHREADS),1)
             EXTRA_LIBS = -lpthread
         endif
     endif
 endif
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-LIBPL = $(DIST)/lib/libplc$(MOD_VERSION).a
+LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+LIBPL = $(libdir)/libplc$(MOD_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), SCO_SV)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), UNIXWARE)
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -236,17 +236,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/pr/src/io/Makefile
+++ b/pr/src/io/Makefile
@@ -65,17 +65,17 @@ ifndef USE_PTHREADS
 	    prfile.c \
 	    prio.c \
 	    prsocket.c \
 	    $(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/io/Makefile.in
+++ b/pr/src/io/Makefile.in
@@ -70,17 +70,17 @@ ifndef USE_PTHREADS
 	    prfile.c \
 	    prio.c \
 	    prsocket.c \
 	    $(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/linking/Makefile
+++ b/pr/src/linking/Makefile
@@ -45,17 +45,17 @@ endif
 endif
 
 CSRCS =           \
 	prlink.c   \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/linking/Makefile.in
+++ b/pr/src/linking/Makefile.in
@@ -51,17 +51,17 @@ endif
 endif
 
 CSRCS =           \
 	prlink.c   \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES += -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/malloc/Makefile
+++ b/pr/src/malloc/Makefile
@@ -41,17 +41,17 @@ include $(MOD_DEPTH)/config/config.mk
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 CSRCS = prmalloc.c prmem.c
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
--- a/pr/src/malloc/Makefile.in
+++ b/pr/src/malloc/Makefile.in
@@ -46,17 +46,17 @@ include $(topsrcdir)/config/config.mk
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES += -D_NSPR_BUILD_
 
 CSRCS = prmalloc.c prmem.c
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
--- a/pr/src/md/Makefile
+++ b/pr/src/md/Makefile
@@ -60,17 +60,17 @@ endif
 endif
 
 CSRCS =          \
 	prosdep.c \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/Makefile.in
+++ b/pr/src/md/Makefile.in
@@ -69,17 +69,17 @@ endif
 endif # USE_AUTOCONF
 
 CSRCS =          \
 	prosdep.c \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/beos/Makefile
+++ b/pr/src/md/beos/Makefile
@@ -35,17 +35,17 @@ MOD_DEPTH = ../../../..
 
 include $(MOD_DEPTH)/config/config.mk
 
 include bsrcs.mk
 CSRCS += $(MDCSRCS)
 
 TARGETS		= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/beos/Makefile.in
+++ b/pr/src/md/beos/Makefile.in
@@ -41,17 +41,17 @@ include $(MOD_DEPTH)/config/autoconf.mk
 
 include $(topsrcdir)/config/config.mk
 
 include $(srcdir)/bsrcs.mk
 CSRCS += $(MDCSRCS)
 
 TARGETS		= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/os2/Makefile
+++ b/pr/src/md/os2/Makefile
@@ -50,17 +50,17 @@ CSRCS = \
     os2_errors.c \
     os2poll.c \
     os2rng.c \
     $(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/os2/Makefile.in
+++ b/pr/src/md/os2/Makefile.in
@@ -55,17 +55,17 @@ CSRCS = \
     os2_errors.c \
     os2poll.c \
     os2rng.c \
     $(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/unix/Makefile
+++ b/pr/src/md/unix/Makefile
@@ -298,37 +298,37 @@ ifeq ($(OS_ARCH),SunOS)
 			ULTRASPARC_ASFILES = os_$(OS_ARCH)_ultrasparc.s
 			ULTRASPARC_ASOBJS = $(addprefix $(OBJDIR)/,$(ULTRASPARC_ASFILES:.s=.$(OBJ_SUFFIX)))
 			TARGETS		+= $(ULTRASPARC_ASOBJS) $(SHARED_LIBRARY)
 			RELEASE_LIBS = $(SHARED_LIBRARY)
 		endif
 	endif
 endif
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 #ifeq ($(OS_ARCH),AIX)
 #ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE)))
 #ifneq ($(USE_PTHREADS), 1)
-#	$(INSTALL) -m 444 $(OBJDIR)/aixwrap.$(OBJ_SUFFIX) $(DIST)/lib
+#	$(INSTALL) -m 444 $(OBJDIR)/aixwrap.$(OBJ_SUFFIX) $(libdir)
 #endif
 #endif
 #endif
 
 ifeq ($(OS_ARCH),SunOS)
 ifneq ($(OS_RELEASE),4.1.3_U1)
 ifeq ($(OS_TEST),sun4u)
 $(SHARED_LIBRARY): $(ULTRASPARC_ASOBJS)
 	$(LD) -G -z text -o $@ $(ULTRASPARC_ASOBJS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(libdir)
 
 $(ULTRASPARC_ASOBJS): $(ULTRASPARC_ASFILES)
 ifeq ($(USE_64),1)
 	/usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v9 $<
 else
 	/usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v8plus $<
 endif
 
--- a/pr/src/md/unix/Makefile.in
+++ b/pr/src/md/unix/Makefile.in
@@ -319,38 +319,38 @@ else # USE_AUTOCONF
 
 CSRCS += $(PR_MD_CSRCS)
 ASFILES += $(PR_MD_ASFILES)
 
 TARGETS = $(OBJS)
 
 endif # ! USE_AUTOCONF
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 #ifeq ($(OS_ARCH),AIX)
 #ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE)))
 #ifneq ($(USE_PTHREADS), 1)
-#	$(INSTALL) -m 444 $(OBJDIR)/aixwrap.$(OBJ_SUFFIX) $(DIST)/lib
+#	$(INSTALL) -m 444 $(OBJDIR)/aixwrap.$(OBJ_SUFFIX) $(libdir)
 #endif
 #endif
 #endif
 
 ifndef USE_AUTOCONF
 ifeq ($(OS_ARCH),SunOS)
 ifneq ($(OS_RELEASE),4.1.3_U1)
 ifeq ($(OS_TEST),sun4u)
 $(SHARED_LIBRARY): $(ULTRASPARC_ASOBJS)
 	$(LD) -G -z text -o $@ $(ULTRASPARC_ASOBJS)
-	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/lib
+	$(INSTALL) -m 444 $(SHARED_LIBRARY) $(libdir)
 
 $(ULTRASPARC_ASOBJS): $(ULTRASPARC_ASFILES)
 ifeq ($(USE_64),1)
 	/usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v9 $<
 else
 	/usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v8plus $<
 endif
 
--- a/pr/src/md/windows/Makefile
+++ b/pr/src/md/windows/Makefile
@@ -87,17 +87,17 @@ CSRCS =          \
     w32rng.c \
     w32shm.c \
     $(NULL)
 endif
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/md/windows/Makefile.in
+++ b/pr/src/md/windows/Makefile.in
@@ -96,17 +96,17 @@ CSRCS =          \
     w32rng.c \
     w32shm.c \
     $(NULL)
 endif
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES += -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/memory/Makefile
+++ b/pr/src/memory/Makefile
@@ -47,17 +47,17 @@ endif
 CSRCS = prseg.c prshm.c prshma.c
 
 ifdef GC_LEAK_DETECTOR
 CSRCS += prgcleak.c
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/memory/Makefile.in
+++ b/pr/src/memory/Makefile.in
@@ -54,17 +54,17 @@ endif #!USE_AUTOCONF
 CSRCS = prseg.c prshm.c prshma.c
 
 ifdef GC_LEAK_DETECTOR
 CSRCS += prgcleak.c
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES += -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/misc/Makefile
+++ b/pr/src/misc/Makefile
@@ -71,17 +71,17 @@ CSRCS = \
 ifndef USE_PTHREADS
 CSRCS += \
 	pripcsem.c \
 	$(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 RELEASE_BINS = compile-et.pl prerr.properties
 
 include $(MOD_DEPTH)/config/rules.mk
 
 # An AIX Optimization bug causes PR_dtoa() to produce wrong result.
--- a/pr/src/misc/Makefile.in
+++ b/pr/src/misc/Makefile.in
@@ -78,17 +78,17 @@ CSRCS = \
 ifndef USE_PTHREADS
 CSRCS += \
 	pripcsem.c \
 	$(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 RELEASE_BINS = compile-et.pl prerr.properties
 
 include $(topsrcdir)/config/rules.mk
 
 ifndef USE_AUTOCONF
--- a/pr/src/pthreads/Makefile
+++ b/pr/src/pthreads/Makefile
@@ -48,17 +48,17 @@ CSRCS = \
 	ptio.c \
 	ptsynch.c \
 	ptthread.c \
 	ptmisc.c \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/pthreads/Makefile.in
+++ b/pr/src/pthreads/Makefile.in
@@ -54,17 +54,17 @@ CSRCS = \
 	ptio.c \
 	ptsynch.c \
 	ptthread.c \
 	ptmisc.c \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/threads/Makefile
+++ b/pr/src/threads/Makefile
@@ -78,17 +78,17 @@ CSRCS =	\
 	prcthr.c \
 	prtpd.c \
 	$(NULL)
 endif
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/threads/Makefile.in
+++ b/pr/src/threads/Makefile.in
@@ -84,17 +84,17 @@ CSRCS =	\
 	prcthr.c \
 	prtpd.c \
 	$(NULL)
 endif
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/threads/combined/Makefile
+++ b/pr/src/threads/combined/Makefile
@@ -54,17 +54,17 @@ CSRCS =         \
 	prulock.c    \
 	pruthr.c     \
     prustack.c    \
 	$(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 DEFINES     += -D_NSPR_BUILD_
 
 include $(MOD_DEPTH)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/src/threads/combined/Makefile.in
+++ b/pr/src/threads/combined/Makefile.in
@@ -62,17 +62,17 @@ CSRCS =         \
 	prulock.c    \
 	pruthr.c     \
     prustack.c    \
 	$(NULL)
 endif
 
 TARGETS	= $(OBJS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 DEFINES	+= -D_NSPR_BUILD_
 
 include $(topsrcdir)/config/rules.mk
 
 export:: $(TARGETS)
 
 install:: export
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -215,65 +215,65 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS)
 
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(includedir) -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPLC = -lplc$(MOD_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPLC= $(libdir)/plc$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifeq ($(OS_TARGET), WIN95)
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPLC= $(libdir)/plc$(MOD_VERSION).$(LIB_SUFFIX)
   else
-    LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPLC= $(DIST)/lib/libplc$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPLC= $(libdir)/libplc$(MOD_VERSION).$(LIB_SUFFIX)
   endif
   ifdef PROFILE                                                                              
     LDOPTS += -PROFILE -MAP                                                                  
   endif # profile
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
   LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-  LIBPR  = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib
+  LIBPR  = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPLC = $(libdir)/plc$(MOD_VERSION).lib
 else
 ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF)
   LDOPTS = -Zlinker /PM:VIO
 endif
 endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 # Use an absolute pathname as the runtime library path (for the -R
 # or -rpath linker option or the LD_RUN_PATH environment variable).
 ifeq (,$(patsubst /%,,$(DIST)))
 # $(DIST) is already an absolute pathname.
-ABSOLUTE_LIB_DIR = $(DIST)/lib
+ABSOLUTE_LIB_DIR = $(libdir)
 else
 # $(DIST) is a relative pathname: prepend the current directory.
 PWD = $(shell pwd)
-ABSOLUTE_LIB_DIR = $(PWD)/$(DIST)/lib
+ABSOLUTE_LIB_DIR = $(PWD)/$(libdir)
 endif
 endif
 
 ifeq ($(OS_ARCH), IRIX)
     ifeq ($(USE_CPLUS), 1)
         CC = CC
     endif
     LDOPTS += -rpath $(ABSOLUTE_LIB_DIR) -rdata_shared
@@ -295,18 +295,18 @@ endif
 
 ifeq ($(OS_ARCH), OSF1)
     ifeq ($(USE_CPLUS), 1)
         CC = cxx
     endif
 # I haven't figured out how to pass -rpath to cc on OSF1 V3.2, so
 # we do static linking.
     ifeq (,$(filter-out V2.0 V3.2,$(OS_RELEASE)))
-        LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-        LIBPLC = $(DIST)/lib/libplc$(MOD_VERSION).a
+        LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+        LIBPLC = $(libdir)/libplc$(MOD_VERSION).a
         EXTRA_LIBS = -lc_r
     else
         LDOPTS += -rpath $(ABSOLUTE_LIB_DIR)
     endif
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
     LDOPTS += -z -Wl,+s,+b,$(ABSOLUTE_LIB_DIR)
@@ -384,18 +384,18 @@ ifeq ($(OS_ARCH), NEXTSTEP)
 LDOPTS += -posix
 endif
 
 ifeq ($(OS_ARCH), NEWS-OS)
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
 #export LD_RUN_PATH = $(ABSOLUTE_LIB_DIR)
-    LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-    LIBPLC = $(DIST)/lib/libplc$(MOD_VERSION).a
+    LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+    LIBPLC = $(libdir)/libplc$(MOD_VERSION).a
     EXTRA_LIBS = -lsocket -lnsl -lgen -lresolv
 endif
 
 ifeq ($(OS_ARCH), Linux)
     ifeq ($(OS_RELEASE), 1.2)
         EXTRA_LIBS = -ldl
     else
         LDOPTS += -Xlinker -rpath $(ABSOLUTE_LIB_DIR)
@@ -484,17 +484,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/pr/tests/Makefile.in
+++ b/pr/tests/Makefile.in
@@ -217,67 +217,67 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS)
 
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(MOD_VERSION)
 LIBPLC = -lplc$(MOD_VERSION)
 
 ifndef USE_AUTOCONF
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).lib
+  LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPLC= $(libdir)/plc$(MOD_VERSION).lib
 else
   LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
   ifeq ($(OS_TARGET), WIN95)
-    LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/nspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPLC= $(libdir)/plc$(MOD_VERSION).$(LIB_SUFFIX)
   else
-    LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
-    LIBPLC= $(DIST)/lib/libplc$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPR = $(libdir)/libnspr$(MOD_VERSION).$(LIB_SUFFIX)
+    LIBPLC= $(libdir)/libplc$(MOD_VERSION).$(LIB_SUFFIX)
   endif
   ifdef PROFILE                                                                              
     LDOPTS += -PROFILE -MAP                                                                  
   endif # profile
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
 ifeq ($(MOZ_OS2_TOOLS),VACPP)
   LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-  LIBPR  = $(DIST)/lib/nspr$(MOD_VERSION).lib
-  LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib
+  LIBPR  = $(libdir)/nspr$(MOD_VERSION).lib
+  LIBPLC = $(libdir)/plc$(MOD_VERSION).lib
 else
 ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF)
   LDOPTS = -Zlinker /PM:VIO
 endif
 endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 # Use an absolute pathname as the runtime library path (for the -R
 # or -rpath linker option or the LD_RUN_PATH environment variable).
 ifeq (,$(patsubst /%,,$(DIST)))
 # $(DIST) is already an absolute pathname.
-ABSOLUTE_LIB_DIR = $(DIST)/lib
+ABSOLUTE_LIB_DIR = $(libdir)
 else
 # $(DIST) is a relative pathname: prepend the current directory.
 PWD = $(shell pwd)
-ABSOLUTE_LIB_DIR = $(PWD)/$(DIST)/lib
+ABSOLUTE_LIB_DIR = $(PWD)/$(libdir)
 endif
 endif
 
 ifeq ($(OS_ARCH), IRIX)
     ifeq ($(USE_CPLUS), 1)
         CC = CC
     endif
     LDOPTS += -rpath $(ABSOLUTE_LIB_DIR) -rdata_shared
@@ -299,18 +299,18 @@ endif
 
 ifeq ($(OS_ARCH), OSF1)
     ifeq ($(USE_CPLUS), 1)
         CC = cxx
     endif
 # I haven't figured out how to pass -rpath to cc on OSF1 V3.2, so
 # we do static linking.
     ifeq (,$(filter-out V2.0 V3.2,$(OS_RELEASE)))
-        LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-        LIBPLC = $(DIST)/lib/libplc$(MOD_VERSION).a
+        LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+        LIBPLC = $(libdir)/libplc$(MOD_VERSION).a
         EXTRA_LIBS = -lc_r
     else
         LDOPTS += -rpath $(ABSOLUTE_LIB_DIR)
     endif
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
     LDOPTS += -z -Wl,+s,+b,$(ABSOLUTE_LIB_DIR)
@@ -388,18 +388,18 @@ ifeq ($(OS_ARCH), NEXTSTEP)
 LDOPTS += -posix
 endif
 
 ifeq ($(OS_ARCH), NEWS-OS)
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
 #export LD_RUN_PATH = $(ABSOLUTE_LIB_DIR)
-    LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
-    LIBPLC = $(DIST)/lib/libplc$(MOD_VERSION).a
+    LIBPR = $(libdir)/libnspr$(MOD_VERSION).a
+    LIBPLC = $(libdir)/libplc$(MOD_VERSION).a
     EXTRA_LIBS = -lsocket -lnsl -lgen -lresolv
 endif
 
 ifeq ($(OS_ARCH), Linux)
     ifeq ($(OS_RELEASE), 1.2)
         EXTRA_LIBS = -ldl
     else
         LDOPTS += -Xlinker -rpath $(ABSOLUTE_LIB_DIR)
@@ -508,17 +508,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(MOD_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(MOD_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/pr/tests/dll/Makefile
+++ b/pr/tests/dll/Makefile
@@ -41,17 +41,17 @@ include $(MOD_DEPTH)/config/config.mk
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
 CSRCS = mygetval.c mysetval.c
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 OBJS = $(OBJDIR)/mygetval.$(OBJ_SUFFIX) \
 	$(OBJDIR)/mysetval.$(OBJ_SUFFIX)
 
 ifeq ($(OS_TARGET), WIN16)
 W16OBJS = $(subst $(space),$(comma)$(space),$(OBJS))
 endif
 
--- a/pr/tests/dll/Makefile.in
+++ b/pr/tests/dll/Makefile.in
@@ -46,17 +46,17 @@ include $(topsrcdir)/config/config.mk
 ifeq ($(OS_ARCH),SunOS)
 ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
 CSRCS = mygetval.c mysetval.c
 
-INCLUDES = -I$(DIST)/include
+INCLUDES = -I$(includedir)
 
 OBJS = $(OBJDIR)/mygetval.$(OBJ_SUFFIX) \
 	$(OBJDIR)/mysetval.$(OBJ_SUFFIX)
 
 ifeq ($(OS_TARGET), WIN16)
 W16OBJS = $(subst $(space),$(comma)$(space),$(OBJS))
 endif
 
--- a/pr/tests/w16gui/Makefile
+++ b/pr/tests/w16gui/Makefile
@@ -43,19 +43,19 @@ W16STDIO = $(MOD_DEPTH)/pr/src/md/window
 
 CSRCS = poppad.c \
        popfile.c \
        popfont.c \
        popfind.c \
        popprnt0.c
           
 
-INCLUDES = -I$(DIST)/include 
-LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-LIBPLDS = $(DIST)/lib/plds$(MOD_VERSION).lib
+INCLUDES = -I$(includedir) 
+LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+LIBPLDS = $(libdir)/plds$(MOD_VERSION).lib
 TARGETS = $(OBJDIR)/poppad.exe
 OS_CFLAGS = $(OS_EXE_CFLAGS)
 
 include $(MOD_DEPTH)/config/rules.mk
 
 
 ifeq ($(OS_TARGET),WIN16)    
 $(OBJDIR)/poppad.exe: $(OBJS)
--- a/pr/tests/w16gui/Makefile.in
+++ b/pr/tests/w16gui/Makefile.in
@@ -48,19 +48,19 @@ W16STDIO = $(MOD_DEPTH)/pr/src/md/window
 
 CSRCS = poppad.c \
        popfile.c \
        popfont.c \
        popfind.c \
        popprnt0.c
           
 
-INCLUDES = -I$(DIST)/include 
-LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib
-LIBPLDS = $(DIST)/lib/plds$(MOD_VERSION).lib
+INCLUDES = -I$(includedir) 
+LIBPR = $(libdir)/nspr$(MOD_VERSION).lib
+LIBPLDS = $(libdir)/plds$(MOD_VERSION).lib
 TARGETS = $(OBJDIR)/poppad.exe
 OS_CFLAGS = $(OS_EXE_CFLAGS)
 
 include $(topsrcdir)/config/rules.mk
 
 
 ifeq ($(OS_TARGET),WIN16)    
 $(OBJDIR)/poppad.exe: $(OBJS)
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -54,77 +54,77 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS)
 
-INCLUDES = -I$(DIST)/include 
+INCLUDES = -I$(includedir) 
 
 NSPR_VERSION = 3
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(NSPR_VERSION)
 LIBPLC = -lplc$(NSPR_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-  LIBPLC= $(DIST)/lib/plc$(NSPR_VERSION).lib
+  LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+  LIBPLC= $(libdir)/plc$(NSPR_VERSION).lib
 else
 LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
-LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
-LIBPLC= $(DIST)/lib/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
+LIBPR = $(libdir)/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
+LIBPLC= $(libdir)/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-    LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-    LIBPLC= $(DIST)/lib/plc$(NSPR_VERSION).lib
+    LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+    LIBPLC= $(libdir)/plc$(NSPR_VERSION).lib
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib -lpthread
+LDOPTS += -rpath $(PWD)/$(libdir) -lpthread
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 LIBPR = -lnspr$(NSPR_VERSION)_shr
 LIBPLC = -lplc$(NSPR_VERSION)_shr
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 endif
 endif
 
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
 ifeq ($(OS_RELEASE), 5.4)
 EXTRA_LIBS = -lthread
@@ -138,38 +138,38 @@ EXTRA_LIBS = -lthread
 endif
 endif
 endif # SunOS
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).a
-LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).a
+LIBPR = $(libdir)/libnspr$(NSPR_VERSION).a
+LIBPLC = $(libdir)/libplc$(NSPR_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -192,17 +192,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(NSPR_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(NSPR_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -59,77 +59,77 @@ PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 PROGS = $(addprefix $(OBJDIR)/, $(CSRCS:.c=$(PROG_SUFFIX)))
 
 TARGETS = $(PROGS)
 
-INCLUDES = -I$(DIST)/include 
+INCLUDES = -I$(includedir) 
 
 NSPR_VERSION = 3
 
 # Setting the variables LDOPTS and LIBPR.  We first initialize
 # them to the default values, then adjust them for some platforms.
-LDOPTS = -L$(DIST)/lib
+LDOPTS = -L$(libdir)
 LIBPR = -lnspr$(NSPR_VERSION)
 LIBPLC = -lplc$(NSPR_VERSION)
 
 ifeq ($(OS_ARCH), WINNT)
 ifeq ($(OS_TARGET), WIN16)
-  LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-  LIBPLC= $(DIST)/lib/plc$(NSPR_VERSION).lib
+  LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+  LIBPLC= $(libdir)/plc$(NSPR_VERSION).lib
 else
 LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO
-LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
-LIBPLC= $(DIST)/lib/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
+LIBPR = $(libdir)/libnspr$(NSPR_VERSION).$(LIB_SUFFIX)
+LIBPLC= $(libdir)/libplc$(NSPR_VERSION).$(LIB_SUFFIX)
 endif
 endif
 
 ifeq ($(OS_ARCH),OS2)
   ifeq ($(MOZ_OS2_TOOLS),VACPP)
     LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO
-    LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib
-    LIBPLC= $(DIST)/lib/plc$(NSPR_VERSION).lib
+    LIBPR = $(libdir)/nspr$(NSPR_VERSION).lib
+    LIBPLC= $(libdir)/plc$(NSPR_VERSION).lib
   else
     LDOPTS += -Zomf -Zlinker /PM:VIO
   endif
 endif
 
 ifneq ($(OS_ARCH), WINNT)
 PWD = $(shell pwd)
 endif
 
 ifeq ($(OS_ARCH), IRIX)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib
+LDOPTS += -rpath $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(DIST)/lib -lpthread
+LDOPTS += -rpath $(PWD)/$(libdir) -lpthread
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
-LDOPTS += -Wl,+s,+b,$(PWD)/$(DIST)/lib
+LDOPTS += -Wl,+s,+b,$(PWD)/$(libdir)
 endif
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
-LDOPTS += -blibpath:$(PWD)/$(DIST)/lib:/usr/lib:/lib
+LDOPTS += -blibpath:$(PWD)/$(libdir):/usr/lib:/lib
 LIBPR = -lnspr$(NSPR_VERSION)_shr
 LIBPLC = -lplc$(NSPR_VERSION)_shr
 endif
 
 # Solaris
 ifeq ($(OS_ARCH), SunOS)
 ifneq ($(OS_RELEASE), 4.1.3_U1)
 ifdef NS_USE_GCC
-LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(DIST)/lib
+LDOPTS += -Xlinker -R -Xlinker $(PWD)/$(libdir)
 else
-LDOPTS += -R $(PWD)/$(DIST)/lib
+LDOPTS += -R $(PWD)/$(libdir)
 endif
 endif
 
 # SunOS 5.4 and 5.5 need to link with -lthread or -lpthread,
 # even though we already linked with these system libraries
 # when we built libnspr.so.
 ifeq ($(OS_RELEASE), 5.4)
 EXTRA_LIBS = -lthread
@@ -143,38 +143,38 @@ EXTRA_LIBS = -lthread
 endif
 endif
 endif # SunOS
 
 ifeq ($(OS_ARCH), NCR)
 # XXX: We see some strange problems when we link with libnspr.so.
 # So for now we use static libraries on NCR.  The shared library
 # stuff below is commented out.
-LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).a
-LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).a
+LIBPR = $(libdir)/libnspr$(NSPR_VERSION).a
+LIBPLC = $(libdir)/libplc$(NSPR_VERSION).a
 EXTRA_LIBS = -lsocket -lnsl -ldl
 
 # NCR needs to link against -lsocket -lnsl (and -lc, which is linked
 # implicitly by $(CC)) again even though we already linked with these
 # system libraries when we built libnspr.so.
 #EXTRA_LIBS = -lsocket -lnsl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-#export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+#export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
-export LD_RUN_PATH = $(PWD)/$(DIST)/lib
+export LD_RUN_PATH = $(PWD)/$(libdir)
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################
 
@@ -197,17 +197,17 @@ ifeq ($(AIX_PRE_4_2),1)
 #
 # We use a pattern rule in ns/nspr20/config/rules.mk to generate
 # the .$(OBJ_SUFFIX) file from the .c source file, then do the
 # two-step linking hack below.
 
 $(OBJDIR)/%: $(OBJDIR)/%.$(OBJ_SUFFIX)
 	@$(MAKE_OBJDIR)
 	rm -f $@ $(AIX_TMP)
-	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(DIST)/lib/libnspr$(NSPR_VERSION).a
+	$(CC) $(AIX_LINK_OPTS) -o $(AIX_TMP) $< $(libdir)/libnspr$(NSPR_VERSION).a
 	$(CC) -o $@ $(AIX_TMP) $(AIX_WRAP)
 	rm -f $(AIX_TMP)
 
 else
 
 # All platforms that are not AIX pre-4.2.
 
 $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)