attempt to register additional cores
[AROS.git] / tools / genmodule / writeincproto.c
blobf7113e7c6f8c42d2db98d366a003e2b02b726efd
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
4 Desc: Function to write proto/modulename(_rel).h. Part of genmodule.
5 */
7 #include "genmodule.h"
9 void writeincproto(struct config *cfg)
11 FILE *out;
12 char line[256], define[256], *banner;
13 struct linelist *linelistit;
15 snprintf(line, 255, "%s/proto/%s.h",
16 cfg->gendir, cfg->includename
18 out = fopen(line, "w");
20 if (out == NULL)
22 perror(line);
23 exit(20);
26 banner = getBanner(cfg);
27 fprintf(out,
28 "#ifndef PROTO_%s_H\n"
29 "#define PROTO_%s_H\n"
30 "\n"
31 "%s"
32 "\n"
33 , cfg->includenameupper
34 , cfg->includenameupper
35 , banner
37 fprintf(out,
38 "#include <exec/types.h>\n"
39 "%s"
40 "#include <aros/system.h>\n"
41 "\n"
42 "#include <clib/%s_protos.h>\n"
43 "\n",
44 (cfg->modtype == DEVICE) ? "#include <exec/devices.h>\n" : "",
45 cfg->includename
47 freeBanner(banner);
48 if (!(cfg->options & OPTION_DUPBASE))
50 /* If single libbase store libbase in global variable.
51 This is here to be legacy compliant for code that expects this
52 global libbase. If that would not be needed we could always use
53 __aros_getbase_ModName() to access libbase
55 fprintf(out,
56 "#ifndef __%s_RELLIBBASE__\n"
57 " #if !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
58 " #if !defined(%s)\n"
59 " #ifdef __%s_STDLIBBASE__\n"
60 " extern struct Library *%s;\n"
61 " #else\n"
62 " extern %s%s;\n"
63 " #endif\n"
64 " #endif\n"
65 " #endif\n"
66 " #ifndef __aros_getbase_%s\n"
67 " #define __aros_getbase_%s() (%s)\n"
68 " #endif\n"
69 "#else /* __%s_RELLIBASE__ */\n"
70 " extern const IPTR __aros_rellib_offset_%s;\n"
71 " #define AROS_RELLIB_OFFSET_%s __aros_rellib_offset_%s\n"
72 " #define AROS_RELLIB_BASE_%s __aros_rellib_base_%s\n"
73 " #ifndef __aros_getbase_%s\n"
74 " #ifndef __aros_getoffsettable\n"
75 " char *__aros_getoffsettable(void);\n"
76 " #endif\n"
77 " #define __aros_getbase_%s() (*(%s*)(__aros_getoffsettable()+__aros_rellib_offset_%s))\n"
78 " #endif\n"
79 "#endif\n"
80 "\n",
81 cfg->includenameupper,
82 cfg->includenameupper,
83 cfg->libbase,
84 cfg->includenameupper,
85 cfg->libbase,
86 cfg->libbasetypeptrextern, cfg->libbase,
87 cfg->libbase,
88 cfg->libbase, cfg->libbase,
89 cfg->includenameupper,
90 cfg->libbase,
91 cfg->includenameupper, cfg->libbase,
92 cfg->includenameupper, cfg->libbase,
93 cfg->libbase,
94 cfg->libbase, cfg->libbasetypeptrextern, cfg->libbase
97 else /* cfg->options & OPTION_DUPBASE */
99 /* If multiple libbase access libbase through __aros_getbase_ModName() */
100 fprintf(out,
101 "%s__aros_getbase_%s(void);\n"
102 " extern const IPTR __aros_rellib_offset_%s;\n"
103 " #define AROS_RELLIB_OFFSET_%s __aros_rellib_offset_%s\n"
104 " #define AROS_RELLIB_BASE_%s __aros_rellib_base_%s\n"
105 "\n",
106 cfg->libbasetypeptrextern, cfg->libbase,
107 cfg->libbase,
108 cfg->includenameupper, cfg->libbase,
109 cfg->includenameupper, cfg->libbase
113 // define name must not start with a digit
114 // this solves a problem with proto/8svx.h
115 if (isdigit(cfg->includenameupper[0]))
117 snprintf(define, sizeof define, "X%s", cfg->includenameupper);
119 else
121 strncpy(define, cfg->includenameupper, sizeof define);
124 fprintf(out,
125 "#if !defined(NOLIBINLINE) && !defined(%s_NOLIBINLINE) && !defined(__%s_RELLIBBASE__)\n"
126 "# include <inline/%s.h>\n"
127 "#elif !defined(NOLIBDEFINES) && !defined(%s_NOLIBDEFINES)\n"
128 "# include <defines/%s.h>\n"
129 "#endif\n"
130 "\n"
131 "#endif /* PROTO_%s_H */\n",
132 define, cfg->includenameupper,
133 cfg->includename,
134 define,
135 cfg->includename,
136 cfg->includenameupper
139 fclose(out);