Fixed a few warnings.
[tangerine.git] / tools / genmodule / writemakefile.c
blobee442295d42cbda5ab1708393133f2dcf40af1a0
1 /*
2 Copyright © 2005, The AROS Development Team. All rights reserved.
3 $Id$
5 Code to write a Makefile with variables that provides the files
6 and configuration for building the module
7 */
8 #include <stdio.h>
9 #include <stddef.h>
10 #include <string.h>
12 #include "genmodule.h"
13 #include "config.h"
15 void writemakefile(struct config *cfg)
17 FILE *out;
18 char name[512];
20 snprintf(name, sizeof(name), "%s/Makefile.%s", cfg->gendir, cfg->modulename);
22 out = fopen(name, "w");
24 if (out == NULL)
26 perror(name);
27 exit(20);
30 fprintf(out,
31 "%s_STARTFILES := %s_start\n"
32 "%s_ENDFILES := %s_end\n"
33 "%s_MODDIR := %s\n",
34 cfg->modulename, cfg->modulename,
35 cfg->modulename, cfg->modulename,
36 cfg->modulename, cfg->moddir
39 fprintf(out, "%s_LINKLIBFILES :=", cfg->modulename);
40 if (cfg->options & OPTION_STUBS)
41 fprintf(out, " %s_stubs", cfg->modulename);
42 if (cfg->options & OPTION_AUTOINIT)
43 fprintf(out, " %s_autoinit", cfg->modulename);
44 fprintf(out, "\n");
46 fprintf(out, "%s_LINKLIBAFILES :=", cfg->modulename);
47 if ((cfg->options & OPTION_STUBS) && (cfg->intcfg & CFG_GENASTUBS))
48 fprintf(out, "%s_astubs\n", cfg->modulename);
49 fprintf(out, "\n");
51 fprintf(out, "%s_INCLUDES := ", cfg->modulename);
52 if (cfg->options & OPTION_INCLUDES)
54 fprintf(out,
55 "clib/%s_protos.h defines/%s.h proto/%s.h",
56 cfg->modulename, cfg->modulename, cfg->modulename
59 fprintf(out, "\n");
61 fprintf(out,
62 "%s_NEEDREF := %s\n",
63 cfg->modulename, (cfg->intcfg & CFG_NOREADREF) ? "no" : "yes"
66 if (ferror(out))
68 perror("Error writing Makefile");
69 fclose(out);
70 exit(20);
73 fclose(out);