The "asm" extension is now recognized for assembly files

This commit is contained in:
Pierre Pronchery 2011-05-08 17:02:13 +00:00
parent 9c991976e9
commit f62e808301
3 changed files with 42 additions and 20 deletions

View File

@ -67,7 +67,17 @@ const struct HostKernel sHostKernel[] =
const String * sTargetType[TT_COUNT] = { "binary", "library", "libtool", const String * sTargetType[TT_COUNT] = { "binary", "library", "libtool",
"object", "plugin", "script", NULL }; "object", "plugin", "script", NULL };
const String * sObjectType[OT_COUNT] = { "c", "cc", "cpp", "S", NULL }; const struct ExtensionType _sExtensionType[] =
{
{ "c", OT_C_SOURCE },
{ "cpp", OT_CXX_SOURCE },
{ "cxx", OT_CXX_SOURCE },
{ "c++", OT_CXX_SOURCE },
{ "asm", OT_ASM_SOURCE },
{ "S", OT_ASM_SOURCE },
{ NULL, 0 }
};
const struct ExtensionType * sExtensionType = _sExtensionType;
String const * _source_extension(String const * source) String const * _source_extension(String const * source)
{ {
@ -79,6 +89,19 @@ String const * _source_extension(String const * source)
return NULL; return NULL;
} }
ObjectType _source_type(String const * source)
{
String const * extension;
size_t i;
if((extension = _source_extension(source)) == NULL)
extension = source;
for(i = 0; sExtensionType[i].extension != NULL; i++)
if(string_compare(sExtensionType[i].extension, extension) == 0)
return sExtensionType[i].type;
return -1;
}
/* functions */ /* functions */
int configure_error(char const * message, int ret) int configure_error(char const * message, int ret)

View File

@ -76,14 +76,20 @@ extern const String * sTargetType[TT_COUNT];
typedef enum _ObjectType typedef enum _ObjectType
{ {
OT_C_SOURCE = 0, OT_C_SOURCE = 0,
OT_CXX_SOURCE, OT_CPP_SOURCE, OT_CXX_SOURCE,
OT_ASM_SOURCE, OT_ASM_SOURCE,
OT_UNKNOWN OT_UNKNOWN
} ObjectType; } ObjectType;
# define OT_LAST OT_UNKNOWN # define OT_LAST OT_UNKNOWN
# define OT_COUNT (OT_LAST + 1) # define OT_COUNT (OT_LAST + 1)
extern const String * sObjectType[OT_COUNT]; struct ExtensionType
{
const char * extension;
ObjectType type;
};
extern const struct ExtensionType * sExtensionType;
String const * _source_extension(String const * source); String const * _source_extension(String const * source);
ObjectType _source_type(String const * source);
/* constants */ /* constants */

View File

@ -798,12 +798,11 @@ static int _objs_source(Prefs * prefs, FILE * fp, String * source,
} }
len = string_length(source) - string_length(extension) - 1; len = string_length(source) - string_length(extension) - 1;
source[len] = '\0'; source[len] = '\0';
switch(enum_string(OT_LAST, sObjectType, extension)) switch(_source_type(extension))
{ {
case OT_ASM_SOURCE: case OT_ASM_SOURCE:
case OT_C_SOURCE: case OT_C_SOURCE:
case OT_CXX_SOURCE: case OT_CXX_SOURCE:
case OT_CPP_SOURCE:
if(prefs->flags & PREFS_n) if(prefs->flags & PREFS_n)
break; break;
fprintf(fp, " %s%s", source, tt == TT_LIBTOOL ? ".lo" fprintf(fp, " %s%s", source, tt == TT_LIBTOOL ? ".lo"
@ -890,7 +889,7 @@ static int _target_flags(Configure * configure, FILE * fp,
sources[i] = c; sources[i] = c;
continue; continue;
} }
type = enum_string(OT_LAST, sObjectType, extension); type = _source_type(extension);
if(!done[type]) if(!done[type])
switch(type) switch(type)
{ {
@ -901,9 +900,7 @@ static int _target_flags(Configure * configure, FILE * fp,
_flags_c(configure, fp, target); _flags_c(configure, fp, target);
break; break;
case OT_CXX_SOURCE: case OT_CXX_SOURCE:
case OT_CPP_SOURCE:
done[OT_CXX_SOURCE] = 1; done[OT_CXX_SOURCE] = 1;
done[OT_CPP_SOURCE] = 1;
_flags_cxx(configure, fp, target); _flags_cxx(configure, fp, target);
break; break;
case OT_UNKNOWN: case OT_UNKNOWN:
@ -1056,7 +1053,7 @@ static int _target_object(Configure * configure, FILE * fp,
return 0; return 0;
if((extension = _source_extension(p)) == NULL) if((extension = _source_extension(p)) == NULL)
return 1; return 1;
switch(enum_string(OT_LAST, sObjectType, extension)) switch(_source_type(extension))
{ {
case OT_ASM_SOURCE: case OT_ASM_SOURCE:
fprintf(fp, "\n%s%s%s\n%s%s", target, "_OBJS = ", fprintf(fp, "\n%s%s%s\n%s%s", target, "_OBJS = ",
@ -1078,7 +1075,6 @@ static int _target_object(Configure * configure, FILE * fp,
fputc('\n', fp); fputc('\n', fp);
break; break;
case OT_CXX_SOURCE: case OT_CXX_SOURCE:
case OT_CPP_SOURCE:
fprintf(fp, "\n%s%s%s\n%s%s", target, "_OBJS = ", fprintf(fp, "\n%s%s%s\n%s%s", target, "_OBJS = ",
target, target, "_CXXFLAGS =" target, target, "_CXXFLAGS ="
" $(CPPFLAGSF) $(CPPFLAGS)" " $(CPPFLAGSF) $(CPPFLAGS)"
@ -1264,7 +1260,7 @@ static int _target_source(Configure * configure, FILE * fp,
return 1; return 1;
len = string_length(source) - string_length(extension) - 1; len = string_length(source) - string_length(extension) - 1;
source[len] = '\0'; source[len] = '\0';
switch((ot = enum_string(OT_LAST, sObjectType, extension))) switch((ot = _source_type(extension)))
{ {
case OT_ASM_SOURCE: case OT_ASM_SOURCE:
if(configure->prefs->flags & PREFS_n) if(configure->prefs->flags & PREFS_n)
@ -1272,7 +1268,7 @@ static int _target_source(Configure * configure, FILE * fp,
fprintf(fp, "\n%s.o", source); fprintf(fp, "\n%s.o", source);
if(tt == TT_LIBTOOL) if(tt == TT_LIBTOOL)
fprintf(fp, " %s.lo", source); fprintf(fp, " %s.lo", source);
fprintf(fp, ": %s.%s", source, sObjectType[ot]); fprintf(fp, ": %s.%s", source, extension);
source[len] = '.'; /* FIXME ugly */ source[len] = '.'; /* FIXME ugly */
_source_depends(configure->config, fp, source); _source_depends(configure->config, fp, source);
source[len] = '\0'; source[len] = '\0';
@ -1281,7 +1277,7 @@ static int _target_source(Configure * configure, FILE * fp,
fputs("$(LIBTOOL) --mode=compile ", fp); fputs("$(LIBTOOL) --mode=compile ", fp);
fprintf(fp, "%s%s%s", "$(AS) $(", target, "_ASFLAGS)"); fprintf(fp, "%s%s%s", "$(AS) $(", target, "_ASFLAGS)");
fprintf(fp, "%s%s%s%s%s%s", " -o ", source, ".o ", fprintf(fp, "%s%s%s%s%s%s", " -o ", source, ".o ",
source, ".", sObjectType[ot]); source, ".", extension);
fputc('\n', fp); fputc('\n', fp);
break; break;
case OT_C_SOURCE: case OT_C_SOURCE:
@ -1290,7 +1286,7 @@ static int _target_source(Configure * configure, FILE * fp,
fprintf(fp, "\n%s%s", source, ".o"); fprintf(fp, "\n%s%s", source, ".o");
if(tt == TT_LIBTOOL) if(tt == TT_LIBTOOL)
fprintf(fp, " %s%s", source, ".lo"); fprintf(fp, " %s%s", source, ".lo");
fprintf(fp, ": %s.%s", source, sObjectType[ot]); fprintf(fp, ": %s.%s", source, extension);
source[len] = '.'; /* FIXME ugly */ source[len] = '.'; /* FIXME ugly */
_source_depends(configure->config, fp, source); _source_depends(configure->config, fp, source);
/* FIXME do both wherever also relevant */ /* FIXME do both wherever also relevant */
@ -1313,16 +1309,14 @@ static int _target_source(Configure * configure, FILE * fp,
} }
if(string_find(source, "/")) if(string_find(source, "/"))
fprintf(fp, "%s%s%s", " -o ", source, ".o"); fprintf(fp, "%s%s%s", " -o ", source, ".o");
fprintf(fp, "%s%s%s%s", " -c ", source, ".", fprintf(fp, "%s%s%s%s", " -c ", source, ".", extension);
sObjectType[ot]);
fputc('\n', fp); fputc('\n', fp);
break; break;
case OT_CXX_SOURCE: case OT_CXX_SOURCE:
case OT_CPP_SOURCE:
if(configure->prefs->flags & PREFS_n) if(configure->prefs->flags & PREFS_n)
break; break;
fprintf(fp, "%s%s%s%s%s%s", "\n", source, ".o: ", fprintf(fp, "%s%s%s%s%s%s", "\n", source, ".o: ",
source, ".", sObjectType[ot]); source, ".", extension);
source[len] = '.'; /* FIXME ugly */ source[len] = '.'; /* FIXME ugly */
_source_depends(configure->config, fp, source); _source_depends(configure->config, fp, source);
p = config_get(configure->config, source, "cxxflags"); p = config_get(configure->config, source, "cxxflags");
@ -1333,8 +1327,7 @@ static int _target_source(Configure * configure, FILE * fp,
fprintf(fp, " %s", p); fprintf(fp, " %s", p);
if(string_find(source, "/")) if(string_find(source, "/"))
fprintf(fp, "%s%s%s", " -o ", source, ".o"); fprintf(fp, "%s%s%s", " -o ", source, ".o");
fprintf(fp, "%s%s%s%s", " -c ", source, ".", fprintf(fp, "%s%s%s%s", " -c ", source, ".", extension);
sObjectType[ot]);
fputc('\n', fp); fputc('\n', fp);
break; break;
case OT_UNKNOWN: case OT_UNKNOWN: