2 Copyright © 2005-2011, The AROS Development Team. All rights reserved.
5 Code to write a Makefile with variables that provides the files
6 and configuration for building the module
12 #include "genmodule.h"
15 static inline const char *upname(const char *s
)
17 static char name
[512];
20 while (s
&& i
< (sizeof(name
)-1))
21 name
[i
++] = toupper(*(s
++));
27 void writemakefile(struct config
*cfg
)
33 snprintf(name
, sizeof(name
), "%s/Makefile.%s", cfg
->gendir
, cfg
->modulename
);
35 out
= fopen(name
, "w");
44 "%s_STARTFILES += %s_start\n"
45 "%s_ENDFILES += %s_end\n"
47 cfg
->modulename
, cfg
->modulename
,
48 cfg
->modulename
, cfg
->modulename
,
49 cfg
->modulename
, cfg
->moddir
52 fprintf(out
, "%s_LINKLIBFILES +=", cfg
->modulename
);
53 if (cfg
->options
& OPTION_STUBS
)
54 fprintf(out
, " %s_stubs", cfg
->modulename
);
55 if (cfg
->options
& OPTION_AUTOINIT
)
56 fprintf(out
, " %s_autoinit", cfg
->modulename
);
57 if (cfg
->modtype
== LIBRARY
)
58 fprintf(out
, " %s_getlibbase", cfg
->modulename
);
60 fprintf(out
, "%s_RELLINKLIBFILES +=", cfg
->modulename
);
61 if (cfg
->options
& OPTION_STUBS
)
62 fprintf(out
, " %s_relstubs", cfg
->modulename
);
63 if (cfg
->options
& OPTION_AUTOINIT
)
64 fprintf(out
, " %s_relautoinit", cfg
->modulename
);
65 if (cfg
->modtype
== LIBRARY
)
66 fprintf(out
, " %s_relgetlibbase", cfg
->modulename
);
69 /* Currently there are no asm files anymore */
70 fprintf(out
, "%s_LINKLIBAFILES +=\n", cfg
->modulename
);
71 fprintf(out
, "%s_RELLINKLIBAFILES +=\n", cfg
->modulename
);
73 fprintf(out
, "%s_INCLUDES += ", cfg
->modulename
);
74 if (cfg
->options
& OPTION_INCLUDES
)
77 "clib/%s_protos.h inline/%s.h defines/%s.h proto/%s.h",
78 cfg
->modulename
, cfg
->modulename
, cfg
->modulename
, cfg
->modulename
80 if (cfg
->modtype
== LIBRARY
)
81 fprintf(out
, " inline/%s_rel.h defines/%s_rel.h proto/%s_rel.h",
82 cfg
->modulename
, cfg
->modulename
, cfg
->modulename
);
84 if (cfg
->interfacelist
)
86 struct interfaceinfo
*in
;
87 for (in
= cfg
->interfacelist
; in
; in
= in
->next
)
95 fprintf(out
, "%s_CFLAGS +=", cfg
->modulename
);
96 for (s
= cfg
->rellibs
; s
; s
= s
->next
)
97 fprintf(out
, " -D__%s_RELLIBBASE__", upname(s
->s
));
100 fprintf(out
, "%s_DFLAGS +=", cfg
->modulename
);
101 for (s
= cfg
->rellibs
; s
; s
= s
->next
)
102 fprintf(out
, " -D__%s_RELLIBBASE__", upname(s
->s
));
105 fprintf(out
, "%s_LDFLAGS +=", cfg
->modulename
);
108 fprintf(out
, "%s_LIBS +=", cfg
->modulename
);
109 for (s
= cfg
->rellibs
; s
; s
= s
->next
)
110 fprintf(out
, " %s_rel", s
->s
);
115 perror("Error writing Makefile");