.gitignore: Update
[AROS.git] / tools / genmodule / writeincproto.c
blobfb4e19987db105276892035d04198a2fe6509d91
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 "#include <exec/types.h>\n"
33 "#include <aros/system.h>\n"
34 "\n"
35 "#include <clib/%s_protos.h>\n"
36 "\n",
37 cfg->modulenameupper, is_rel ? "_REL" : "",
38 cfg->modulenameupper, is_rel ? "_REL" : "",
39 banner,
40 cfg->modulename
42 freeBanner(banner);
43 if (!is_rel)
45 fprintf(out,
46 "#if !defined(%s) && !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
47 " #ifdef __%s_STDLIBBASE__\n"
48 " extern struct Library *%s;\n"
49 " #else\n"
50 " extern %s%s;\n"
51 " #endif\n"
52 "#endif\n"
53 "\n",
54 cfg->libbase, cfg->modulenameupper,
55 cfg->modulenameupper,
56 cfg->libbase,
57 cfg->libbasetypeptrextern, cfg->libbase
60 else /* is_rel */
62 fprintf(out,
63 "#if !defined(%s) && !defined(__NOLIBBASE__) && !defined(__%s_NOLIBBASE__)\n"
64 " extern IPTR %s_offset;\n"
65 " #ifdef __%s_STDLIBBASE__\n"
66 " #define %s ((struct Library *)((char *)AROS_GET_LIBBASE+%s_offset))\n"
67 " #else\n"
68 " #define %s ((%s)((char *)AROS_GET_LIBBASE+%s_offset))\n"
69 " #endif\n"
70 "#endif\n"
71 "\n",
72 cfg->libbase, cfg->modulenameupper,
73 cfg->libbase,
74 cfg->modulenameupper,
75 cfg->libbase, cfg->libbase,
76 cfg->libbase, cfg->libbasetypeptrextern, cfg->libbase
80 // define name must not start with a digit
81 // this solves a problem with proto/8svx.h
82 if (isdigit(cfg->modulenameupper[0]))
84 snprintf(define, sizeof define, "X%s", cfg->modulenameupper);
86 else
88 strncpy(define, cfg->modulenameupper, sizeof define);
91 if (!is_rel)
93 fprintf(out,
94 "#if !defined(NOLIBINLINE) && !defined(%s_NOLIBINLINE)\n"
95 "# include <inline/%s.h>\n",
96 define, cfg->modulename
100 fprintf(out,
101 "#%sif !defined(NOLIBDEFINES) && !defined(%s_NOLIBDEFINES)\n"
102 "# include <defines/%s.h>\n"
103 "#endif\n"
104 "\n"
105 "#endif /* PROTO_%s_H */\n",
106 (is_rel) ? "" : "el",
107 define, cfg->modulename,
108 cfg->modulenameupper
110 fclose(out);