#!/bin/sh
#
# Create a modlist.h from a list of dirs with modules
#

fullnames=`cat $1`

dirs=
for dir in $fullnames
do
  dir="`echo $dir|sed 's,^.*/\([^/]*\)$,\1,'`"  # Portable (?) basename
  dirs="$dirs $dir"
done

for a in $dirs
do
  echo "void init_"$a"_efuns(void);"
  echo "void init_"$a"_programs(void);"
  echo "void exit_"$a"(void);"
done
echo ""

echo "struct module module_list [] = {"

echo "  { \"main\", init_main_efuns, init_main_programs, exit_main, 0 }"
for a in $dirs
do
  echo " ,{ \"$a\", init_"$a"_efuns, init_"$a"_programs, exit_$a, 0 }"
done
echo "};"
