Added startup section to library .conf file. Code in this section will be
[AROS.git] / tools / genmodule / writeautoinit.c
blob9f061a3d7a79f5453aa4598536778120a311932b
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 Function to write module_autoinit.c. Part of genmodule.
6 */
7 #include "genmodule.h"
9 void writeautoinit(struct config *cfg)
11 FILE *out;
12 char line[256], *banner;
13 struct stringlist *linelistit;
15 snprintf(line, 255, "%s/%s_autoinit.c", cfg->gendir, cfg->modulename);
16 out = fopen(line, "w");
18 if (out==NULL)
20 perror(line);
21 exit(20);
24 banner = getBanner(cfg);
25 fprintf(out,
26 "%s"
27 "\n"
28 "#include <proto/%s.h>\n"
29 "#include <aros/symbolsets.h>\n"
30 "\n"
31 "ADD2LIBS((CONST_STRPTR)\"%s.library\",%u, %s, %s);\n",
32 banner, cfg->modulename,
33 cfg->modulename, cfg->majorversion, cfg->libbasetypeptrextern, cfg->libbase
35 freeBanner(banner);
37 /* Write the code to be added to startup provided in the config file */
38 for (linelistit = cfg->startuplines; linelistit != NULL; linelistit = linelistit->next)
40 fprintf(out, "%s\n", linelistit->s);
43 if (cfg->forcelist!=NULL)
45 struct stringlist * forcelistit;
47 fprintf(out, "\n");
48 for (forcelistit = cfg->forcelist;
49 forcelistit!=NULL;
50 forcelistit = forcelistit->next
53 fprintf(out, "extern struct Library *%s;\n", forcelistit->s);
55 fprintf(out, "\nvoid __%s_forcelibs(void)\n{\n", cfg->modulename);
56 for (forcelistit = cfg->forcelist;
57 forcelistit!=NULL;
58 forcelistit = forcelistit->next
61 fprintf(out, " %s = NULL;\n", forcelistit->s);
63 fprintf(out, "}\n");
65 fclose(out);