2 * udibuild - UDI Compilation Utility
3 * - By John Hodge (thePowersGang)
6 * - Compilation functions
11 #include "include/build.h"
14 # define __attribute__(...)
18 char *get_objfile(tIniFile *opts, const char *srcfile);
19 char *mkstr(const char *fmt, ...) __attribute__((format(printf,1,2)));
22 int Build_CompileFile(tIniFile *opts, const char *abi, tUdiprops *udiprops, tUdiprops_Srcfile *srcfile)
24 // Select compiler from opts [abi]
25 const char *cc_prog = IniFile_Get(opts, abi, "CC", NULL);
27 fprintf(stderr, "No 'CC' defined for ABI %s\n", abi);
31 // Build up compiler's command line
32 // - Include CFLAGS from .ini file
33 // - defines from udiprops
34 // - Object file is srcfile with .o appended
35 // > Place in 'obj/' dir?
36 char *objfile = get_objfile(opts, srcfile->Filename);
37 char *cmd = mkstr("%s -DUDI_ABI_is_%s %s %s -c %s -o %s",
40 IniFile_Get(opts, abi, "CFLAGS", ""),
41 srcfile->CompileOpts ? srcfile->CompileOpts : "",
42 srcfile->Filename, objfile);
43 printf("--- Compiling: %s\n", srcfile->Filename);
51 int Build_LinkObjects(tIniFile *opts, const char *abi, tUdiprops *udiprops)
56 char *get_objfile(tIniFile *opts, const char *srcfile)
58 return mkstr("%s.o", srcfile);
61 char *mkstr(const char *fmt, ...)
65 size_t len = vsnprintf(NULL, 0, fmt, args);
68 char *ret = malloc(len+1);
69 vsnprintf(ret, len+1, fmt, args);