forked from residualvm/residualvm-tools
/
makegen
44 lines (36 loc) · 919 Bytes
/
makegen
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
#!/bin/sh
srcdir=`dirname $0`
builddir=`pwd`
rm -f $builddir/Makefile.modules
touch $builddir/Makefile.modules
MODULE="."
add_subdirectory() {
MODULE="$MODULE/$1"
. $srcdir/$MODULE/module.mg
MODULE="${MODULE%/$1}"
}
add_executable() {
echo -n "$1_SOURCES := " >> $builddir/Makefile.modules
for f in $2; do
echo -n "$MODULE/$f " >> $builddir/Makefile.modules
done
echo >> $builddir/Makefile.modules
echo -e \
"build: $1
$1_DIRS := \$(sort \$(dir \$($1_SOURCES)))
$1_dirs:
\$(QUIET)\$(MKDIR) \$($1_DIRS)
$1: $1_dirs \$($1_SOURCES)
\$(QUIET)\$(MKDIR) \$(DEPDIR)
\$(QUIET_CXX)\$(CXX) \$(LDFLAGS) $3 \$(DEFINES) -I. -I\$(srcdir) \
\$(filter %.cpp %.o, $+) -o \$@\$(EXEEXT)
EXECUTABLES += $1\$(EXEEXT)
clean: clean/$1
clean/$1:
\$(QUIET)\$(RM) \$($1_SOURCES) $1
\$(RMDIR) \$($1_DIRS) \n" >> $builddir/Makefile.modules
}
add_in_group() {
echo "$2: $1" >> $builddir/Makefile.modules
}
. $srcdir/root.mg