macosx_deployment_target.c [plain text]
#ifndef RLD
#include <stdlib.h>
#include <string.h>
#include <mach/mach.h>
#include "stuff/errors.h"
#include "stuff/macosx_deployment_target.h"
struct macosx_deployment_target_pair {
const char *name;
enum macosx_deployment_target_value value;
};
static const struct macosx_deployment_target_pair
macosx_deployment_target_pairs[] = {
{ "10.1", MACOSX_DEPLOYMENT_TARGET_10_1 },
{ "10.2", MACOSX_DEPLOYMENT_TARGET_10_2 },
{ "10.3", MACOSX_DEPLOYMENT_TARGET_10_3 },
{ "10.4", MACOSX_DEPLOYMENT_TARGET_10_4 },
{ "10.5", MACOSX_DEPLOYMENT_TARGET_10_5 },
{ NULL, 0 }
};
static const char *command_line_macosx_deployment_target = NULL;
__private_extern__
void
put_macosx_deployment_target(
const char *target)
{
command_line_macosx_deployment_target = target;
}
__private_extern__
void
get_macosx_deployment_target(
enum macosx_deployment_target_value *value,
const char **name,
cpu_type_t cputype)
{
unsigned long i;
char *p;
if(cputype == CPU_TYPE_I386){
*value = MACOSX_DEPLOYMENT_TARGET_10_4;
*name = "10.4";
}
else{
*value = MACOSX_DEPLOYMENT_TARGET_10_1;
*name = "10.1";
}
if(command_line_macosx_deployment_target != NULL)
p = command_line_macosx_deployment_target;
else
p = getenv("MACOSX_DEPLOYMENT_TARGET");
if(p != NULL){
for(i = 0; macosx_deployment_target_pairs[i].name != NULL; i++){
if(strcmp(macosx_deployment_target_pairs[i].name, p) == 0){
*value = macosx_deployment_target_pairs[i].value;
*name = macosx_deployment_target_pairs[i].name;
break;
}
}
if(macosx_deployment_target_pairs[i].name == NULL){
if(command_line_macosx_deployment_target != NULL)
warning("unknown -macosx_version_min parameter value: "
"%s ignored (using %s)", p, *name);
else
warning("unknown MACOSX_DEPLOYMENT_TARGET environment "
"variable value: %s ignored (using %s)", p, *name);
}
}
}
#endif