From 2e1d779805d8baf84ab8816a24fc3964f37e4c9c Mon Sep 17 00:00:00 2001
From: Florian Franzmann <siflfran@hawo.stw.uni-erlangen.de>
Date: Thu, 20 Mar 2014 12:11:24 +0000
Subject: [PATCH 1/2] clean up the Makefile

- don't hardcode the installation path, make it settable from the
  outside
- don't hardcode $(CC) and $(LD)
- make the %.o: %c and %.so: %.o rules less verbose
- remove redundant rules
- don't install all .so files, install the built libraries
- mark install, all and clean as phony
---
 Makefile | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 9d92efb..78a76ea 100644
--- a/Makefile
+++ b/Makefile
@@ -1,40 +1,36 @@
-INSTALL_PLUGINS_DIR	=	/usr/local/lib/ladspa/
-
-CC		=	gcc
-LD		= ld
+INSTALL_PLUGINS_DIR	?=	/usr/local/lib/ladspa/
 
 # rt 31.5.2013: got rid of sse2 stuff so we can build for ARM
 CFLAGS		=	-I. -Ofast -Wall -fomit-frame-pointer -ffast-math -fstrength-reduce -funroll-loops -c -fPIC -DPIC
 LDFLAGS		= -shared
 
 PLUGINS		=	RTallpass1.so \
-      RTallpass2.so \
-			RTlowpass.so \
-			RThighpass.so \
-			RThighshelf.so \
-			RTlowshelf.so \
-		  RTlr4hipass.so \
-			RTlr4lowpass.so \
-		  RTparaeq.so \
+				RTallpass2.so \
+				RTlowpass.so \
+				RThighpass.so \
+				RThighshelf.so \
+				RTlowshelf.so \
+				RTlr4hipass.so \
+				RTlr4lowpass.so \
+				RTparaeq.so \
 
 all: $(PLUGINS)
 
 %.o: %.c
-	$(CC) $(CFLAGS) -o $@ $<
+	@echo -e "(CC) $@"
+	@$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
 %.so: %.o
-	$(LD) $(LDFLAGS) -o $@ $<
-
-install: targets
-	test -d $(INSTALL_PLUGINS_DIR) || mkdir $(INSTALL_PLUGINS_DIR)
-	cp *.so $(INSTALL_PLUGINS_DIR)
-
-targets:	$(PLUGINS)
+	@echo -e "(LD) $@"
+	@$(LD) $(LDFLAGS) -o $@ $<
 
-always:	
+install: all
+	mkdir -p $(INSTALL_PLUGINS_DIR)
+	install -m644 $(PLUGINS) $(INSTALL_PLUGINS_DIR)
 
 clean:
 	-rm -f `find . -name "*.so"`
 	-rm -f `find . -name "*.o"`
 	-rm -f `find . -name "*~"`
 
+.PHONY: install all clean
-- 
1.9.0

