Index: build_tools/mkpkgconfig
===================================================================
--- build_tools/mkpkgconfig	(revision 333067)
+++ build_tools/mkpkgconfig	(working copy)
@@ -9,7 +9,7 @@
 
 ## Create a pkgconfig spec file for 3rd party modules (pkg-config asterisk --cflags)
 
-if [ ! -d $PPATH ]; then
+if [ ! -d "$PPATH" ]; then
   exit
 fi
 
@@ -29,7 +29,7 @@
   ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g'`
 
 
-cat <<EOF > $PPATH/asterisk.pc
+cat <<EOF > "$PPATH/asterisk.pc"
 install_prefix=$INSTALL_PREFIX
 version_number=$ASTERISKVERSIONNUM
 etcdir=$ASTETCDIR
Index: sounds/Makefile
===================================================================
--- sounds/Makefile	(revision 333067)
+++ sounds/Makefile	(working copy)
@@ -16,9 +16,9 @@
 -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/makeopts
 
 CMD_PREFIX?=@
-SOUNDS_DIR:=$(MAKE_ASTDATADIR)/sounds
+SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
 SOUNDS_CACHE_DIR?=
-MOH_DIR:=$(MAKE_ASTDATADIR)/moh
+MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
 CORE_SOUNDS_VERSION:=1.4.21
 EXTRA_SOUNDS_VERSION:=1.4.11
 MOH_VERSION:=2.03
@@ -38,7 +38,7 @@
 MCS:=$(subst -SIREN7,-siren7,$(MCS))
 MCS:=$(subst -SIREN14,-siren14,$(MCS))
 CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
-CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
+CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
 MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
 MES:=$(subst -FR-,-fr-,$(MES))
 MES:=$(subst -ES-,-es-,$(MES))
@@ -52,7 +52,7 @@
 MES:=$(subst -SIREN7,-siren7,$(MES))
 MES:=$(subst -SIREN14,-siren14,$(MES))
 EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
-EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
+EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
 MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
 MM:=$(subst -WAV,-wav,$(MM))
 MM:=$(subst -ULAW,-ulaw,$(MM))
@@ -64,7 +64,7 @@
 MM:=$(subst -SIREN7,-siren7,$(MM))
 MM:=$(subst -SIREN14,-siren14,$(MM))
 MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
-MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%-$(MOH_VERSION))
+MOH_TAGS:=$(MM:MOH-%=.asterisk-moh-%-$(MOH_VERSION))
 # If "fetch" is used, --continue is not a valid option.
 ifneq ($(findstring wget,$(DOWNLOAD)),)
 DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
@@ -73,8 +73,8 @@
 ifneq ($(SOUNDS_CACHE_DIR),)
 
 define sound_format_lang_rule
-$(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
-	$(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
+.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
+	$(CMD_PREFIX)PACKAGE=$$(subst .asterisk,asterisk,$$@).tar.gz; \
 	if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}; then \
 	  (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}); \
 	fi; \
@@ -90,7 +90,7 @@
 	    exit 1; \
 	  ) || exit 1; \
 	rm -f $$(subst -$(4),,$$@)-*; \
-	(cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
+	(mkdir -p "$(1)$(if $(3),/$(3),)";cd "$(1)$(if $(3),/$(3),)"; cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
 endef
 
 define sound_download_rule
@@ -115,13 +115,13 @@
 else
 
 define sound_format_lang_rule
-$(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
-	$(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
+.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
+	$(CMD_PREFIX)PACKAGE=$$(subst .asterisk,asterisk,$$@).tar.gz; \
 	if test ! -f $$$${PACKAGE}; then \
 	  $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} || exit 1; \
 	fi; \
 	rm -f $$(subst -$(4),,$$@)-*; \
-	(cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
+	(mkdir -p "$(1)$(if $(3),/$(3),)";cd "$(1)$(if $(3),/$(3),)"; cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
 endef
 
 define sound_download_rule
@@ -178,14 +178,15 @@
 dist-clean:
 	rm -f *.tar.gz
 
-$(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_DIR)/ru $(SOUNDS_CACHE_DIR):
+#$(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_DIR)/ru $(SOUNDS_CACHE_DIR):
+$(SOUNDS_CACHE_DIR):
 	mkdir -p $@
 
-install: $(SOUNDS_CACHE_DIR) $(SOUNDS_DIR)/en $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
+install: $(SOUNDS_CACHE_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
 
 uninstall:
-	rm -rf $(SOUNDS_DIR)
-	rm -rf $(MOH_DIR)
+	rm -rf "$(SOUNDS_DIR)"
+	rm -rf "$(MOH_DIR)"
 
 core_sounds_version:
 	@echo $(CORE_SOUNDS_VERSION)
