2 Copyright © 1995-2014, 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"
66 " #ifndef __aros_getbase_%s\n"
67 " #define __aros_getbase_%s() (%s)\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 cfg
->includenameupper
,
82 cfg
->includenameupper
,
84 cfg
->includenameupper
,
86 cfg
->libbasetypeptrextern
, cfg
->libbase
,
88 cfg
->libbase
, cfg
->libbase
,
89 cfg
->includenameupper
,
91 cfg
->includenameupper
, cfg
->libbase
,
92 cfg
->includenameupper
, 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() */
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"
106 cfg
->libbasetypeptrextern
, 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
);
121 strncpy(define
, cfg
->includenameupper
, sizeof define
);
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"
131 "#endif /* PROTO_%s_H */\n",
132 define
, cfg
->includenameupper
,
136 cfg
->includenameupper