示例#1
0
void codegen_makefile(fileinfo* mainfile, const char** tmpbinname, bool skip_compile_link) {
  fileinfo makefile;
  openCFile(&makefile, "Makefile");
  const char* tmpDirName = intDirName;
  const char* strippedExeFilename = stripdirectories(executableFilename);
  const char* exeExt = "";
  const char* tmpbin = "";

  fprintf(makefile.fptr, "CHPL_MAKE_HOME = %s\n\n", CHPL_HOME);
  fprintf(makefile.fptr, "TMPDIRNAME = %s\n", tmpDirName);

  // LLVM builds just use the makefile for the launcher and
  // so want to skip the actual program generation.
  if( skip_compile_link ) {
    fprintf(makefile.fptr, "SKIP_COMPILE_LINK = skip\n");
  }

  if (fLibraryCompile) {
    if (fLinkStyle==LS_DYNAMIC) exeExt = ".so";
    else exeExt = ".a";
  }
  fprintf(makefile.fptr, "BINNAME = %s%s\n\n", executableFilename, exeExt);
  // BLC: This munging is done so that cp won't complain if the source
  // and destination are the same file (e.g., a.out and ./a.out)
  tmpbin = astr(tmpDirName, "/", strippedExeFilename, ".tmp", exeExt);
  if( tmpbinname ) *tmpbinname = tmpbin;
  fprintf(makefile.fptr, "TMPBINNAME = %s\n", tmpbin);
  // BLC: We generate a TMPBINNAME which is the name that will be used
  // by the C compiler in creating the executable, and is in the
  // --savec directory (a /tmp directory by default).  We then copy it
  // over to BINNAME -- the name given by the user, or a.out by
  // default -- after linking is done.  As it turns out, this saves a
  // factor of 5 or so in time in running the test system, as opposed
  // to specifying BINNAME on the C compiler command line.

  fprintf(makefile.fptr, "COMP_GEN_CFLAGS =");
  if (ccwarnings) {
    fprintf(makefile.fptr, " $(WARN_GEN_CFLAGS)");
  }
  if (debugCCode) {
    fprintf(makefile.fptr, " $(DEBUG_CFLAGS)");
  }
  if (optimizeCCode) {
    fprintf(makefile.fptr, " $(OPT_CFLAGS)");
  }
  if (specializeCCode) {
    fprintf(makefile.fptr, " $(SPECIALIZE_CFLAGS)");
  }
  if (fieeefloat) {
    fprintf(makefile.fptr, " $(IEEE_FLOAT_GEN_CFLAGS)");
  } else {
    fprintf(makefile.fptr, " $(NO_IEEE_FLOAT_GEN_CFLAGS)");
  }
  if (fLibraryCompile && (fLinkStyle==LS_DYNAMIC))
    fprintf(makefile.fptr, " $(SHARED_LIB_CFLAGS)");
  forv_Vec(const char*, dirName, incDirs) {
    fprintf(makefile.fptr, " -I%s", dirName);
  }
示例#2
0
文件: files.cpp 项目: DawidvC/chapel
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");
}
示例#3
0
文件: files.cpp 项目: DawidvC/chapel
void codegen_makefile(fileinfo* mainfile, const char** tmpbinname, bool skip_compile_link, const std::vector<const char*>& splitFiles) {
  fileinfo makefile;
  openCFile(&makefile, "Makefile");
  const char* tmpDirName = intDirName;
  const char* strippedExeFilename = stripdirectories(executableFilename);
  const char* exeExt = "";
  const char* tmpbin = "";
  std::string chplmakeallvars = "\0";


  fprintf(makefile.fptr, "CHPL_MAKE_HOME = %s\n\n", CHPL_HOME);
  fprintf(makefile.fptr, "CHPL_MAKE_RUNTIME_LIB = %s\n\n", CHPL_RUNTIME_LIB);
  fprintf(makefile.fptr, "CHPL_MAKE_RUNTIME_INCL = %s\n\n", CHPL_RUNTIME_INCL);
  fprintf(makefile.fptr, "CHPL_MAKE_THIRD_PARTY = %s\n\n", CHPL_THIRD_PARTY);
  fprintf(makefile.fptr, "TMPDIRNAME = %s\n\n", tmpDirName);

  // Generate one variable containing all envMap information to pass to printchplenv
  for (std::map<std::string, const char*>::iterator env=envMap.begin(); env!=envMap.end(); ++env)
  {
    const std::string& key = env->first;
    const char* oldPrefix = "CHPL_";
    const char* newPrefix = "CHPL_MAKE_";
    INT_ASSERT(key.substr(0, strlen(oldPrefix)) == oldPrefix);
    std::string keySuffix = key.substr(strlen(oldPrefix), std::string::npos);
    std::string chpl_make_key = newPrefix + keySuffix;
    chplmakeallvars += chpl_make_key + "=" + std::string(env->second) + "|";
  }

  fprintf(makefile.fptr, "\nexport CHPL_MAKE_SETTINGS_NO_NEWLINES := %s\n", chplmakeallvars.c_str());


  // LLVM builds just use the makefile for the launcher and
  // so want to skip the actual program generation.
  if( skip_compile_link ) {
    fprintf(makefile.fptr, "SKIP_COMPILE_LINK = skip\n");
  }

  if (fLibraryCompile) {
    if (fLinkStyle==LS_DYNAMIC) exeExt = ".so";
    else exeExt = ".a";
  }
  fprintf(makefile.fptr, "BINNAME = %s%s\n\n", executableFilename, exeExt);
  // BLC: This munging is done so that cp won't complain if the source
  // and destination are the same file (e.g., myprogram and ./myprogram)
  tmpbin = astr(tmpDirName, "/", strippedExeFilename, ".tmp", exeExt);
  if( tmpbinname ) *tmpbinname = tmpbin;
  fprintf(makefile.fptr, "TMPBINNAME = %s\n", tmpbin);
  // BLC: We generate a TMPBINNAME which is the name that will be used
  // by the C compiler in creating the executable, and is in the
  // --savec directory (a /tmp directory by default).  We then copy it
  // over to BINNAME -- the name given by the user/default module's filename
  // -- after linking is done.  As it turns out, this saves a
  // factor of 5 or so in time in running the test system, as opposed
  // to specifying BINNAME on the C compiler command line.

  fprintf(makefile.fptr, "COMP_GEN_WARN = %i\n", ccwarnings);
  fprintf(makefile.fptr, "COMP_GEN_DEBUG = %i\n", debugCCode);
  fprintf(makefile.fptr, "COMP_GEN_OPT = %i\n", optimizeCCode);
  fprintf(makefile.fptr, "COMP_GEN_SPECIALIZE = %i\n", specializeCCode);
  fprintf(makefile.fptr, "COMP_GEN_FLOAT_OPT = %i\n", ffloatOpt);

  fprintf(makefile.fptr, "COMP_GEN_USER_CFLAGS =");

  if (fLibraryCompile && (fLinkStyle==LS_DYNAMIC))
    fprintf(makefile.fptr, " $(SHARED_LIB_CFLAGS)");
  for_vector(const char, dirName, incDirs) {
    fprintf(makefile.fptr, " -I%s", dirName);
  }
示例#4
0
文件: files.cpp 项目: DawidvC/chapel
const char* objectFileForCFile(const char* inputFilename) {
  const char* pathlessFilename = stripdirectories(inputFilename);
  const char* objFilename = genIntermediateFilename(astr(pathlessFilename, ".o"));
  return objFilename;
}
示例#5
0
void codegen_makefile(fileinfo* mainfile, const char** tmpbinname,
                      bool skip_compile_link,
                      const std::vector<const char*>& splitFiles) {
  const char* tmpDirName = intDirName;
  const char* strippedExeFilename = stripdirectories(executableFilename);
  const char* exeExt = getLibraryExtension();
  const char* server = "";
  const char* tmpserver = "";
  const char* tmpbin = "";
  bool startsWithLib = !strncmp(executableFilename, "lib", 3);
  bool dyn = (fLinkStyle == LS_DYNAMIC);
  std::string makeallvars;
  fileinfo makefile;

  openCFile(&makefile, "Makefile");

  // Capture different compiler directories.
  fprintf(makefile.fptr, "CHPL_MAKE_HOME = %s\n\n", CHPL_HOME);
  fprintf(makefile.fptr, "CHPL_MAKE_RUNTIME_LIB = %s\n\n", CHPL_RUNTIME_LIB);
  fprintf(makefile.fptr, "CHPL_MAKE_RUNTIME_INCL = %s\n\n", CHPL_RUNTIME_INCL);
  fprintf(makefile.fptr, "CHPL_MAKE_THIRD_PARTY = %s\n\n", CHPL_THIRD_PARTY);
  fprintf(makefile.fptr, "TMPDIRNAME = %s\n\n", tmpDirName);

  // Store chapel environment variables in a cache.
  makeallvars = genMakefileEnvCache();
  fprintf(makefile.fptr, "export CHPL_MAKE_CHPLENV_CACHE := %s\n\n",
          makeallvars.c_str());

  //
  // LLVM builds just use the makefile for the launcher and so want to skip
  // the actual program generation.
  //
  if (skip_compile_link) {
    fprintf(makefile.fptr, "SKIP_COMPILE_LINK = skip\n");
  }

  //
  // In --library compilation, put the generated library in the library
  // directory.
  //
  if (fLibraryCompile) {

    ensureLibDirExists();
    fprintf(makefile.fptr, "BINNAME = %s/", libDir);
    if (!startsWithLib) { fprintf(makefile.fptr, "lib"); }
    fprintf(makefile.fptr, "%s%s\n\n", executableFilename, exeExt);

    //
    // Now that the client and launcher are merged, the server name becomes
    // the name of the library without any extension. We munge the server
    // name with a trailing underscore just to guarantee that it's different
    // from the file name.
    //
    if (fMultiLocaleInterop) {
      server = astr(executableFilename, "_server");
      fprintf(makefile.fptr, "SERVERNAME = %s\n\n", server);
    }

  } else {
    fprintf(makefile.fptr, "BINNAME = %s%s\n\n", executableFilename, exeExt);
  }

  //
  // BLC: This munging is done so that cp won't complain if the source
  // and destination are the same file (e.g., myprogram and ./myprogram).
  //
  if (fLibraryCompile) {
    const char* pfx = startsWithLib ? "/" : "/lib";
    tmpbin = astr(tmpDirName, pfx, strippedExeFilename, ".tmp", exeExt);

    if (fMultiLocaleInterop) {
      tmpserver = astr(tmpDirName, "/", strippedExeFilename, "_server");
    }
  } else {
    tmpbin = astr(tmpDirName, "/", strippedExeFilename, ".tmp", exeExt);
  }

  // Write out the temporary filename to the caller if necessary.
  if (tmpbinname) { *tmpbinname = tmpbin; }

  //
  // BLC: We generate a TMPBINNAME which is the name that will be used
  // by the C compiler in creating the executable, and is in the
  // --savec directory (a /tmp directory by default).  We then copy it
  // over to BINNAME -- the name given by the user/default module's filename
  // -- after linking is done.  As it turns out, this saves a
  // factor of 5 or so in time in running the test system, as opposed
  // to specifying BINNAME on the C compiler command line.
  //
  fprintf(makefile.fptr, "TMPBINNAME = %s\n", tmpbin);

  if (fMultiLocaleInterop) {
    fprintf(makefile.fptr, "TMPSERVERNAME = %s\n\n", tmpserver);
  }

  // Bunch of C compiler flags.
  fprintf(makefile.fptr, "COMP_GEN_WARN = %i\n", ccwarnings);
  fprintf(makefile.fptr, "COMP_GEN_DEBUG = %i\n", debugCCode);
  fprintf(makefile.fptr, "COMP_GEN_OPT = %i\n", optimizeCCode);
  fprintf(makefile.fptr, "COMP_GEN_SPECIALIZE = %i\n", specializeCCode);
  fprintf(makefile.fptr, "COMP_GEN_FLOAT_OPT = %i\n", ffloatOpt);

  if (fMultiLocaleInterop) {
    const char* loc = "$(CHPL_MAKE_HOME)/runtime/etc/src";
    fprintf(makefile.fptr, "COMP_GEN_MLI_EXTRA_INCLUDES = -I%s\n", loc);
  }
  
  // Build a string out of include directories, for convenience.
  std::string includedirs;
  for_vector(const char, dirName, incDirs) {
    includedirs += " -I";
    includedirs += dirName;
  }