File: mkpluginhooks

package info (click to toggle)
dosemu 1.4.0+svn.1999-2
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 15,552 kB
  • ctags: 22,600
  • sloc: ansic: 136,915; asm: 4,107; sh: 1,606; perl: 1,411; makefile: 974; tcl: 599; awk: 404; yacc: 300; lex: 157
file content (175 lines) | stat: -rwxr-xr-x 4,608 bytes parent folder | download | duplicates (7)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#! /bin/bash

HEADERS="config init close inte6 poll"

TOP=`dirname $0`
PLUG=plugin
SRCDIR=$TOP/src/$PLUG
DESTDIR=src/$PLUG
INC=$DESTDIR/include
PREF=plugin_
CONF=config
CONFIGURE=configure
LIB=plugin_libdirs
PINC=plugin_incdirs
PCONF=plugin_configure
PARSDIR=src/base/init

PDIRS=`cd $SRCDIR; find ./ -maxdepth 1 ! -name include -type d -printf ' %f'`

function 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
}

function restore_enable {
  if [ "$PDIRS" != " " ]; then
    for d in $PDIRS; do
      if [ -f $SRCDIR/$d/$CONF/${PREF}enable ]; then
        if [ "`cat $DESTDIR/$d/$CONF/${PREF}enable`" = "replaced" ]; then
          echo "yes" >$DESTDIR/$d/$CONF/${PREF}enable
        fi
      fi
    done
  fi
}

if [ "$1" = 'enable' ]; then
	shift 
	while [ $# -ge 2 ]; do
		dir=$1
		on=$2
		shift
		shift
		if test -d $SRCDIR/$dir ; then
			mkdir -p $DESTDIR/$dir/config
			echo $on > $DESTDIR/$dir/config/plugin_enable
		fi
	done
	exit 0
fi

if [ "$1" = "" -o "$1" = "clean" ]; then
  gendummy clean
  restore_enable
  rm -f $LIB $PINC $PCONF $PARSDIR/parser.y $PARSDIR/lexer.l
  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
mkdir -p $PARSDIR
if [ "$1" = "" -o "$1" = "parser" ]; then cp -fp $TOP/$PARSDIR/parser.y.in $PARSDIR/parser.y; fi
if [ "$1" = "" -o "$1" = "lexer" ]; then cp -fp $TOP/$PARSDIR/lexer.l.in $PARSDIR/lexer.l; fi

if [ ! -d $SRCDIR ]; then
  exit 1
fi


if [ "$PDIRS" != " " ]; then

  # Check for plugins which override default ones.
  # Overriding plugins will disable the clashing plugin
  if [ "$1" = "" ]; then for d in $PDIRS; do
    if [ -f $DESTDIR/$d/$CONF/${PREF}enable ]; then
     if [ "`cat $DESTDIR/$d/$CONF/${PREF}enable`" = "yes" ]; then
      if [ -f $SRCDIR/$d/$CONF/${PREF}override ]; then
        for oplugin in `cat $SRCDIR/$d/$CONF/${PREF}override`; do
          if [ "$oplugin" != "" -a -d $DESTDIR/$oplugin ]; then
            if [ -f $DESTDIR/$oplugin/$CONF/${PREF}enable ]; then
              if [ "`cat $DESTDIR/$oplugin/$CONF/${PREF}enable`" = "yes" ]; then
                echo "replaced" >$DESTDIR/$oplugin/$CONF/${PREF}enable
              fi
            fi
          fi
        done
      fi
     fi
    fi
  done fi

  # ok, now we are safe

  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 ]; then
      enable=`cat $DESTDIR/$d/$CONF/${PREF}enable`
    else
      enable=no
    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 configure directories
        if [ -f $SRCDIR/$d/$CONFIGURE ]; then
          echo -n " $DESTDIR/$d" >> $PCONF
        fi
        # Plugin special headers...
        for h in $HEADERS; do
          if [ -f $SRCDIR/$d/$CONF/$PREF$h.h ]; then
            echo -E "#include \"../$PLUG/$d/$CONF/$PREF$h.h\"" >>$INC/$PREF$h.h
          fi
        done
      fi
      # Plugin parsers parts
      if [ "$1" = "" -o "$1" = "parser" ]; then
        if [ -f $SRCDIR/$d/$CONF/${PREF}parser ]; then
          $TOP/bisonpp.pl -y $PARSDIR/parser.y $SRCDIR/$d/$CONF/${PREF}parser >$PARSDIR/parser.y.tmp
          mv -f $PARSDIR/parser.y.tmp $PARSDIR/parser.y
        fi
      fi
      # Plugin lexer parts
      if [ "$1" = "" -o "$1" = "lexer" ]; then
        if [ -f $SRCDIR/$d/$CONF/${PREF}lexer ]; then
          $TOP/bisonpp.pl -l $PARSDIR/lexer.l $SRCDIR/$d/$CONF/${PREF}lexer >$PARSDIR/lexer.l.tmp
          mv -f $PARSDIR/lexer.l.tmp $PARSDIR/lexer.l
        fi
      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