Пример #1
0
static void genCFileBuildRules(FILE* makefile) {
  int filenum = 0;
  while (const char* inputFilename = nthFilename(filenum++)) {
    if (isCSource(inputFilename)) {
      const char* objFilename = objectFileForCFile(inputFilename);
      fprintf(makefile, "%s: %s FORCE\n", objFilename, inputFilename);
      fprintf(makefile,
                   "\t$(CC) -c -o $@ $(GEN_CFLAGS) $(COMP_GEN_CFLAGS) $<\n");
      fprintf(makefile, "\n");
    }
  }
  fprintf(makefile, "\n");
}
Пример #2
0
static void genCFiles(FILE* makefile) {
  int filenum = 0;
  int first = 1;
  while (const char* inputFilename = nthFilename(filenum++)) {
    if (isCSource(inputFilename)) {
      if (first) {
        fprintf(makefile, "CHPL_CL_C_SRCS = \\\n");
        first = 0;
      }
      fprintf(makefile, "\t%s \\\n", inputFilename);
    }
  }
  if (!first)
    fprintf(makefile, "\n");
}
Пример #3
0
static const char* addCurrentDirToSourceFile(const char* filename,
                                             const char* modFilename) {
  // Do nothing if modFilename is NULL
  if (modFilename == NULL) {
    return filename;
  }

  // Do nothing if the filename is already absolute
  if (filename[0] == '/') {
    return filename;
  }

  // Do nothing if the current module's directory is "./"
  const char* modDir = getDirectory(modFilename);
  if (strcmp(modDir, ".") == 0) {
    return filename;
  }

  // If the file is a .c or .o...
  if (isCSource(filename) || isObjFile(filename)) {
    // ...and it isn't already an absolute path, add the module directory
    return astr(modDir, "/", filename);
  }

  // If the file is a .h, add the module's directory to the -I path
  if (isCHeader(filename)) {
    for_vector(const char, dir, incDirs) {
      if (dir == modDir) {
        // we've already added this -I directory, so don't do it again
        return filename;
      }
    }
    addIncInfo(modDir);
    return filename;
  }

  // otherwise, leave it as-is
  return filename;
}
Пример #4
0
static void genObjFiles(FILE* makefile) {
  int filenum = 0;
  int first = 1;
  while (const char* inputFilename = nthFilename(filenum++)) {
    bool objfile = isObjFile(inputFilename);
    bool cfile = isCSource(inputFilename);
    if (objfile || cfile) {
      if (first) {
        fprintf(makefile, "CHPL_CL_OBJS = \\\n");
        first = 0;
      }
      if (objfile) {
        fprintf(makefile, "\t%s \\\n", inputFilename);
      } else {
        const char* pathlessFilename = stripdirectories(inputFilename);
        const char* objFilename = genIntermediateFilename(astr(pathlessFilename, ".o"));
        fprintf(makefile, "\t%s \\\n", objFilename);
      }
    }
  }
  if (!first)
    fprintf(makefile, "\n");
}
Пример #5
0
static bool isRecognizedSource(const char* filename) {
  return (isCSource(filename) ||
          isCHeader(filename) ||
          isObjFile(filename) ||
          isChplSource(filename));
}