about summary refs log tree commit diff
path: root/make
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-08-14T14·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-08-14T14·00+0000
commite1a6fb787059848c815a8154da23b7da794c6231 (patch)
tree84ca9576a1abbc27c35f26b137628f5b5c000fc2 /make
parent08c53923dba9c7fe6c2676be862744dc1f90f660 (diff)
* `dependencyClosure' now allows a search path, e.g.,
    dependencyClosure { ... searchPath = [ ../foo ../bar ]; ... }

* Primop `dirOf' to return the directory part of a path (e.g., dirOf
  /a/b/c == /a/b).

* Primop `relativise' (according to Webster that's a real word!) that
  given paths A and B returns a string representing path B relative
  path to A; e.g., relativise /a/b/c a/b/x/y => "../x/y".

Diffstat (limited to 'make')
-rw-r--r--make/examples/aterm/test/default.nix2
-rw-r--r--make/lib/compile-c.sh1
-rw-r--r--make/lib/default.nix27
-rw-r--r--make/lib/find-includes.pl4
4 files changed, 21 insertions, 13 deletions
diff --git a/make/examples/aterm/test/default.nix b/make/examples/aterm/test/default.nix
index 8d2bed5fc3..e59b86b943 100644
--- a/make/examples/aterm/test/default.nix
+++ b/make/examples/aterm/test/default.nix
@@ -4,7 +4,7 @@ let {
   inherit (import ../aterm {}) libATerm;
 
   compileTest = main: link {
-    objects = [(compileC {inherit main; cFlags = "-I../aterm";})];
+    objects = [(compileC {inherit main; localIncludePath = [ ../aterm ];})];
     libraries = libATerm;
   };
 
diff --git a/make/lib/compile-c.sh b/make/lib/compile-c.sh
index 04d2595def..3558dd89ea 100644
--- a/make/lib/compile-c.sh
+++ b/make/lib/compile-c.sh
@@ -70,5 +70,4 @@ fi
 
 mkdir $out
 test "$prefix" && cd $prefix
-ls -l
 gcc -Wall $cFlags -c $mainName -o $out/$mainName.o
diff --git a/make/lib/default.nix b/make/lib/default.nix
index b2f26a9367..81440ca6a7 100644
--- a/make/lib/default.nix
+++ b/make/lib/default.nix
@@ -8,10 +8,17 @@ rec {
   stdenv = pkgs.stdenv;
   
 
-  compileC = {main, localIncludes ? "auto", cFlags ? "", sharedLib ? false}:
+  compileC =
+  { main
+  , localIncludes ? "auto"
+  , localIncludePath ? []
+  , cFlags ? ""
+  , sharedLib ? false
+  }:
   stdenv.mkDerivation {
     name = "compile-c";
     builder = ./compile-c.sh;
+    
     localIncludes =
       if localIncludes == "auto" then
         dependencyClosure {
@@ -19,38 +26,37 @@ rec {
             import (findIncludes {
               inherit main;
             });
+          searchPath = localIncludePath;
           startSet = [main];
         }
       else
         localIncludes;
+        
     inherit main;
+    
     cFlags = [
       cFlags
       (if sharedLib then ["-fpic"] else [])
+      (map (p: "-I" + (relativise (dirOf main) p)) localIncludePath)
     ];
   };
 
-  /*
-  runCommand = {command}: {
-    name = "run-command";
-    builder = ./run-command.sh;
-    inherit command;
-  };
-  */
-
+  
   findIncludes = {main}: stdenv.mkDerivation {
     name = "find-includes";
     realBuilder = pkgs.perl ~ "bin/perl";
     args = [ ./find-includes.pl ];
     inherit main;
   };
-  
+
+    
   link = {objects, programName ? "program", libraries ? []}: stdenv.mkDerivation {
     name = "link";
     builder = ./link.sh;
     inherit objects programName libraries;
   };
 
+  
   makeLibrary = {objects, libraryName ? [], sharedLib ? false}:
   # assert sharedLib -> fold (obj: x: assert obj.sharedLib && x) false objects
   stdenv.mkDerivation {
@@ -59,4 +65,5 @@ rec {
     inherit objects libraryName sharedLib;
   };
 
+  
 }
diff --git a/make/lib/find-includes.pl b/make/lib/find-includes.pl
index f4f1f43239..43406825ae 100644
--- a/make/lib/find-includes.pl
+++ b/make/lib/find-includes.pl
@@ -9,7 +9,9 @@ print OUT "[\n";
 open IN, "<$root" or die "$!";
 while (<IN>) {
     if (/^\#include\s+\"(.*)\"/) {
-        print "DEP $1\n";
+        print OUT "\"$1\"\n";
+    }
+    if (/^\#include\s+\<(.*)\>/) {
         print OUT "\"$1\"\n";
     }
 }