tools/genmodule: Added .unusedlibbase option
[AROS.git] / tools / genmodule / writeincproto.c
blob450f8324fa2ca941800c1ac366cf3fde1529c4fc
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
4 Desc: Function to write proto/modulename(_rel).h. Part of genmodule.
5 */
6 #include "genmodule.h"
8 void writeincproto(struct config *cfg, int is_rel)
10 FILE *out;
11 char line[256], define[256], *banner;
12 struct linelist *linelistit;
14 snprintf(line, 255, "%s/proto/%s%s.h",
15 cfg->gendir, cfg->modulename, is_rel ? "_rel" : ""
17 out = fopen(line, "w");
19 if (out == NULL)
21 perror(line);
22 exit(20);
25 banner = getBanner(cfg);
26 fprintf(out,
27 "#ifndef PROTO_%s%s_H\n"
28 "#define PROTO_%s%s_H\n"
29 "\n"
30 "%s"
31 "\n"
32 , cfg->modulenameupper, is_rel ? "_REL" : ""
33 , cfg->modulenameupper, is_rel ? "_REL" : ""
34 , banner
36 if (!is_rel)
37 fprintf(out,
38 "#ifdef __%s_RELLIBBASE__\n"
39 "#include <proto/%s_rel.h>\n"
40 "#else /* !__%s_RELLIBBASE__ */\n"
41 , cfg->modulenameupper
42 , cfg->modulename
43 , cfg->modulenameupper
45 fprintf(out,
46 "#include <exec/types.h>\n"
47 "#include <aros/system.h>\n"
48 "\n"
49 "#include <clib/%s_protos.h>\n"
50 "\n",
51 cfg->modulename
53 freeBanner(banner);
54 if (!is_rel)
56 fprintf(out,
57 "#if !defined(%s) && !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
58 " #ifdef __%s_STDLIBBASE__\n"
59 " extern struct Library *%s;\n"
60 " #else\n"
61 " extern %s%s;\n"
62 " #endif\n"
63 "#endif\n"
64 "\n",
65 cfg->libbase, cfg->modulenameupper,
66 cfg->modulenameupper,
67 cfg->libbase,
68 cfg->libbasetypeptrextern, cfg->libbase
71 else /* is_rel */
73 fprintf(out,
74 "#if !defined(%s) && !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
75 "#ifndef __aros_getbase\n"
76 " void *__aros_getbase(void);\n"
77 "#endif\n"
78 " extern const IPTR __aros_rellib_offset_%s;\n"
79 "#define AROS_RELLIB_BASE_%s __aros_rellib_base_%s\n"
80 "#define AROS_RELLIB_OFFSET_%s __aros_rellib_offset_%s\n"
81 "#endif\n"
82 "\n",
83 cfg->libbase, cfg->modulenameupper,
84 cfg->libbase,
85 cfg->modulenameupper, cfg->libbase,
86 cfg->modulenameupper, cfg->libbase
90 // define name must not start with a digit
91 // this solves a problem with proto/8svx.h
92 if (isdigit(cfg->modulenameupper[0]))
94 snprintf(define, sizeof define, "X%s", cfg->modulenameupper);
96 else
98 strncpy(define, cfg->modulenameupper, sizeof define);
101 if (!is_rel)
103 fprintf(out,
104 "#if !defined(NOLIBINLINE) && !defined(%s_NOLIBINLINE)\n"
105 "# include <inline/%s%s.h>\n",
106 define, cfg->modulename
107 , (is_rel) ? "_rel" : ""
111 fprintf(out,
112 "#%sif !defined(NOLIBDEFINES) && !defined(%s_NOLIBDEFINES)\n"
113 "# include <defines/%s%s.h>\n"
114 "#endif\n"
115 "\n",
116 (is_rel) ? "" : "el",
117 define, cfg->modulename
118 , (is_rel) ? "_rel" : ""
120 if (!is_rel)
121 fprintf(out,
122 "#endif /* !__%s_RELLIBBASE__ */\n"
123 , cfg->modulenameupper
125 fprintf(out,
126 "#endif /* PROTO_%s_H */\n",
127 cfg->modulenameupper
129 fclose(out);