forked from dosemu2/dosemu2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkpluginhooks
executable file
·147 lines (135 loc) · 3.32 KB
/
mkpluginhooks
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#! /bin/sh
HEADERS="config"
TOP=`dirname $0`
PLUG=plugin
SRCDIR=`realpath $TOP/src/$PLUG`
DESTDIR=src/$PLUG
INC=$DESTDIR/include
PREF=plugin_
CONF=config
CONFIGURE=configure.ac
LIB=plugin_libdirs
PINC=plugin_incdirs
PCONF=plugin_configure
PDIRS="$(cd $SRCDIR; find . -maxdepth 1 ! -name include ! -path . -type d -exec basename {} \; | LC_ALL=C sort)"
gendummy() {
for i in $HEADERS; do
if [ "$1" = "clean" ]; then
rm -f $INC/$PREF$i.h
else
echo -n "" >$INC/$PREF$i.h
fi
done
}
if [ "$1" = 'enable' ]; then
shift
dir=$1
on=$2
shift
shift
req_on=$on
if [ "$on" = "yes" -a -f $SRCDIR/$dir/$CONFIGURE ]; then
wd=`pwd`
[ -d $DESTDIR/$dir ] || mkdir -p $DESTDIR/$dir
cd $DESTDIR/$dir
[ -f $CONFIGURE ] || ln -s $SRCDIR/$dir/$CONFIGURE $CONFIGURE
[ -f Makefile.conf.in ] || [ ! -f $SRCDIR/$dir/Makefile.conf.in ] || ln -s $SRCDIR/$dir/Makefile.conf.in Makefile.conf.in
echo "=== configuring in $dir"
trap "echo ; exit 130" INT
if [ ! -f ./configure ] && ! autoreconf -v ; then
on="no"
fi
if [ ! -f ./configure ]; then
on="no"
else
if ! ./configure ; then
echo "Configuration for $dir failed, disabling"
on="no"
fi
fi
trap - INT
cd $wd
fi
if test -d $SRCDIR/$dir ; then
mkdir -p $DESTDIR/$dir/config
echo $on > $DESTDIR/$dir/config/plugin_enable
fi
if [ "$req_on" != "$on" ]; then
exit 1
fi
exit 0
fi
if [ "$1" = "" -o "$1" = "clean" ]; then
gendummy clean
rm -f $LIB $PINC $PCONF
rm -rf $INC
fi
if [ "$1" = "clean" ]; then
rm -f $DESTDIR/*/config/plugin_enable
exit 0
fi
mkdir -p $INC
if [ "$1" = "" ]; then gendummy; fi
if [ ! -d $SRCDIR ]; then
exit 1
fi
if [ "$PDIRS" != " " ]; then
if [ "$1" = "" ]; then rm -f $LIB; fi
for d in $PDIRS; do
# Test if this plugin is enabled
if [ -f $DESTDIR/$d/$CONF/${PREF}enable ] && \
[ -f $SRCDIR/$d/Makefile ] && ([ ! -f $SRCDIR/$d/configure.ac ] || \
[ -f $SRCDIR/$d/configure ]); then
enable=`cat $DESTDIR/$d/$CONF/${PREF}enable`
else
enable=no
fi
# Plugin configure directories
if [ -f $SRCDIR/$d/$CONFIGURE ]; then
echo -n " $DESTDIR/$d" >> $PCONF
fi
if [ "$enable" = "yes" ]; then
if [ "$1" = "" ]; then
# Plugin library direcories
if [ -f $SRCDIR/$d/$CONF/${PREF}dirs ]; then
for i in `cat $SRCDIR/$d/$CONF/${PREF}dirs`; do
if [ "$i" = "./" ]; then
echo -n " $PLUG/$d" >>$LIB
else
echo -n " $PLUG/$d/$i" >>$LIB
fi
done
else
echo -n " $PLUG/$d" >>$LIB
fi
# Plugin include directories
if [ -f $SRCDIR/$d/$CONF/${PREF}incdirs ]; then
for i in `cat $SRCDIR/$d/$CONF/${PREF}incdirs`; do
if [ "$i" = "./" ]; then
echo -n " $PLUG/$d" >>$PINC
else
echo -n " $PLUG/$d/$i" >>$PINC
fi
done
fi
# Plugin special headers...
for h in $HEADERS; do
if [ -f $SRCDIR/$d/$CONF/$PREF$h.h ]; then
echo "#include \"../$PLUG/$d/$CONF/$PREF$h.h\"" >>$INC/$PREF$h.h
fi
done
fi
fi
done
if [ "$1" = "" ]; then
if [ -f $LIB ]; then
echo "" >>$LIB
fi
if [ -f $PINC ]; then
echo "" >>$PINC
fi
if [ -f $PCONF ]; then
echo "" >>$PCONF
fi
fi
fi