Fix fname and dname calculation. Refactor code.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 13 Jan 2010 22:29:54 +0200
changeset 14 ebe743b087ae
parent 13 9e590e7ef108
child 15 a261abd34f1b
Fix fname and dname calculation. Refactor code.
Makefile
--- a/Makefile	Wed Jan 13 22:09:26 2010 +0200
+++ b/Makefile	Wed Jan 13 22:29:54 2010 +0200
@@ -20,19 +20,20 @@
   DIRS = all linux
 endif
 ifeq 'windows' '$(host_os)'
-  DIRS = all win
+  DIRS = all
+  # DIRS += win
 endif
 
 .PHONY: install
 install:
 	for srcdir in $(DIRS); do \
-		for item in `cd  $$srcdir; find $$PWD -type f`; do \
-			file=$${item#$${PWD}/$${srcdir}/}; \
+		prefix=$$PWD/$$srcdir; \
+		for item in `find $$prefix -type f`; do \
 			fname=$${item##*/}; \
-			dir=$${item#$${PWD}/$${srcdir}}; \
-			dir=$${dir%/$${fname}}; \
-			dir=$${dir#/}; \
-			echo mkdir -p $(HOME)/$$dir; \
+			file=$${item#$${prefix}/}; \
+			dir=$${file%$${fname}}; \
+			dir=$${dir%/}; \
+			echo [ -n $$dir ] '&&' mkdir -p $(HOME)/$$dir; \
 			echo install -m 660 $$srcdir/$$file $(HOME)/$$dir; \
 		done; \
 	done