File: depmod.sh

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (56 lines) | stat: -rwxr-xr-x 1,471 bytes parent folder | download | duplicates (5)
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
#! /bin/sh

# Usage: depmod.sh module_name libraries sources ...

# Generate dependencies and rules for building dynamically loaded modules
# under Unices.


modname=$1
modlibs=$2
shift; shift

sources=$*
objects=`echo $sources | sed 's,[^	 ]*/,,g;s,\.[^.	 ]*,,g'`

MODNAME=`echo $modname | tr a-z A-Z`

module="alleg-${modname}.so"
objlist="MODULE_${MODNAME}_OBJECTS"


# object list
prev="$objlist ="
for file in .. $objects; do
  if test "$file" != ..; then
    echo "$prev \\"
    prev="  \$(OBJDIR)/module/$file\$(OBJ)"
  fi
done
echo "$prev"
echo ""

# module rule
echo "\$(LIBDIR)/$module: \$(${objlist})"
if test "$modlibs" = "--"; then
   echo "	\$(CC) -shared \$(ALLEGRO_SHAREDLIB_CFLAGS) -o \$@ \$(${objlist}) \$(LDFLAGS)"
else
   echo "	\$(CC) -shared \$(ALLEGRO_SHAREDLIB_CFLAGS) -o \$@ \$(${objlist}) \$(LDFLAGS) $modlibs"
fi
echo ""

# explicit object rules (pass -DALLEGRO_MODULE)
for file in .. $sources; do
  if test "$file" != ..; then
    name=`echo $file | sed 's,^.*/,,;s,\.[^.]*$,,'`
    ext=`echo $file | sed 's,^.*\.,,'`
    echo "\$(OBJDIR)/module/$name\$(OBJ): \$(srcdir)/$file \$(obj_unix_asmdef_inc)"
    if test "$ext" = "c"; then
      echo "	\$(COMPILE_NORMAL) \$(ALLEGRO_SHAREDLIB_CFLAGS) -DALLEGRO_MODULE -c \$(srcdir)/$file -o \$(OBJDIR)/module/$name\$(OBJ)"
    else
      echo "	\$(COMPILE_S_NORMAL) \$(ALLEGRO_SHAREDLIB_CFLAGS) -DALLEGRO_MODULE -c \$(srcdir)/$file -o \$(OBJDIR)/module/$name\$(OBJ)"
    fi
  fi
done
echo ""
echo ""