Makefile adopted to changed font names.
[cake.git] / tools / genmodule / writemakefile.c
blob9e4ab08928e2b764754aa98f97443b0c3c92d618
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 if (!(cfg->intcfg & CFG_GENLINKLIB))
40 fprintf(out,
41 "%s_LINKLIBFILES :=\n"
42 "%s_LINKLIBAFILES :=\n",
43 cfg->modulename,
44 cfg->modulename
46 else
48 switch (cfg->modtype)
50 case LIBRARY:
51 fprintf(out,
52 "%s_LINKLIBFILES := %s_stubs %s_autoinit\n",
53 cfg->modulename, cfg->modulename, cfg->modulename
55 break;
57 case DEVICE:
58 case RESOURCE:
59 fprintf(out,
60 "%s_LINKLIBFILES := %s_stubs\n",
61 cfg->modulename, cfg->modulename
63 break;
65 default:
66 fprintf(stderr, "Internal error in writemakefile: unsupported modtype for genlinklib\n");
67 exit(20);
70 fprintf(out, "%s_LINKLIBAFILES :=", cfg->modulename);
71 if (cfg->intcfg & CFG_GENASTUBS)
72 fprintf(out, "%s_astubs\n", cfg->modulename);
73 else
74 fprintf(out, "\n");
77 fprintf(out, "%s_INCLUDES := ", cfg->modulename);
78 switch (cfg->modtype)
80 case LIBRARY:
81 case DEVICE:
82 case RESOURCE:
83 case GADGET:
84 fprintf(out,
85 "clib/%s_protos.h defines/%s.h proto/%s.h\n",
86 cfg->modulename, cfg->modulename, cfg->modulename
88 break;
90 case DATATYPE:
91 case MCC:
92 case MUI:
93 case MCP:
94 case HIDD:
95 fprintf(out, "\n");
96 break;
98 default:
99 fprintf(out, "Internal error writemakefile: unhandled modtype for includes\n");
100 break;
103 fprintf(out,
104 "%s_NEEDREF := %s\n",
105 cfg->modulename, (cfg->intcfg & CFG_NOREADREF) ? "no" : "yes"
108 if (ferror(out))
110 perror("Error writing Makefile");
111 fclose(out);
112 exit(20);
115 fclose(out);