shithub: riscv

ref: 414d29e98f8d5242cc68161e61b66b7171e96634
dir: /sys/src/cmd/python/mkconfig/

View raw version
#!/bin/rc

cat <<!
/* Module configuration */

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

#include "Python.h"
!

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

cat <<!

extern void PyMarshal_Init(void);
extern void initimp(void);
extern void initgc(void);
extern void init_ast(void);
extern void init_types(void);

struct _inittab _PyImport_Inittab[] = {

!

cat $* | 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},

	/* This lives in Python/Python-ast.c */
	{"_ast", init_ast},

	/* This lives in Python/_types.c */
	{"_types", init_types},

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

	/* This lives in gcmodule.c */
	{"gc", initgc},

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