Ejemplo n.º 1
0
void preprocess_c(char *path)
{
	build_arglist(CMD_CPP);

	add_argument_list("-I", &inclist);
	add_argument_list("-D", &deflist);
	add_argument(path);
	/* Weird one .. -E goes to stdout */
	if (last_phase != 1)
		redirect_out(pathmod(path, ".c", ".%", 0));
	run_command();
}
Ejemplo n.º 2
0
void link_phase(void)
{
	build_arglist(CMD_LD);
	add_argument("-b");
	add_argument("-c");
	add_argument("256");
	if (strip)
		add_argument("-s");
	add_argument("-o");
	add_argument(target);
	if (!standalone)
		add_argument(CRT0);
	add_argument_list(NULL, &objlist);
	add_argument_list(NULL, &liblist);
	run_command();
}
Ejemplo n.º 3
0
Archivo: fcc.c Proyecto: 8l/FUZIX
static void build_command(void)
{
  char buf[128];

  add_argument("sdcc");
  /* Set up the basic parameters we will inflict on the user */
  add_argument("--std-c99");
  add_option("-m", cpu?cpu:"z80");
  if (mode == MODE_LINK) {
    add_argument("--no-std-crt0");
    add_argument("--nostdlib");
    add_argument("--code-loc");
    snprintf(buf, sizeof(buf), "%d", progbase);
    add_argument(mstrdup(buf));
    add_argument("--data-loc");
    add_argument("0x0");
  }
  /* Parse the specials */
  if (pedantic == 0)
    add_argument("--less-pedantic");
  if (werror == 1)
    add_argument("--Werror");
  if (unschar == 1)
    add_argument("-funsigned-char");
  if (debug == 1)
    add_argument("--debug");
  /* Turn -O1/2/3/4 into something meaningful */
  if (opt != NULL) {
    if (optcode > 0)
      add_argument("--max-allocs-per-node");
    if (optcode == 1)
      add_argument("30000");
    if (optcode == 2 || optcode == 3)
      add_argument("100000");
    if (optcode == 4)
      add_argument("250000");
    if (optcode > 2)
      add_argument("-D__FUZIX_OPT_SPEED__");
  }
  /* Size optimise for all but high -O values */
  if (opt == NULL || optcode < 3)
    add_argument("--opt-code-size");
  /* Macros */
  add_argument("-D__FUZIX__");
  /* Suppress the warnings when sharing code across architectures */
  add_argument("-Ddouble=float");
  /* User provided macros */
  add_argument_list(machead);
  /* Paths */
  add_option_list("-I", includehead);
  if (mode == MODE_LINK)
    add_option_list("-L", libphead);
  if (mode == MODE_CPP)
    add_argument("-E");
  if (mode == MODE_ASM)
    add_argument("-S");
  if (mode == MODE_OBJ) {
    if (srchead == NULL) {
      fprintf(stderr, "The -c option requires an input.\n");
      exit(1);
    }
    add_argument("-c");
    if (srchead->next && target) {
      fprintf(stderr, "Cannot use -c together with -o with multiple input files.\n");
      exit(1);
    }
  }
  if (mode == MODE_LINK) {
    if (target == NULL)
      autotarget();
    if (target == NULL) {
      fprintf(stderr, "no target.\n");
      exit(1);
    }
    add_option("-o", target);
    if (nostdio)
      snprintf(buf, sizeof(buf), FCC_DIR "/lib/crt0nostdio%s.rel", platform);
    else
      snprintf(buf, sizeof(buf), FCC_DIR "/lib/crt0%s.rel", platform);
    add_argument(mstrdup(buf));
  }
  if (srchead) {
    if (mode == MODE_OBJ)
      add_argument(srchead->p);
    else
      add_argument_list(srchead);
  }
  else {
    fprintf(stderr, "fcc: No sources specified.\n");
    exit(1);
  }
  if (mode == MODE_LINK)
    add_option_list("-l", libhead);
}