-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkapp
executable file
·37 lines (31 loc) · 1.02 KB
/
mkapp
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
#!/usr/bin/env bash
export M4_APP_DIR=$1
export APP_DIR=$2
function copy_and_expand () {
IN=$1;
OUT=$2;
## any environment variable beginning with POOTPOOT gets
## automatically propagated into an m4 macro
DEFINES=""
for key in `env | grep ^POOTPOOT | sed -e 's/=.*//'`; do
value=`env | grep ^${key} | sed -e 's/[^=]*=//'`
DEFINES="$DEFINES --define=${key}=${value}"
done
## the m4 rules:
## . files named *.m4 are ignored
## . files named *.*.m4 are expanded as *.*
for path in `(cd $IN; ls -1 | grep '\..*\.m4$')`; do
outpath=`echo $path | sed -e 's/\.m4$//'`
m4 $DEFINES -E -I $IN -P $IN/$path > $OUT/$outpath
done
for path in `(cd $IN; ls -1 | grep -v '\.m4$')`; do
if [ -f $IN/$path ]; then
cp $IN/$path $OUT/$path
fi
done
}
for in_dir in `find $M4_APP_DIR -type d | sed -e "s/${M4_APP_DIR}/./"`; do
out_dir="${APP_DIR}/${in_dir}"
mkdir -p ${out_dir}
copy_and_expand "${M4_APP_DIR}/$in_dir" $out_dir
done