Merge in THRIFT-784 and THRIFT-646

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/branches/0.3.0@946261 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/erl/Makefile.am b/lib/erl/Makefile.am
index ee8fbff..33761a1 100644
--- a/lib/erl/Makefile.am
+++ b/lib/erl/Makefile.am
@@ -17,9 +17,6 @@
 # under the License.
 #
 
-# directory where erlang library code should live
-ERL_LIB_ROOT_DIR=$(shell erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell)
-
 MODULES = \
 	src
 
@@ -28,30 +25,20 @@
 		(cd $$dir; ${MAKE} $@); \
 	done
 
-ERLLIBDIR=$(DESTDIR)$(ERL_LIB_ROOT_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
-
 install: all
-	mkdir -p $(ERLLIBDIR) ; \
-	mkdir -p $(ERLLIBDIR)/ebin ; \
-	mkdir -p $(ERLLIBDIR)/include ; \
-	mkdir -p $(ERLLIBDIR)/src ; \
-	for i in ebin/*.app*   ; do $(INSTALL) $$i $(ERLLIBDIR)/$$i ; done ; \
-	for i in ebin/*.beam   ; do $(INSTALL) $$i $(ERLLIBDIR)/$$i ; done ; \
-	for i in include/*.hrl ; do $(INSTALL) $$i $(ERLLIBDIR)/$$i ; done ; \
-	for i in src/*.erl     ; do $(INSTALL) $$i $(ERLLIBDIR)/$$i ; done
+	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift) ; \
+	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/ebin ; \
+	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/include ; \
+	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/src ; \
+	for p in ebin/*.app* ebin/*.beam include/*.hrl src/*.erl ; \
+		do $(INSTALL) $$p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/$$p ; \
+	done
 
 uninstall:
-	rm -rf $(ERLLIBDIR)
+	rm -rf $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)
 
-check: all
 
-distclean: clean
-
-# Hack to make "make dist" work.
-# This should not work, but it appears to.
-distdir:
+maintainer-clean-local:
+	rm -rf ebin
 
 MAINTAINERCLEANFILES = Makefile.in
-
-maintainer-clean:
-	test ! -d ebin || rm -rf ebin