2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
4 Desc: Function to write proto/modulename(_rel).h. Part of genmodule.
9 void writeincproto(struct config
*cfg
)
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");
26 banner
= getBanner(cfg
);
28 "#ifndef PROTO_%s_H\n"
29 "#define PROTO_%s_H\n"
33 , cfg
->includenameupper
34 , cfg
->includenameupper
38 "#include <exec/types.h>\n"
40 "#include <aros/system.h>\n"
42 "#include <clib/%s_protos.h>\n"
44 (cfg
->modtype
== DEVICE
) ? "#include <exec/devices.h>\n" : "",
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
56 "#ifndef __%s_RELLIBBASE__\n"
57 " #if !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
59 " #ifdef __%s_STDLIBBASE__\n"
60 " extern struct Library *%s;\n"
65 " #ifndef __aros_getbase_%s\n"
66 " #define __aros_getbase_%s() (%s)\n"
68 " #endif /* defined(__NOLIBBASE__) || defined(__DUMMY_NOLIBBASE__) */\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"
77 " #define __aros_getbase_%s() (*(%s*)(__aros_getoffsettable()+__aros_rellib_offset_%s))\n"
81 "#ifndef __aros_getbase_%s\n"
82 "extern %s__aros_getbase_%s(void);\n"
85 cfg
->includenameupper
,
86 cfg
->includenameupper
,
88 cfg
->includenameupper
,
90 cfg
->libbasetypeptrextern
, cfg
->libbase
,
92 cfg
->libbase
, cfg
->libbase
,
93 cfg
->includenameupper
,
95 cfg
->includenameupper
, cfg
->libbase
,
96 cfg
->includenameupper
, cfg
->libbase
,
98 cfg
->libbase
, cfg
->libbasetypeptrextern
, cfg
->libbase
,
99 cfg
->libbase
, cfg
->libbasetypeptrextern
, cfg
->libbase
102 else /* cfg->options & OPTION_DUPBASE */
104 /* If multiple libbase access libbase through __aros_getbase_ModName() */
106 "%s__aros_getbase_%s(void);\n"
107 " extern const IPTR __aros_rellib_offset_%s;\n"
108 " #define AROS_RELLIB_OFFSET_%s __aros_rellib_offset_%s\n"
109 " #define AROS_RELLIB_BASE_%s __aros_rellib_base_%s\n"
111 cfg
->libbasetypeptrextern
, cfg
->libbase
,
113 cfg
->includenameupper
, cfg
->libbase
,
114 cfg
->includenameupper
, cfg
->libbase
118 // define name must not start with a digit
119 // this solves a problem with proto/8svx.h
120 if (isdigit(cfg
->includenameupper
[0]))
122 snprintf(define
, sizeof define
, "X%s", cfg
->includenameupper
);
126 strncpy(define
, cfg
->includenameupper
, sizeof define
);
130 "#if !defined(NOLIBINLINE) && !defined(%s_NOLIBINLINE) && !defined(__%s_RELLIBBASE__)\n"
131 "# include <inline/%s.h>\n"
132 "#elif !defined(NOLIBDEFINES) && !defined(%s_NOLIBDEFINES)\n"
133 "# include <defines/%s.h>\n"
136 "#endif /* PROTO_%s_H */\n",
137 define
, cfg
->includenameupper
,
141 cfg
->includenameupper