summaryrefslogtreecommitdiffstats
path: root/libtoprammer/fpga/src/create.sh
blob: 7c8214cbfc1e4b8c0146b41317c1eaa6ba1884b3 (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
#!/bin/sh
# Create source template
# Copyright (c) 2010-2012 Michael Buesch <m@bues.ch>
# Licensed under the GNU/GPL v2+

basedir="$(dirname "$0")"
[ "$(echo -n "$basedir" | cut -c1)" = "/" ] || basedir="$PWD/$basedir"

template="$basedir/template"

set -e

usage()
{
	echo "Usage: create.sh TARGET_NAME"
}

[ $# -eq 1 ] || {
	usage
	exit 1
}
name="$1"

target="$basedir/$name"

mkdir -p "$target"
for file in $(ls "$template"); do
	suffix="$(echo "$file" | cut -d. -f2)"
	targetfile="$name.$suffix"
	[ "$file" = "Makefile" ] && targetfile="$file"
	cat "$template/$file" |\
		sed -e 's/template/'"$name"'/' > "$target/$targetfile"
done

exit 0
bues.ch cgit interface