1:/*
   2: * Copyright (c) 2004, Brian Hawkins
   3: * Permission is granted to use this code without restriction as long
   4: * as this copyright notice appears in all source files.
   5: */
   6: 
   7:bldoutdir = "build";
   8:build = make.getProperty("build", "debug");
   9:progBin = "cpmaketest";
  10:/*
  11:objExt and exeExt are set in the platform specific make file
  12:*/
  13:if (make.getProperty("os.name").startsWith("Windows"))
  14:    sourceRelative("windows.bsh");
  15:else
  16:    sourceRelative("linux.bsh");
  17:
  18:progBin = progBin + exeExt;
  19:
  20:srcFiles = new String[] 
  21:    {
  22:    "main.cpp",
  23:    "employee.cpp",
  24:    "company.cpp"
  25:    };
  26:    
  27:objs = make.substitute("(.*)\\.cpp", bldoutdir+"/$1"+objExt, srcFiles);
  28:
  29:includeDirs = new String[] { "include" };
  30:    
  31://-------------------------------------------------------------------
  32://==-- SET SEARCH PATHS --==
  33:make.addSearchPath(".*\\.hpp", "include");
  34:make.addSearchPath(".*\\.cpp", "src");
  35:
  36://-------------------------------------------------------------------
  37://==-- RULE FOR CREATING DIRECTORIES --==
  38:make.createDirectoryRule(bldoutdir, null, false);   
  39:    
  40://-------------------------------------------------------------------
  41://==-- COMPILE OBJECT RULE --==
  42:make.createPatternDependency(bldoutdir+"/(.*)\\"+objExt, bldoutdir);
  43:make.createPatternRule(bldoutdir+"/(.*)\\"+objExt, "$1.cpp", "compile", true);
  44:void compile(String target, String[] prereqs)
  45:    {
  46:    cmd = getCompileCommand(target, prereqs[0], includeDirs);
  47:    make.exec(cmd);
  48:    }
  49:    
  50://-------------------------------------------------------------------
  51://==-- LINK EXECUTABLE --==
  52:make.createExplicitRule(bldoutdir+"/"+progBin, objs, "link", true);
  53:void link(String target, String[] prereqs)
  54:    {
  55:    print("Linking "+target+" for "+platform);
  56:    cmd = getLinkCommand(target, prereqs);
  57:    make.exec(cmd);
  58:    }
  59:    
  60://-------------------------------------------------------------------
  61://==-- TEST --==
  62:make.createPhonyRule("test", bldoutdir+"/"+progBin, "test");
  63:void test(String target, String[] prereqs)
  64:    {
  65:    print("Running Test");
  66:    make.exec(bldoutdir, make.fullPath(bldoutdir)+"/"+progBin, true);
  67:    }
  68:    
  69:    
  70:make.setDefaultTarget(bldoutdir+"/"+progBin);