aboutsummaryrefslogtreecommitdiff
path: root/packages/linux_make/generate_install_makefile.bash
blob: 3ef8a519fcff7bef89f0d9256241038840c6a8be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash

ROOT_DIR=`echo $1 | sed 's|/*$||'`
prefix=$2

if [ $# -ne 1 ]; then
	 echo "Usage: $0 ROOT_DIR"
	 exit;
fi

SED=`echo sed "s|${ROOT_DIR}/||"`

function print_file ()
{
	 local my_file=$1
	 echo -e "\tinstall -p '$my_file' '\$(prefix)/$my_file'"
}

function print_dir ()
{
	 echo -e "\tinstall -d -m0755 '\$(prefix)/$1'"
}

function traverse_install_tree ()
{
	 for file in `\ls -1d $1/*`; do
		  local target=`echo $file | $SED`
		  if [ -d "$file" ]; then
				print_dir "$target"
				traverse_install_tree "$file"
		  elif [ -f "$file" ]; then
				print_file "$target"
#		  else
#				echo "MYSTERY FILE: $file"
		  fi
	 done
}

function remove_file () 
{
# arg, $n-help.pd causes lots of problems
#	 local my_file=`echo $1 | sed 's|$|\\$|g'`
	 local my_file=$1
	 echo -e "\trm -f -- '\$(prefix)/$my_file'"
}

function remove_dir ()
{
	 echo -e "\t-rmdir '\$(prefix)/$1'"
}

function uninstall_tree ()
{
	 for file in `\ls -1d $1/*`; do
		  local target=`echo $file | $SED`
		  if [ -d "$file" ]; then
				uninstall_tree "$file"
				remove_dir "$target"
		  elif [ -f "$file" ]; then
				remove_file "$target"
#		  else
#				echo "MYSTERY FILE: $file"
		  fi
	 done
}


echo ""
echo "prefix = /usr/local"
echo ""
echo "default:"
echo -e "\t@echo 'you have to run \"make install\" to install Pd-extended'"
echo ""
echo "install:"
traverse_install_tree $ROOT_DIR

echo ""
echo ""
echo ""
echo "uninstall:"
uninstall_tree $ROOT_DIR