Import SB128-v5.24 to main branch
[AROS.git] / tools / genmodule / writemakefile.c
blob105085cde2a6dd0fa740df4c399870d11ccd2feb
1 /*
2 Copyright © 2005-2011, 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 /* Currently there are no asm files anymore */
47 fprintf(out, "%s_LINKLIBAFILES :=\n", cfg->modulename);
49 fprintf(out, "%s_INCLUDES := ", cfg->modulename);
50 if (cfg->options & OPTION_INCLUDES)
52 fprintf(out,
53 "clib/%s_protos.h inline/%s.h defines/%s.h proto/%s.h",
54 cfg->modulename, cfg->modulename, cfg->modulename, cfg->modulename
57 fprintf(out, "\n");
59 if (ferror(out))
61 perror("Error writing Makefile");
62 fclose(out);
63 exit(20);
66 fclose(out);