Description: Revamp the build system
 - Make errors fatal, so that they do not get ignored anymore.
 - Use sane make variables that a shell will accept as valid, otherwise
   the exports do not work at all.
 - Do not use system paths when we should use in-tree ones.
Author: Guillem Jover <gjover@sipwise.com>

---

---
 Makefile                                  |   13 +--
 Makefile.defs                             |  124 +++++++++++++++---------------
 apps/Makefile                             |   16 ++-
 apps/diameter_client/lib_dbase/Makefile   |    2 
 apps/dsm/Makefile                         |    6 -
 apps/dsm/mods/Makefile                    |   16 ++-
 apps/dsm/mods/Makefile.dsm_module         |   53 ++++++------
 apps/examples/Makefile                    |   16 ++-
 apps/examples/out_of_tree/Makefile        |    4 
 apps/examples/tutorial/Makefile           |   16 ++-
 apps/ivr/Makefile                         |    6 -
 apps/ivr/Makefile.ivr_application         |   34 ++++----
 apps/monitoring/Makefile                  |    2 
 apps/monitoring/tools/Makefile            |    9 +-
 apps/msg_storage/Makefile                 |    2 
 apps/py_sems/Makefile                     |    8 -
 apps/py_sems/Makefile.defs                |    2 
 apps/py_sems/Makefile.py_sems_application |   17 ++--
 apps/rtmp/flash_phone/Makefile            |    8 +
 apps/rtmp/librtmp/Makefile                |    2 
 apps/sbc/Makefile                         |    8 -
 apps/sbc/call_control/Makefile            |   14 ++-
 apps/sbc/tools/Makefile                   |    9 +-
 apps/voicemail/Makefile                   |   12 +-
 apps/webconference/Makefile               |    2 
 apps/webconference/tools/Makefile         |    9 +-
 core/Makefile                             |   72 ++++++++---------
 core/plug-in/Makefile                     |   16 ++-
 core/plug-in/Makefile.app_module          |   53 ++++++------
 core/plug-in/Makefile.audio_module        |    6 -
 core/plug-in/gsm/gsm-1.0-pl10/Makefile    |   56 ++++++-------
 core/plug-in/ilbc/iLBC_rfc3951/Makefile   |    2 
 core/plug-in/stats/Makefile               |    6 -
 core/resample/Makefile                    |    4 
 core/sip/Makefile                         |    4 
 core/tests/Makefile                       |   18 ++--
 pkg/rpm/sems.spec                         |   20 ++--
 tools/Makefile                            |   15 +--
 38 files changed, 363 insertions(+), 319 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,9 @@ subdirs = core apps tools
 
 .PHONY: clean
 clean:
-	-@rm -f *.so
-	-@for r in $(subdirs) doc "" ; do \
+	@rm -f *.so
+	@set -e; \
+	for r in $(subdirs) doc "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "making $$r" ; \
@@ -23,7 +24,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(subdirs) "" ; do \
+	@set -e; \
+	for r in $(subdirs) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "making $$r" ; \
@@ -33,7 +35,8 @@ modules:
 
 .PHONY: install
 install:
-	-@for r in $(subdirs) "" ; do \
+	@set -e; \
+	for r in $(subdirs) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -43,7 +46,7 @@ install:
 	@echo ""
 	@echo "*** install complete. Run SEMS with "
 	@echo "*** "
-	@echo "***   $(bin-target)$(NAME) -f $(cfg-target)sems.conf"
+	@echo "***   $(bin_target)$(NAME) -f $(cfg_target)sems.conf"
 
 
 .PHONY: dist
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -261,55 +261,55 @@ BASEDIR ?=
 basedir = $(BASEDIR)
 
 # Redhat users should use sems.redhat instead of sems
-# the file will be to $(bin-prefix)/$(bin-dir)/sems copied.
-start-script = sems.redhat
+# the file will be to $(bin_prefix)/$(bin_dir)/sems copied.
+start_script = sems.redhat
 
 # install prefixes for various stuff
-cfg-prefix = $(basedir)$(prefix)
-bin-prefix = $(basedir)$(prefix)
-modules-prefix = $(basedir)$(prefix)
-doc-prefix = $(basedir)$(prefix)
-audio-prefix = $(basedir)$(prefix)
-lib-prefix = $(basedir)$(prefix)
+cfg_prefix = $(basedir)$(prefix)
+bin_prefix = $(basedir)$(prefix)
+modules_prefix = $(basedir)$(prefix)
+doc_prefix = $(basedir)$(prefix)
+audio_prefix = $(basedir)$(prefix)
+lib_prefix = $(basedir)$(prefix)
 
 # dirs
-cfg-dir = etc/$(APP_NAME)/
+cfg_dir = etc/$(APP_NAME)/
 
-bin-dir = sbin/
-modules-dir = lib/$(APP_NAME)/plug-in/
-audio-dir = lib/$(APP_NAME)/audio/
-lib-dir = lib/$(APP_NAME)/
+bin_dir = sbin/
+modules_dir = lib/$(APP_NAME)/plug-in/
+audio_dir = lib/$(APP_NAME)/audio/
+lib_dir = lib/$(APP_NAME)/
 
 ifeq ($(OS), linux)
-	doc-dir = share/doc/$(APP_NAME)/
-	man-dir = share/man/
+	doc_dir = share/doc/$(APP_NAME)/
+	man_dir = share/man/
 else
 ifeq ($(OS), freebsd)
-	doc-dir = share/doc/$(APP_NAME)/
-	man-dir = man/
+	doc_dir = share/doc/$(APP_NAME)/
+	man_dir = man/
 else
 ifeq ($(OS), openbsd)
-	doc-dir = share/doc/$(APP_NAME)/
-	man-dir = man/
+	doc_dir = share/doc/$(APP_NAME)/
+	man_dir = man/
 else
 ifeq ($(OS), netbsd)
-	doc-dir = share/doc/$(APP_NAME)
-	man-dir = man/
+	doc_dir = share/doc/$(APP_NAME)
+	man_dir = man/
 else
-	doc-dir = doc/$(APP_NAME)/
-	man-dir = man/
+	doc_dir = doc/$(APP_NAME)/
+	man_dir = man/
 endif
 endif
 endif
 endif
 
 # target dirs for various stuff
-bin-target = $(prefix)/$(bin-dir)
-cfg-target ?= $(prefix)/$(cfg-dir)
-app-cfg-target = $(cfg-target)etc/
-modules-target = $(prefix)/$(modules-dir)
-audio-target = $(prefix)/$(audio-dir)
-lib-target = $(prefix)/$(lib-dir)
+bin_target = $(prefix)/$(bin_dir)
+cfg_target ?= $(prefix)/$(cfg_dir)
+app_cfg_target = $(cfg_target)etc/
+modules_target = $(prefix)/$(modules_dir)
+audio_target = $(prefix)/$(audio_dir)
+lib_target = $(prefix)/$(lib_dir)
 
 ifeq ($(OS), solaris)
 #use GNU versions
@@ -320,24 +320,24 @@ INSTALL ?= install
 TAR ?= tar
 endif
 
-INSTALL-TOUCH = touch          # used to create the file first (good to 
+INSTALL_TOUCH = touch          # used to create the file first (good to
                                #  make solaris install work)
-INSTALL-CFG = $(INSTALL) -m 644
-INSTALL-BIN = $(INSTALL) -m 755
-INSTALL-MODULES = $(INSTALL) -m 755
-INSTALL-DOC = $(INSTALL) -m 644
-INSTALL-AUDIO = $(INSTALL) -m 644
+INSTALL_CFG = $(INSTALL) -m 644
+INSTALL_BIN = $(INSTALL) -m 755
+INSTALL_MODULES = $(INSTALL) -m 755
+INSTALL_DOC = $(INSTALL) -m 644
+INSTALL_AUDIO = $(INSTALL) -m 644
 
 #export stuff to sub-makes
 export REL_VERSION RELEASE OS ARCH
 export CPPFLAGS CXXFLAGS LDFLAGS CFLAGS LIB_LDFLAGS
 export CXX CC LD
-export DESTDIR PREFIX prefix basedir ser-prefix
-export start-script
-export cfg-prefix bin-prefix modules-prefix doc-prefix audio-prefix lib-prefix
-export cfg-dir bin-dir modules-dir audio-dir lib-dir doc-dir man-dir
-export bin-target cfg-target app-cfg-target modules-target audio-target lib-target
-export INSTALL TAR INSTALL-TOUCH INSTALL-CFG INSTALL-BIN INSTALL-MODULES INSTALL-DOC INSTALL-AUDIO
+export DESTDIR PREFIX prefix basedir ser_prefix
+export start_script
+export cfg_prefix bin_prefix modules_prefix doc_prefix audio_prefix lib_prefix
+export cfg_dir bin_dir modules_dir audio_dir lib_dir doc_dir man_dir
+export bin_target cfg_target app_cfg_target modules_target audio_target lib_target
+export INSTALL TAR INSTALL_TOUCH INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC INSTALL_AUDIO
 export APP_NAME
 
 export USE_SPANDSP LIBSPANDSP_STATIC LIBSPANDSP_LDIR 
@@ -347,27 +347,27 @@ export USE_MONITORING
 export exclude_core_modules exclude_app_modules
 endif  # ifeq ($(makefile_defs, 1)
 
-mk-install-dirs: $(DESTDIR)$(cfg-target) \
-		 $(DESTDIR)$(app-cfg-target) \
-		 $(DESTDIR)$(bin-prefix)/$(bin-dir) \
-		 $(DESTDIR)$(modules-prefix)/$(modules-dir) \
-		 $(DESTDIR)$(audio-prefix)/$(audio-dir) \
-		 $(DESTDIR)$(doc-prefix)/$(doc-dir)
-
-$(DESTDIR)$(cfg-target): 
-	mkdir -p $(DESTDIR)$(cfg-target)
-
-$(DESTDIR)$(app-cfg-target): 
-	mkdir -p $(DESTDIR)$(app-cfg-target)
-
-$(DESTDIR)$(bin-prefix)/$(bin-dir):
-	mkdir -p $(DESTDIR)$(bin-prefix)/$(bin-dir)
+mk-install-dirs: $(DESTDIR)$(cfg_target) \
+		 $(DESTDIR)$(app_cfg_target) \
+		 $(DESTDIR)$(bin_prefix)/$(bin_dir) \
+		 $(DESTDIR)$(modules_prefix)/$(modules_dir) \
+		 $(DESTDIR)$(audio_prefix)/$(audio_dir) \
+		 $(DESTDIR)$(doc_prefix)/$(doc_dir)
+
+$(DESTDIR)$(cfg_target):
+	mkdir -p $(DESTDIR)$(cfg_target)
+
+$(DESTDIR)$(app_cfg_target):
+	mkdir -p $(DESTDIR)$(app_cfg_target)
+
+$(DESTDIR)$(bin_prefix)/$(bin_dir):
+	mkdir -p $(DESTDIR)$(bin_prefix)/$(bin_dir)
 
-$(DESTDIR)$(modules-prefix)/$(modules-dir):
-	mkdir -p $(DESTDIR)$(modules-prefix)/$(modules-dir)
+$(DESTDIR)$(modules_prefix)/$(modules_dir):
+	mkdir -p $(DESTDIR)$(modules_prefix)/$(modules_dir)
 
-$(DESTDIR)$(audio-prefix)/$(audio-dir):
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)
+$(DESTDIR)$(audio_prefix)/$(audio_dir):
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)
 
-$(DESTDIR)$(doc-prefix)/$(doc-dir):
-	mkdir -p $(DESTDIR)$(doc-prefix)/$(doc-dir)
+$(DESTDIR)$(doc_prefix)/$(doc_dir):
+	mkdir -p $(DESTDIR)$(doc_prefix)/$(doc_dir)
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -41,8 +41,9 @@ all: modules
 
 .PHONY: clean
 clean:
-	-@rm -f *.so
-	-@for r in $(app_modules) "" ; do \
+	@rm -f *.so
+	@set -e; \
+	for r in $(app_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "Cleaning $$r" ; \
@@ -53,7 +54,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(app_modules) "" ; do \
+	@set -e; \
+	for r in $(app_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo "Making $$r" ; \
@@ -67,7 +69,8 @@ install: install-bin
 
 .PHONY: install-bin
 install-bin:
-	-@for r in $(app_modules) "" ; do \
+	@set -e; \
+	for r in $(app_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "Installing $$r binaries" ; \
@@ -77,8 +80,9 @@ install-bin:
 	done
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(cfg-target)
-	-@for r in $(app_modules) "" ; do \
+install-cfg: $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(app_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "Installing $$r configuration" ; \
--- a/apps/diameter_client/lib_dbase/Makefile
+++ b/apps/diameter_client/lib_dbase/Makefile
@@ -25,7 +25,7 @@ RANLIB		= ranlib
 
 .PHONY: clean
 clean:
-	-@rm -f $(objs) $(depends) $(lib_name)
+	@rm -f $(objs) $(depends) $(lib_name)
 
 -include $(depends)
 
--- a/apps/dsm/Makefile
+++ b/apps/dsm/Makefile
@@ -12,10 +12,10 @@ COREPATH ?=../../core
 include $(COREPATH)/plug-in/Makefile.app_module
 
 make_dsm_mods: 
-	-@$(MAKE) -C mods  
+	@$(MAKE) -C mods
 
 install_dsm_mods:
-	-@$(MAKE) -C mods/ install
+	@$(MAKE) -C mods/ install
 
 clean_dsm_mods:
-	-@$(MAKE) -C mods/ clean
+	@$(MAKE) -C mods/ clean
--- a/apps/dsm/mods/Makefile
+++ b/apps/dsm/mods/Makefile
@@ -25,8 +25,9 @@ all: modules
 
 .PHONY: clean
 clean:
-	-@rm -f lib/*.so
-	-@for r in $(dsm_modules) "" ; do \
+	@rm -f lib/*.so
+	@set -e; \
+	for r in $(dsm_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -36,7 +37,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(dsm_modules) "" ; do \
+	@set -e; \
+	for r in $(dsm_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "" ; \
@@ -49,7 +51,8 @@ install: install-bin
 
 .PHONY: install-bin
 install-bin:
-	-@for r in $(dsm_modules) "" ; do \
+	@set -e; \
+	for r in $(dsm_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -58,8 +61,9 @@ install-bin:
 	done
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(cfg-target)
-	-@for r in $(dsm_modules) "" ; do \
+install-cfg: $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(dsm_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
--- a/apps/dsm/mods/Makefile.dsm_module
+++ b/apps/dsm/mods/Makefile.dsm_module
@@ -33,51 +33,54 @@ module_package: $(extra_target) $(lib_na
 
 .PHONY: clean
 clean: $(extra_clean)
-	-@rm -f $(objs) $(depends) $(lib_name)
+	@rm -f $(objs) $(depends) $(lib_name)
 
 .PHONY: install
 install: all $(extra_install)
-	mkdir -p $(DESTDIR)$(lib-prefix)/$(lib-dir)/dsm
+	mkdir -p $(DESTDIR)$(lib_prefix)/$(lib_dir)/dsm
 	if [ -f "$(lib_name)" ]; then \
-	 $(INSTALL-TOUCH) $(DESTDIR)$(lib-prefix)/$(lib-dir)/dsm/; \
-	 $(INSTALL-MODULES) $(lib_name) $(DESTDIR)$(lib-prefix)/$(lib-dir)/dsm/; \
+	 $(INSTALL_TOUCH) $(DESTDIR)$(lib_prefix)/$(lib_dir)/dsm/; \
+	 $(INSTALL_MODULES) $(lib_name) $(DESTDIR)$(lib_prefix)/$(lib_dir)/dsm/; \
 	fi
 
 .PHONY: install-cfg
 install-cfg: 
-	mkdir -p $(DESTDIR)$(cfg-target)
-	-@for r in $(module_conf_files); do \
+	mkdir -p $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(module_conf_files); do \
 			echo installing $$r ;  \
-			$(INSTALL-TOUCH) $(DESTDIR)$(cfg-target)$$r ; \
-			sed -e "s#/usr/.*lib/sems/audio/#$(audio-target)#g" \
-			-e "s#/usr/.*lib/sems/plug-in/#$(modules-target)#g" \
-			-e "s#/usr/.*lib/sems/ivr/#$(lib-target)ivr/#g" \
-			-e "s#/usr/.*lib/sems/dsm/#$(lib-target)dsm/#g" \
-			-e "s#/usr/.*lib/sems/py_sems/#$(lib-target)py_sems/#g" \
-			-e "s#/usr/.*etc/sems/#$(cfg-target)#g" \
-			< $$r > $(DESTDIR)$(cfg-target)$$r; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(cfg_target)$$r ; \
+			sed -e "s#/usr/.*lib/sems/audio/#$(audio_target)#g" \
+			-e "s#/usr/.*lib/sems/plug-in/#$(modules_target)#g" \
+			-e "s#/usr/.*lib/sems/ivr/#$(lib_target)ivr/#g" \
+			-e "s#/usr/.*lib/sems/dsm/#$(lib_target)dsm/#g" \
+			-e "s#/usr/.*lib/sems/py_sems/#$(lib_target)py_sems/#g" \
+			-e "s#/usr/.*etc/sems/#$(cfg_target)#g" \
+			< $$r > $(DESTDIR)$(cfg_target)$$r; \
 	done
 
-$(DESTDIR)(audio-prefix)/$(audio-dir):
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)
+$(DESTDIR)$(audio_prefix)/$(audio_dir):
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)
 
 .PHONY: $(plug_in_name)_audio
-$(plug_in_name)_audio: $(DESTDIR)$(audio-prefix)/$(audio-dir)
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)$(plug_in_name)
-	-@for f in $(AUDIO_FILES) ; do \
+$(plug_in_name)_audio: $(DESTDIR)$(audio_prefix)/$(audio_dir)
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)$(plug_in_name)
+	@set -e; \
+	for f in $(AUDIO_FILES) ; do \
 		if [ -n "wav/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(audio-prefix)/$(audio-dir)$(plug_in_name)/$$f; \
-			$(INSTALL-AUDIO) wav/$$f $(DESTDIR)$(audio-prefix)/$(audio-dir)$(plug_in_name)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(audio_prefix)/$(audio_dir)$(plug_in_name)/$$f; \
+			$(INSTALL_AUDIO) wav/$$f $(DESTDIR)$(audio_prefix)/$(audio_dir)$(plug_in_name)/$$f; \
 		fi ; \
 	done
 
 .PHONY: $(plug_in_name)_lib
 $(plug_in_name)_lib: 
-	mkdir -p $(DESTDIR)$(lib-prefix)/$(lib-dir)/$(plug_in_name)
-	-@for f in $(EXTRA_LIB_FILES) ; do \
+	mkdir -p $(DESTDIR)$(lib_prefix)/$(lib_dir)/$(plug_in_name)
+	@set -e; \
+	for f in $(EXTRA_LIB_FILES) ; do \
 		if [ -n "$(EXTRA_LIB_DIR)/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(lib-prefix)/$(lib-dir)/$(plug_in_name)/$$f; \
-			$(INSTALL-AUDIO) $(EXTRA_LIB_DIR)$$f $(DESTDIR)$(lib-prefix)/$(lib-dir)/$(plug_in_name)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(lib_prefix)/$(lib_dir)/$(plug_in_name)/$$f; \
+			$(INSTALL_AUDIO) $(EXTRA_LIB_DIR)$$f $(DESTDIR)$(lib_prefix)/$(lib_dir)/$(plug_in_name)/$$f; \
 		fi ; \
 	done
 
--- a/apps/examples/Makefile
+++ b/apps/examples/Makefile
@@ -13,8 +13,9 @@ all: modules
 
 .PHONY: clean
 clean:
-	-@rm -f *.so
-	-@for r in $(modules) "" ; do \
+	@rm -f *.so
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -24,7 +25,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(modules) "" ; do \
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "" ; \
@@ -37,7 +39,8 @@ install: install-bin
 
 .PHONY: install-bin
 install-bin:
-	-@for r in $(modules) "" ; do \
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -46,8 +49,9 @@ install-bin:
 	done
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(cfg-target)
-	-@for r in $(modules) "" ; do \
+install-cfg: $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
--- a/apps/examples/out_of_tree/Makefile
+++ b/apps/examples/out_of_tree/Makefile
@@ -3,8 +3,8 @@ plug_in_name = myapp
 module_ldflags =
 module_cflags  = 
 
-COREPATH ?=/usr/include/sems
-DEFSPATH ?=/usr/include/sems
+COREPATH ?=$(CURDIR)/../../../core
+DEFSPATH ?=$(COREPATH)/..
 app_module_dir=.
 
 include $(COREPATH)/plug-in/Makefile.app_module
--- a/apps/examples/tutorial/Makefile
+++ b/apps/examples/tutorial/Makefile
@@ -13,8 +13,9 @@ all: modules
 
 .PHONY: clean
 clean:
-	-@rm -f *.so
-	-@for r in $(modules) "" ; do \
+	@rm -f *.so
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -24,7 +25,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(modules) "" ; do \
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "" ; \
@@ -37,7 +39,8 @@ install: install-bin
 
 .PHONY: install-bin
 install-bin:
-	-@for r in $(modules) "" ; do \
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -46,8 +49,9 @@ install-bin:
 	done
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(cfg-target)
-	-@for r in $(modules) "" ; do \
+install-cfg: $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
--- a/apps/ivr/Makefile
+++ b/apps/ivr/Makefile
@@ -91,12 +91,12 @@ endif
 endif
 
 .PHONY: install_python_files
-install_python_files: $(DESTDIR)$(modules-prefix)/$(modules-dir)
+install_python_files: $(DESTDIR)$(modules_prefix)/$(modules_dir)
 	echo "Installing Python object files..."
 	for f in $(py_obj) ; do \
 		if [ -n "py/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(modules-prefix)/$(modules-dir)/$$f; \
-			$(INSTALL-MODULES) py/$$f $(DESTDIR)$(modules-prefix)/$(modules-dir)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(modules_prefix)/$(modules_dir)/$$f; \
+			$(INSTALL_MODULES) py/$$f $(DESTDIR)$(modules_prefix)/$(modules_dir)/$$f; \
 		fi ; \
 	done
 
--- a/apps/ivr/Makefile.ivr_application
+++ b/apps/ivr/Makefile.ivr_application
@@ -10,9 +10,9 @@ include $(COREPATH)/../Makefile.defs
 include $(IVRPATH)/Makefile.defs
 
 # 
-ivr-modules-dir?=lib/$(APP_NAME)/ivr
+ivr_modules_dir?=lib/$(APP_NAME)/ivr
 
-LIB_INSTALLDIR?=$(modules-prefix)/$(ivr-modules-dir)
+LIB_INSTALLDIR?=$(modules_prefix)/$(ivr_modules_dir)
 TARBALL_PREFIX=sems-app-${NAME}
 TARBALL="${TARBALL_PREFIX}-${VERSION}.tar.gz"
 
@@ -50,26 +50,28 @@ endif
 
 .PHONY: install-cfg
 install-cfg: 
-	mkdir -p $(DESTDIR)$(app-cfg-target)
-	-@for r in $(module_conf_files); do \
+	mkdir -p $(DESTDIR)$(app_cfg_target)
+	@set -e; \
+	for r in $(module_conf_files); do \
 			echo installing $$r ;  \
-			$(INSTALL-TOUCH) $(DESTDIR)$(app-cfg-target)$$r ; \
-			sed -e "s#/usr/.*lib/sems/audio/#$(audio-target)#g" \
-			-e "s#/usr/.*lib/sems/plug-in/#$(modules-target)#g" \
-			-e "s#/usr/.*etc/sems/#$(app-cfg-target)#g" \
-			< etc/$$r > $(DESTDIR)$(app-cfg-target)$$r; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(app_cfg_target)$$r ; \
+			sed -e "s#/usr/.*lib/sems/audio/#$(audio_target)#g" \
+			-e "s#/usr/.*lib/sems/plug-in/#$(modules_target)#g" \
+			-e "s#/usr/.*etc/sems/#$(app_cfg_target)#g" \
+			< etc/$$r > $(DESTDIR)$(app_cfg_target)$$r; \
 	done
 
-$(DESTDIR)(audio-prefix)/$(audio-dir):
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)
+$(DESTDIR)$(audio_prefix)/$(audio_dir):
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)
 
 .PHONY: $(NAME)_audio
-$(NAME)_audio: $(DESTDIR)$(audio-prefix)/$(audio-dir)
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)$(NAME)
-	-@for f in $(AUDIO_FILES) ; do \
+$(NAME)_audio: $(DESTDIR)$(audio_prefix)/$(audio_dir)
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)$(NAME)
+	@set -e; \
+	for f in $(AUDIO_FILES) ; do \
 		if [ -n "wav/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(audio-prefix)/$(audio-dir)$(NAME)/$$f; \
-			$(INSTALL-AUDIO) wav/$$f $(DESTDIR)$(audio-prefix)/$(audio-dir)$(NAME)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(audio_prefix)/$(audio_dir)$(NAME)/$$f; \
+			$(INSTALL_AUDIO) wav/$$f $(DESTDIR)$(audio_prefix)/$(audio_dir)$(NAME)/$$f; \
 		fi ; \
 	done
 
--- a/apps/monitoring/Makefile
+++ b/apps/monitoring/Makefile
@@ -9,4 +9,4 @@ COREPATH ?=../../core
 include $(COREPATH)/plug-in/Makefile.app_module
 
 install_tools:
-	-@$(MAKE) -C tools/ install
+	@$(MAKE) -C tools/ install
--- a/apps/monitoring/tools/Makefile
+++ b/apps/monitoring/tools/Makefile
@@ -6,12 +6,13 @@ monitoring_scripts = $(wildcard sems-*)
 all: install_tools
 install: install_tools
 
-install_tools: $(DESTDIR)$(bin-prefix)/$(bin-dir)
-	-@for r in $(monitoring_scripts)  ; do \
+install_tools: $(DESTDIR)$(bin_prefix)/$(bin_dir)
+	@set -e; \
+	for r in $(monitoring_scripts)  ; do \
 		x=`echo $$r | sed s/sems-/$(APP_NAME)-/g` ; \
 		echo "installing $$r -> $$x" ; \
-		$(INSTALL-TOUCH) $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
-		$(INSTALL-BIN) $$r $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
+		$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
+		$(INSTALL_BIN) $$r $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
 	done
 
 
--- a/apps/msg_storage/Makefile
+++ b/apps/msg_storage/Makefile
@@ -9,4 +9,4 @@ COREPATH ?=../../core
 include $(COREPATH)/plug-in/Makefile.app_module
 
 spooldir:
-	-mkdir -p $(DESTDIR)/var/spool/voicebox
+	mkdir -p $(DESTDIR)/var/spool/voicebox
--- a/apps/py_sems/Makefile
+++ b/apps/py_sems/Makefile
@@ -85,17 +85,17 @@ endif
 endif
 
 .PHONY: install_python_files
-install_python_files: $(DESTDIR)$(modules-prefix)/$(modules-dir)
+install_python_files: $(DESTDIR)$(modules_prefix)/$(modules_dir)
 	echo "Installing Python object files..."
 	for f in $(py_obj) ; do \
 		if [ -n "py/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(modules-prefix)/$(modules-dir)/$$f; \
-			$(INSTALL-MODULES) py/$$f $(DESTDIR)$(modules-prefix)/$(modules-dir)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(modules_prefix)/$(modules_dir)/$$f; \
+			$(INSTALL_MODULES) py/$$f $(DESTDIR)$(modules_prefix)/$(modules_dir)/$$f; \
 		fi ; \
 	done
 
 	echo "Installing py_sems script path..."
-	$(INSTALL-MODULES) -d $(DESTDIR)$(modules-prefix)/$(py-sems-modules-dir)
+	$(INSTALL_MODULES) -d $(DESTDIR)$(modules_prefix)/$(py_sems_modules_dir)
 
 .PHONY: clean_py_sems_lib
 clean_py_sems_lib:
--- a/apps/py_sems/Makefile.defs
+++ b/apps/py_sems/Makefile.defs
@@ -15,4 +15,4 @@ PYTHON_DIR = $(shell $(PY_EXE) ./python_
 PYTHON_LIBDIR = $(shell $(PY_EXE) ./python_lib.py)
 
 # 
-py-sems-modules-dir?=lib/$(APP_NAME)/py_sems
+py_sems_modules_dir?=lib/$(APP_NAME)/py_sems
--- a/apps/py_sems/Makefile.py_sems_application
+++ b/apps/py_sems/Makefile.py_sems_application
@@ -7,7 +7,7 @@ PYSEMSPATH ?= ../py_sems
 include $(COREPATH)/../Makefile.defs
 include $(PYSEMSPATH)/Makefile.defs
 
-LIB_INSTALLDIR?=$(modules-prefix)/$(py-sems-modules-dir)
+LIB_INSTALLDIR?=$(modules_prefix)/$(py_sems_modules_dir)
 TARBALL_PREFIX=sems-app-${NAME}
 TARBALL="${TARBALL_PREFIX}-${VERSION}.tar.gz"
 
@@ -42,14 +42,15 @@ install: all
 
 .PHONY: install-cfg
 install-cfg: 
-	mkdir -p $(cfg-target)
-	-@for r in $(module_conf_files); do \
+	mkdir -p $(cfg_target)
+	@set -e; \
+	for r in $(module_conf_files); do \
 			echo installing $$r ;  \
-			$(INSTALL-TOUCH) $(cfg-target)$$r ; \
-			sed -e "s#/usr/.*lib/sems/audio/#$(audio-target)#g" \
-			-e "s#/usr/.*lib/sems/plug-in/#$(modules-target)#g" \
-			-e "s#/usr/.*etc/sems/#$(cfg-target)#g" \
-			< etc/$$r > $(DESTDIR)$(cfg-target)$$r; \
+			$(INSTALL_TOUCH) $(cfg_target)$$r ; \
+			sed -e "s#/usr/.*lib/sems/audio/#$(audio_target)#g" \
+			-e "s#/usr/.*lib/sems/plug-in/#$(modules_target)#g" \
+			-e "s#/usr/.*etc/sems/#$(cfg_target)#g" \
+			< etc/$$r > $(DESTDIR)$(cfg_target)$$r; \
 	done
 
 
--- a/apps/rtmp/flash_phone/Makefile
+++ b/apps/rtmp/flash_phone/Makefile
@@ -21,10 +21,14 @@ MXMLC_OPTS= \
 APP=sono
 SOURCES= $(APP).mxml $(wildcard *.as)
 
-all: $(APP).swf
+ifneq ($(wildcard $(FLEX_SDK)),)
+TARGET=$(APP).swf
+endif
+
+all: $(TARGET)
 
 clean:
-	rm *.swf
+	rm -f *.swf
 
 %.swf: $(SOURCES) Makefile
 	$(MXMLC) $(MXMLC_OPTS) $<
--- a/apps/rtmp/librtmp/Makefile
+++ b/apps/rtmp/librtmp/Makefile
@@ -78,7 +78,7 @@ librtmp.pc: librtmp.pc.in Makefile
 install:	install_base $(SO_INST)
 
 install_base:	librtmp.a librtmp.pc
-	-mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3
+	mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3
 	cp amf.h http.h log.h rtmp.h $(INCDIR)
 	cp librtmp.a $(LIBDIR)
 	cp librtmp.pc $(LIBDIR)/pkgconfig
--- a/apps/sbc/Makefile
+++ b/apps/sbc/Makefile
@@ -11,15 +11,15 @@ COREPATH ?= ../../core
 include $(COREPATH)/plug-in/Makefile.app_module
 
 install_tools:
-	-@$(MAKE) -C tools/ install
+	@$(MAKE) -C tools/ install
 
 make_call_control_mods:
-	-@$(MAKE) -C call_control
+	@$(MAKE) -C call_control
 
 install_call_control_mods:
-	-@$(MAKE) -C call_control/ install
+	@$(MAKE) -C call_control/ install
 
 clean_call_control_mods:
-	-@$(MAKE) -C call_control/ clean
+	@$(MAKE) -C call_control/ clean
 
 
--- a/apps/sbc/call_control/Makefile
+++ b/apps/sbc/call_control/Makefile
@@ -16,7 +16,8 @@ all: modules
 
 .PHONY: clean
 clean:
-	-@for r in $(cc_modules) "" ; do \
+	@set -e; \
+	for r in $(cc_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -26,7 +27,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(cc_modules) "" ; do \
+	@set -e; \
+	for r in $(cc_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "" ; \
@@ -39,7 +41,8 @@ install: install-bin install-cfg
 
 .PHONY: install-bin
 install-bin:
-	-@for r in $(cc_modules) "" ; do \
+	@set -e; \
+	for r in $(cc_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -48,8 +51,9 @@ install-bin:
 	done
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(cfg-target)
-	-@for r in $(dsm_modules) "" ; do \
+install-cfg: $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(dsm_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
--- a/apps/sbc/tools/Makefile
+++ b/apps/sbc/tools/Makefile
@@ -8,12 +8,13 @@ sbc_scripts = $(wildcard sems-sbc-*)
 all: install_tools
 install: install_tools
 
-install_tools: $(DESTDIR)$(bin-prefix)/$(bin-dir)
-	-@for r in $(sbc_scripts)  ; do \
+install_tools: $(DESTDIR)$(bin_prefix)/$(bin_dir)
+	@set -e; \
+	for r in $(sbc_scripts)  ; do \
 		x=`echo $$r | sed s/sems-/$(APP_NAME)-/g` ; \
 		echo "installing $$r -> $$x" ; \
-		$(INSTALL-TOUCH) $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
-		$(INSTALL-BIN) $$r $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
+		$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
+		$(INSTALL_BIN) $$r $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
 	done
 
 
--- a/apps/voicemail/Makefile
+++ b/apps/voicemail/Makefile
@@ -21,12 +21,12 @@ extra_install = install_email_template $
 vm_module:	all
 
 .PHONY: install_email_template
-install_email_template: $(DESTDIR)$(app-cfg-target)
-	$(INSTALL-TOUCH) $(DESTDIR)$(app-cfg-target)default.template.sample
-	$(INSTALL-CFG) default.template.sample $(DESTDIR)$(app-cfg-target)
-	if [ ! -f $(DESTDIR)$(app-cfg-target)default.template ]; then \
-		cp -f $(DESTDIR)$(app-cfg-target)default.template.sample \
-			$(DESTDIR)$(app-cfg-target)default.template; \
+install_email_template: $(DESTDIR)$(app_cfg_target)
+	$(INSTALL_TOUCH) $(DESTDIR)$(app_cfg_target)default.template.sample
+	$(INSTALL_CFG) default.template.sample $(DESTDIR)$(app_cfg_target)
+	if [ ! -f $(DESTDIR)$(app_cfg_target)default.template ]; then \
+		cp -f $(DESTDIR)$(app_cfg_target)default.template.sample \
+			$(DESTDIR)$(app_cfg_target)default.template; \
 	fi
 
 
--- a/apps/webconference/Makefile
+++ b/apps/webconference/Makefile
@@ -9,4 +9,4 @@ COREPATH ?=../../core
 include $(COREPATH)/plug-in/Makefile.app_module
 
 install_tools:
-	-@$(MAKE) -C tools/ install
+	@$(MAKE) -C tools/ install
--- a/apps/webconference/tools/Makefile
+++ b/apps/webconference/tools/Makefile
@@ -7,12 +7,13 @@ wc_scripts = $(wildcard sems-webconferen
 all: install_tools
 install: install_tools
 
-install_tools: $(DESTDIR)$(bin-prefix)/$(bin-dir)
-	-@for r in $(wc_scripts)  ; do \
+install_tools: $(DESTDIR)$(bin_prefix)/$(bin_dir)
+	@set -e; \
+	for r in $(wc_scripts)  ; do \
 		x=`echo $$r | sed s/sems-/$(APP_NAME)-/g` ; \
 		echo "installing $$r -> $$x" ; \
-		$(INSTALL-TOUCH) $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
-		$(INSTALL-BIN) $$r $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
+		$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
+		$(INSTALL_BIN) $$r $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
 	done
 
 
--- a/core/Makefile
+++ b/core/Makefile
@@ -20,29 +20,29 @@ all: ../Makefile.defs $(NAME) modules
 
 .PHONY: clean
 clean:
-	-@rm -f $(OBJS) $(DEPS) $(NAME)
-	-@rm -f lib/*.so compat/getos compat/getarch
-	-@$(MAKE) -C $(SIP_STACK_DIR) clean
-	-@$(MAKE) -C $(RESAMPLE_DIR) clean
-	-@$(MAKE) -C $(PLUGIN_DIR) clean
+	@rm -f $(OBJS) $(DEPS) $(NAME)
+	@rm -f lib/*.so compat/getos compat/getarch
+	@$(MAKE) -C $(SIP_STACK_DIR) clean
+	@$(MAKE) -C $(RESAMPLE_DIR) clean
+	@$(MAKE) -C $(PLUGIN_DIR) clean
 
 .PHONY: sip_stack
 sip_stack:
-	-@echo ""
-	-@echo "making SIP stack"
-	-@cd $(SIP_STACK_DIR); $(MAKE) all
+	@echo ""
+	@echo "making SIP stack"
+	@cd $(SIP_STACK_DIR); $(MAKE) all
 
 .PHONY: modules
 modules:
-	-@echo ""
-	-@echo "making core modules"
-	-@cd $(PLUGIN_DIR); $(MAKE) modules
+	@echo ""
+	@echo "making core modules"
+	@cd $(PLUGIN_DIR); $(MAKE) modules
 
 .PHONY: test
 test:
-	-@echo ""
-	-@echo "making tests"
-	-@cd $(TEST_DIR); $(MAKE)
+	@echo ""
+	@echo "making tests"
+	@cd $(TEST_DIR); $(MAKE)
 
 .PHONY: core
 core: $(OBJS) ../Makefile.defs
@@ -78,9 +78,9 @@ OBJS += $(RESAMPLE_DIR)/libresample.a
 
 .PHONY: resample_lib
 resample_lib:
-	-@echo ""
-	-@echo "making internal resampler"
-	-@cd $(RESAMPLE_DIR); $(MAKE) all
+	@echo ""
+	@echo "making internal resampler"
+	@cd $(RESAMPLE_DIR); $(MAKE) all
 
 else
 
@@ -110,8 +110,8 @@ endif
 	$(CXX) -MMD -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
 
 $(NAME): sip_stack resample_lib core ../Makefile.defs
-	-@echo ""
-	-@echo "making $(NAME) executable"
+	@echo ""
+	@echo "making $(NAME) executable"
 	$(LD) -o $(NAME) $(OBJS) $(LDFLAGS) $(EXTRA_LDFLAGS)
 
 
@@ -122,34 +122,34 @@ install: all mk-install-dirs \
 
 
 # note: on solaris 8 sed: ? or \(...\)* (a.s.o) do not work
-install-cfg: $(DESTDIR)$(cfg-target) $(DESTDIR)$(app-cfg-target)
-		sed -e "s#/usr/.*lib/sems/audio/#$(audio-target)#g" \
-			-e "s#/usr/.*lib/sems/plug-in/#$(modules-target)#g" \
-			-e "s#/usr/.*etc/sems/#$(cfg-target)#g" \
-			< etc/sems.conf.sample > $(DESTDIR)$(cfg-target)sems.conf.default
-		chmod 644 $(DESTDIR)$(cfg-target)sems.conf.default
-		if [ ! -f $(DESTDIR)$(cfg-target)sems.conf ]; then \
-			cp -f $(DESTDIR)$(cfg-target)sems.conf.default \
-				$(DESTDIR)$(cfg-target)sems.conf; \
+install-cfg: $(DESTDIR)$(cfg_target) $(DESTDIR)$(app_cfg_target)
+		sed -e "s#/usr/.*lib/sems/audio/#$(audio_target)#g" \
+			-e "s#/usr/.*lib/sems/plug-in/#$(modules_target)#g" \
+			-e "s#/usr/.*etc/sems/#$(cfg_target)#g" \
+			< etc/sems.conf.sample > $(DESTDIR)$(cfg_target)sems.conf.default
+		chmod 644 $(DESTDIR)$(cfg_target)sems.conf.default
+		if [ ! -f $(DESTDIR)$(cfg_target)sems.conf ]; then \
+			cp -f $(DESTDIR)$(cfg_target)sems.conf.default \
+				$(DESTDIR)$(cfg_target)sems.conf; \
 		fi
 
-		$(INSTALL-CFG) etc/app_mapping.conf.sample $(DESTDIR)$(app-cfg-target)app_mapping.conf
+		$(INSTALL_CFG) etc/app_mapping.conf.sample $(DESTDIR)$(app_cfg_target)app_mapping.conf
 
-install-bin: $(DESTDIR)$(bin-prefix)/$(bin-dir)
-		$(INSTALL-TOUCH) $(DESTDIR)$(bin-prefix)/$(bin-dir)$(NAME)
-		$(INSTALL-BIN) $(NAME) $(DESTDIR)$(bin-prefix)/$(bin-dir)
+install-bin: $(DESTDIR)$(bin_prefix)/$(bin_dir)
+		$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)$(NAME)
+		$(INSTALL_BIN) $(NAME) $(DESTDIR)$(bin_prefix)/$(bin_dir)
 
-install-modules: $(PLUGIN_DIR) $(DESTDIR)$(modules-prefix)/$(modules-dir)
+install-modules: $(PLUGIN_DIR) $(DESTDIR)$(modules_prefix)/$(modules_dir)
 	$(MAKE) -C $(PLUGIN_DIR) install
 
 install-modules-cfg: $(PLUGIN_DIR) 
 	$(MAKE) -C $(PLUGIN_DIR) install-cfg
 
-install-audio: $(DESTDIR)$(audio-prefix)/$(audio-dir)
+install-audio: $(DESTDIR)$(audio_prefix)/$(audio_dir)
 	for f in $(AUDIO_FILES) ; do \
 		if [ -n "wav/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(audio-prefix)/$(audio-dir)$$f; \
-			$(INSTALL-AUDIO) wav/$$f $(DESTDIR)$(audio-prefix)/$(audio-dir)$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(audio_prefix)/$(audio_dir)$$f; \
+			$(INSTALL_AUDIO) wav/$$f $(DESTDIR)$(audio_prefix)/$(audio_dir)$$f; \
 		fi ; \
 	done
 
--- a/core/plug-in/Makefile
+++ b/core/plug-in/Makefile
@@ -12,8 +12,9 @@ all: modules
 
 .PHONY: clean
 clean:
-	-@rm -f *.so
-	-@for r in $(core_modules) "" ; do \
+	@rm -f *.so
+	@set -e; \
+	for r in $(core_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -23,7 +24,8 @@ clean:
 
 .PHONY: modules
 modules:
-	-@for r in $(core_modules) "" ; do \
+	@set -e; \
+	for r in $(core_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo  "" ; \
 			echo  "" ; \
@@ -33,7 +35,8 @@ modules:
 
 .PHONY: install
 install:
-	-@for r in $(core_modules) "" ; do \
+	@set -e; \
+	for r in $(core_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
@@ -42,8 +45,9 @@ install:
 	done
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(cfg-target)
-	-@for r in $(core_modules) "" ; do \
+install-cfg: $(DESTDIR)$(cfg_target)
+	@set -e; \
+	for r in $(core_modules) "" ; do \
 		if [ -n "$$r" ]; then \
 			echo "" ; \
 			echo "" ; \
--- a/core/plug-in/Makefile.app_module
+++ b/core/plug-in/Makefile.app_module
@@ -34,49 +34,52 @@ module_package: $(extra_target) $(lib_na
 
 .PHONY: clean
 clean: $(extra_clean)
-	-@rm -f $(objs) $(depends) $(lib_name)
+	@rm -f $(objs) $(depends) $(lib_name)
 
 .PHONY: install
-install: all $(extra_install) $(DESTDIR)$(modules-prefix)/$(modules-dir)
+install: all $(extra_install) $(DESTDIR)$(modules_prefix)/$(modules_dir)
 	if [ -f "$(lib_name)" ]; then \
-	 $(INSTALL-TOUCH) $(DESTDIR)$(modules-prefix)/$(modules-dir)/$(lib_name) ; \
-	 $(INSTALL-MODULES) $(lib_name) $(DESTDIR)$(modules-prefix)/$(modules-dir); \
+	 $(INSTALL_TOUCH) $(DESTDIR)$(modules_prefix)/$(modules_dir)/$(lib_name) ; \
+	 $(INSTALL_MODULES) $(lib_name) $(DESTDIR)$(modules_prefix)/$(modules_dir); \
 	fi
 
 .PHONY: install-cfg
-install-cfg: $(DESTDIR)$(app-cfg-target)
-	-@for r in $(module_conf_files); do \
+install-cfg: $(DESTDIR)$(app_cfg_target)
+	@set -e; \
+	for r in $(module_conf_files); do \
 			echo installing $$r ;  \
-			$(INSTALL-TOUCH) $(DESTDIR)$(app-cfg-target)$$r ; \
-			sed -e "s#/usr/.*lib/sems/audio/#$(audio-target)#g" \
-			-e "s#/usr/.*lib/sems/plug-in/#$(modules-target)#g" \
-			-e "s#/usr/.*lib/sems/ivr/#$(lib-target)ivr/#g" \
-			-e "s#/usr/.*lib/sems/dsm/#$(lib-target)dsm/#g" \
-			-e "s#/usr/.*lib/sems/py_sems/#$(lib-target)py_sems/#g" \
-			-e "s#/usr/.*etc/sems#$(app-cfg-target)#g" \
-			< etc/$$r > $(DESTDIR)$(app-cfg-target)$$r; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(app_cfg_target)$$r ; \
+			sed -e "s#/usr/.*lib/sems/audio/#$(audio_target)#g" \
+			-e "s#/usr/.*lib/sems/plug-in/#$(modules_target)#g" \
+			-e "s#/usr/.*lib/sems/ivr/#$(lib_target)ivr/#g" \
+			-e "s#/usr/.*lib/sems/dsm/#$(lib_target)dsm/#g" \
+			-e "s#/usr/.*lib/sems/py_sems/#$(lib_target)py_sems/#g" \
+			-e "s#/usr/.*etc/sems#$(app_cfg_target)#g" \
+			< etc/$$r > $(DESTDIR)$(app_cfg_target)$$r; \
 	done
 
-$(DESTDIR)(audio-prefix)/$(audio-dir):
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)
+$(DESTDIR)$(audio_prefix)/$(audio_dir):
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)
 
 .PHONY: $(plug_in_name)_audio
-$(plug_in_name)_audio: $(DESTDIR)$(audio-prefix)/$(audio-dir)
-	mkdir -p $(DESTDIR)$(audio-prefix)/$(audio-dir)$(plug_in_name)
-	-@for f in $(AUDIO_FILES) ; do \
+$(plug_in_name)_audio: $(DESTDIR)$(audio_prefix)/$(audio_dir)
+	mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)$(plug_in_name)
+	@set -e; \
+	for f in $(AUDIO_FILES) ; do \
 		if [ -n "wav/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(audio-prefix)/$(audio-dir)$(plug_in_name)/$$f; \
-			$(INSTALL-AUDIO) wav/$$f $(DESTDIR)$(audio-prefix)/$(audio-dir)$(plug_in_name)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(audio_prefix)/$(audio_dir)$(plug_in_name)/$$f; \
+			$(INSTALL_AUDIO) wav/$$f $(DESTDIR)$(audio_prefix)/$(audio_dir)$(plug_in_name)/$$f; \
 		fi ; \
 	done
 
 .PHONY: $(plug_in_name)_lib
 $(plug_in_name)_lib: 
-	mkdir -p $(DESTDIR)$(lib-prefix)/$(lib-dir)/$(plug_in_name)
-	-@for f in $(EXTRA_LIB_FILES) ; do \
+	mkdir -p $(DESTDIR)$(lib_prefix)/$(lib_dir)/$(plug_in_name)
+	@set -e; \
+	for f in $(EXTRA_LIB_FILES) ; do \
 		if [ -n "$(EXTRA_LIB_DIR)/$$f" ]; then \
-			$(INSTALL-TOUCH) $(DESTDIR)$(lib-prefix)/$(lib-dir)/$(plug_in_name)/$$f; \
-			$(INSTALL-AUDIO) $(EXTRA_LIB_DIR)$$f $(DESTDIR)$(lib-prefix)/$(lib-dir)/$(plug_in_name)/$$f; \
+			$(INSTALL_TOUCH) $(DESTDIR)$(lib_prefix)/$(lib_dir)/$(plug_in_name)/$$f; \
+			$(INSTALL_AUDIO) $(EXTRA_LIB_DIR)$$f $(DESTDIR)$(lib_prefix)/$(lib_dir)/$(plug_in_name)/$$f; \
 		fi ; \
 	done
 
--- a/core/plug-in/Makefile.audio_module
+++ b/core/plug-in/Makefile.audio_module
@@ -32,9 +32,9 @@ clean: $(extra_clean)
 
 .PHONY: install
 install: $(lib_name) $(extra_install)
-	mkdir -p $(DESTDIR)$(modules-prefix)/$(modules-dir)
-	$(INSTALL-TOUCH) $(DESTDIR)$(modules-prefix)/$(modules-dir)/$(lib_name) ; \
-	$(INSTALL-MODULES) $(lib_name) $(DESTDIR)$(modules-prefix)/$(modules-dir)
+	mkdir -p $(DESTDIR)$(modules_prefix)/$(modules_dir)
+	$(INSTALL_TOUCH) $(DESTDIR)$(modules_prefix)/$(modules_dir)/$(lib_name) ; \
+	$(INSTALL_MODULES) $(lib_name) $(DESTDIR)$(modules_prefix)/$(modules_dir)
 
 .PHONY: install-cfg
 install-cfg : $(extra_install_cfg)
--- a/core/plug-in/gsm/gsm-1.0-pl10/Makefile
+++ b/core/plug-in/gsm/gsm-1.0-pl10/Makefile
@@ -276,32 +276,32 @@ TOAST_INSTALL_TARGETS =	\
 
 .c.o:
 		$(CC) $(CFLAGS) $?
-		@-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
+		@mv `$(BASENAME) $@` $@ > /dev/null 2>&1
 
 # Target rules
 
 all:		$(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
-		@-echo $(ROOT): Done.
+		@echo $(ROOT): Done.
 
 tst:		$(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
-		@-echo tst: Done.
+		@echo tst: Done.
 
 addtst:		$(ADDTST)/add $(ADDTST)/add_test.dta
 		$(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
-		@-echo addtst: Done.
+		@echo addtst: Done.
 
 misc:		$(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger 	\
 			$(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
-		@-echo misc: Done.
+		@echo misc: Done.
 
 install:	toastinstall gsminstall
-		@-echo install: Done.
+		@echo install: Done.
 
 
 # The basic API: libgsm
 
 $(LIBGSM):	$(LIB) $(GSM_OBJECTS)
-		-rm -f $(RMFLAGS) $(LIBGSM)
+		rm -f $(RMFLAGS) $(LIBGSM)
 		$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
 		$(RANLIB) $(LIBGSM)
 
@@ -312,11 +312,11 @@ $(TOAST):	$(BIN) $(TOAST_OBJECTS) $(LIBG
 		$(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
 
 $(UNTOAST):	$(BIN) $(TOAST)
-		-rm $(RMFLAGS) $(UNTOAST)
+		rm -f $(RMFLAGS) $(UNTOAST)
 		$(LN) $(TOAST) $(UNTOAST)
 
 $(TCAT):	$(BIN) $(TOAST)
-		-rm $(RMFLAGS) $(TCAT)
+		rm -f $(RMFLAGS) $(TCAT)
 		$(LN) $(TOAST) $(TCAT)
 
 
@@ -332,70 +332,70 @@ $(LIB):
 # Installation
 
 gsminstall:
-		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
-			make $(GSM_INSTALL_TARGETS) ;	\
+		if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
+			$(MAKE) $(GSM_INSTALL_TARGETS) ;	\
 		fi
 
 toastinstall:
-		-if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then	\
-			make $(TOAST_INSTALL_TARGETS);	\
+		if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then	\
+			$(MAKE) $(TOAST_INSTALL_TARGETS);	\
 		fi
 
 gsmuninstall:
-		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
+		if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
 			rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ;	\
 		fi
 
 toastuninstall:
-		-if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then 	\
+		if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then 	\
 			rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS);	\
 		fi
 
 $(TOAST_INSTALL_BIN)/toast:	$(TOAST)
-		-rm $@
+		rm -f $@
 		cp $(TOAST) $@
 		chmod 755 $@
 
 $(TOAST_INSTALL_BIN)/untoast:	$(TOAST_INSTALL_BIN)/toast
-		-rm $@
+		rm -f $@
 		ln $? $@
 
 $(TOAST_INSTALL_BIN)/tcat:	$(TOAST_INSTALL_BIN)/toast
-		-rm $@
+		rm -f $@
 		ln $? $@
 
 $(TOAST_INSTALL_MAN)/toast.1:	$(MAN)/toast.1
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
 $(GSM_INSTALL_MAN)/gsm.3:	$(MAN)/gsm.3
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
 $(GSM_INSTALL_MAN)/gsm_option.3:	$(MAN)/gsm_option.3
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
 $(GSM_INSTALL_MAN)/gsm_explode.3:	$(MAN)/gsm_explode.3
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
 $(GSM_INSTALL_MAN)/gsm_print.3:	$(MAN)/gsm_print.3
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
 $(GSM_INSTALL_INC)/gsm.h:	$(INC)/gsm.h
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
 $(GSM_INSTALL_LIB)/libgsm.a:	$(LIBGSM)
-		-rm $@
+		rm -f $@
 		cp $? $@
 		chmod 444 $@
 
@@ -414,17 +414,17 @@ gsm-1.0.tar.Z:	$(STUFF) $(SOURCES) $(HEA
 # Clean
 
 uninstall:	toastuninstall gsmuninstall
-		@-echo uninstall: Done.
+		@echo uninstall: Done.
 
 semi-clean:
-		-@rm -Rf $(RMFLAGS)  */*.o			\
+		@rm -Rf $(RMFLAGS)  */*.o			\
 			$(TST)/lin2cod $(TST)/lin2txt	\
 			$(TST)/cod2lin $(TST)/cod2txt	\
 			$(TST)/gsm2cod 			\
 			$(TST)/*.*.*
 
 clean:	semi-clean
-		-@rm -Rf $(RMFLAGS) $(LIBGSM) $(ADDTST)/add		\
+		@rm -Rf $(RMFLAGS) $(LIBGSM) $(ADDTST)/add		\
 			$(TOAST) $(TCAT) $(UNTOAST)	\
 			$(ROOT)/gsm-1.0.tar.Z
 
--- a/core/plug-in/ilbc/iLBC_rfc3951/Makefile
+++ b/core/plug-in/ilbc/iLBC_rfc3951/Makefile
@@ -16,7 +16,7 @@ RANLIB		= ranlib
 
 .PHONY: clean
 clean:
-	-@rm -f $(objs) $(depends) $(lib_name)
+	@rm -f $(objs) $(depends) $(lib_name)
 
 -include $(depends)
 
--- a/core/plug-in/stats/Makefile
+++ b/core/plug-in/stats/Makefile
@@ -19,9 +19,9 @@ include ../Makefile.app_module
 $(QUERY_STATS_NAME): query_stats.o Makefile
 	$(LD) -o $(QUERY_STATS_NAME) query_stats.o $(LDFLAGS) $(EXTRA_LDFLAGS) 
 
-install_query_stats: $(QUERY_STATS_NAME) $(DESTDIR)$(bin-prefix)/$(bin-dir)
-	$(INSTALL-TOUCH) $(DESTDIR)$(bin-prefix)/$(bin-dir)$(QUERY_STATS_DEST_NAME)
-	$(INSTALL-BIN) $(QUERY_STATS_NAME) $(DESTDIR)$(bin-prefix)/$(bin-dir)/$(QUERY_STATS_DEST_NAME)
+install_query_stats: $(QUERY_STATS_NAME) $(DESTDIR)$(bin_prefix)/$(bin_dir)
+	$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)$(QUERY_STATS_DEST_NAME)
+	$(INSTALL_BIN) $(QUERY_STATS_NAME) $(DESTDIR)$(bin_prefix)/$(bin_dir)/$(QUERY_STATS_DEST_NAME)
 
 clean_query_stats: 
 	rm -f $(QUERY_STATS_NAME) query_stats.o query_stats.d
--- a/core/resample/Makefile
+++ b/core/resample/Makefile
@@ -24,6 +24,6 @@ CPPFLAGS += -I$(COREPATH)
 	$(CXX) -MMD -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
 
 $(LIBNAME): $(OBJS) $(COREPATH)/../Makefile.defs
-	-@echo ""
-	-@echo "making $(LIBNAME)"
+	@echo ""
+	@echo "making $(LIBNAME)"
 	$(AR) rvs $(LIBNAME) $(OBJS)
--- a/core/sip/Makefile
+++ b/core/sip/Makefile
@@ -48,8 +48,8 @@ endif
 	$(CXX) -MMD -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
 
 $(LIBNAME): $(OBJS) $(COREPATH)/../Makefile.defs
-	-@echo ""
-	-@echo "making $(LIBNAME)"
+	@echo ""
+	@echo "making $(LIBNAME)"
 	$(AR) rvs $(LIBNAME) $(OBJS)
 
 -include $(DEPS)
--- a/core/tests/Makefile
+++ b/core/tests/Makefile
@@ -29,21 +29,21 @@ EXTRA_LDFLAGS += -lresolv -levent -leven
 
 .PHONY: all
 all: ../../Makefile.defs sip_stack libresample
-	-@$(MAKE) core_deps   && $(MAKE) sbc_deps  && $(MAKE) deps    && \
+	@$(MAKE) core_deps   && $(MAKE) sbc_deps  && $(MAKE) deps    && \
 	  $(MAKE) $(NAME) && \
 	./$(NAME)
 
 .PHONY: sip_stack
 sip_stack:
-	-@echo ""
-	-@echo "making SIP stack"
-	-@cd $(SIP_STACK_DIR); $(MAKE) all
+	@echo ""
+	@echo "making SIP stack"
+	@cd $(SIP_STACK_DIR); $(MAKE) all
 
 .PHONY: libresample
 libresample:
-	-@echo ""
-	-@echo "making libresample"
-	-@cd $(RESAMPLE_DIR); $(MAKE) all
+	@echo ""
+	@echo "making libresample"
+	@cd $(RESAMPLE_DIR); $(MAKE) all
 
 SIP_STACK: sip_stack
 
@@ -83,8 +83,8 @@ include ../../Makefile.defs
 	$(CXX) -MM $< $(CPPFLAGS) $(CXXFLAGS) > $@
 
 $(NAME): $(OBJS) $(CORE_OBJS) $(SBC_OBJS) $(AUTH_OBJS) $(SIP_STACK) $(LIBRESAMPLE) ../../Makefile.defs
-	-@echo ""
-	-@echo "making $(NAME)"
+	@echo ""
+	@echo "making $(NAME)"
 	$(LD) -o $(NAME) $(OBJS) $(CORE_OBJS) $(SBC_OBJS) $(SIP_STACK) $(LIBRESAMPLE) $(LDFLAGS) $(EXTRA_LDFLAGS) $(AUTH_OBJS)
 
 ifeq '$(NAME)' '$(MAKECMDGOALS)'
--- a/pkg/rpm/sems.spec
+++ b/pkg/rpm/sems.spec
@@ -112,16 +112,16 @@ make install TTS="y" exclude_modules="ex
 	DESTDIR=$RPM_BUILD_ROOT \
 	basedir= \
 	prefix=%{_prefix} \
-	modules-prefix= \
-        modules-dir=%{_libdir}/sems/plug-in \
-        modules-target=%{_libdir}/sems/plug-in \
-	ivr-modules-dir=%{_libdir}/sems/ivr \
-	cfg-prefix= \
-	cfg-target=%{_sysconfdir}/sems/ \
-	doc-prefix= \
-	doc-dir=%{_docdir}/sems/ \
-	audio-prefix= \
-	audio-dir=%{_libdir}/sems/audio/
+	modules_prefix= \
+	modules_dir=%{_libdir}/sems/plug-in \
+	modules_target=%{_libdir}/sems/plug-in \
+	ivr_modules_dir=%{_libdir}/sems/ivr \
+	cfg_prefix= \
+	cfg_target=%{_sysconfdir}/sems/ \
+	doc_prefix= \
+	doc_dir=%{_docdir}/sems/ \
+	audio_prefix= \
+	audio_dir=%{_libdir}/sems/audio/
 
 install -D -p -m755 pkg/rpm/sems.init $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/sems
 
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -3,18 +3,19 @@ all: make_tools
 COREPATH ?= ../core
 include $(COREPATH)/../Makefile.defs
 
-sems-tools = sems-logfile-callextract
+sems_tools = sems-logfile-callextract
 
-install: $(sems-tools) install_tools
+install: $(sems_tools) install_tools
 
-make_tools: $(sems-tools)
+make_tools: $(sems_tools)
 
-install_tools: $(DESTDIR)$(bin-prefix)/$(bin-dir)
-	-@for r in $(sems-tools)  ; do \
+install_tools: $(DESTDIR)$(bin_prefix)/$(bin_dir)
+	@set -e; \
+	for r in $(sems_tools)  ; do \
 		x=`echo $$r | sed s/sems-/$(APP_NAME)-/g` ; \
 		echo "installing $$r -> $$x" ; \
-		$(INSTALL-TOUCH) $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
-		$(INSTALL-BIN) $$r $(DESTDIR)$(bin-prefix)/$(bin-dir)/$$x ; \
+		$(INSTALL_TOUCH) $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
+		$(INSTALL_BIN) $$r $(DESTDIR)$(bin_prefix)/$(bin_dir)/$$x ; \
 	done
 
 sems-logfile-callextract: logfile-splitter.o
