#!/bin/rc

cat <<!
/* Module configuration */

/* This file contains the table of built-in modules.
   See init_builtin() in import.c. */

#include "Python.h"
!

cat $1 | awk '!/^#/ && NF>0 {if(NF==1) fn="init" $1; else fn=$2; printf("extern void %s(void);\n", fn);}' 

cat <<!

/* Moroo */
extern void init_random(void);
extern void initpyexpat(void);
/* Moroo End */
extern void PyMarshal_Init(void);
extern void initimp(void);
extern void initgc(void);
extern void init_plan9(void);

struct _inittab _PyImport_Inittab[] = {

!

cat $1 | awk '!/^#/ && NF>0 {if(NF==1) fn="init" $1; else fn=$2; printf("\t{\"%s\", %s},\n", $1, fn);}'

cat <<!

	/* This module lives in marshal.c */
	{"marshal", PyMarshal_Init},

	/* This lives in import.c */
	{"imp", initimp},

	/* Moroo
	This module lives in pyexpat.c */
	{"pyexpat", initpyexpat},

	/* These entries are here for sys.builtin_module_names */
	{"__main__", NULL},
	{"__builtin__", NULL},
	{"_plan9", init_plan9},
	{"sys", NULL},
	{"exceptions", NULL},

#ifdef WITH_CYCLE_GC
	/* This lives in gcmodule.c */
	{"gc", initgc},
#endif

	/* Sentinel */
	{0, 0}
};
!
