diff buildHelper.d @ 183:190ba98276b3

Several changes to make it build on posix systems. I've only tried to build on Mac OS X but it should build on Linux now as well. This should also fix ticket #9.
author Jacob Carlborg <doob@me.com>
date Mon, 25 Oct 2010 15:36:13 +0200
parents 0622fff7810a
children 1a0c1126bc46
line wrap: on
line diff
--- a/buildHelper.d	Mon Oct 18 00:36:44 2010 +0400
+++ b/buildHelper.d	Mon Oct 25 15:36:13 2010 +0200
@@ -10,20 +10,28 @@
 
 enum dmdVersionDefault = "2.040";
 enum dmdArchiveBaseURL = "http://ftp.digitalmars.com/";
-enum dmdLib = "dmd.lib";
+enum dmd = "dmd";
+
 version(Windows)
 {
 	enum scriptName = "build.bat";
 	enum osSubDir   = "windows";
 	enum configFile = "sc.ini";
 	enum execExt    = ".exe";
+	enum dmdLib = "dmd.lib";
 }
 else
 {
+	version (OSX)
+		enum osSubDir   = "osx";
+
+	else version (linux)
+		enum osSubDir   = "linux";
+
 	enum scriptName = "./build.sh";
-	enum osSubDir   = "linux";
 	enum configFile = "dmd.conf";
 	enum execExt    = "";
+	enum dmdLib = "libdmd.a";
 }
 
 string dmdVersion;
@@ -183,7 +191,12 @@
 		enum makefile = "win32.mak";
 	else
 	{
-		enum makefile = "linux_lib.mak";
+		version (linux)
+			enum makefile = "linux_lib.mak";
+
+		else version (OSX)
+			enum makefile = "osx_lib.mak";
+
 		doCopy("../../../"~makefile, makefile);
 	}
 
@@ -204,7 +217,7 @@
 		doSystem("make deblib -f"~makefile);
 	else
 		doSystem("make -f"~makefile);
-	doCopy("dmd.lib", "../../../dmd.lib");
+	doCopy(dmdLib, "../../../" ~ dmdLib);
 	
 	// Copy and patch config file
 	doChDir("../../..");
@@ -213,12 +226,13 @@
 		normFilePath("bin/"~configFile),
 		(ref string data) {
 			data = data.replace(normDirPath("../.."), normDirPath("../dmd2"));
-			data = data.replace(normDirPath("../lib"), normDirPath("../dmd2/"~osSubDir~"/lib"));
+			data = data.replace(normDirPath("../lib")[0 .. $ - 1], normDirPath("../dmd2/"~osSubDir~"/lib")[0 .. $ - 1]);
 		}
 	);
 
 	// Copy linker
-	doCopy("dmd2/"~osSubDir~"/bin/link"~execExt, "bin/link"~execExt);
+	version (Windows)
+		doCopy("dmd2/"~osSubDir~"/bin/link"~execExt, "bin/link"~execExt);
 
 	return true;
 }
@@ -317,14 +331,20 @@
 	{
 		system("cls");
 		if(ret == 0) ret = doSystem(r"dmc.exe bridge\bridge.cpp -c");
-		if(!releaseOnly) if(ret == 0) ret = doSystem(r"dmd -debug -g @commands.txt");
-		if(!debugOnly)   if(ret == 0) ret = doSystem(r"dmd -release -O -inline @commands.txt");
+		if(!releaseOnly) if(ret == 0) ret = doSystem(dmd ~ r" -debug -g @commands.txt");
+		if(!debugOnly)   if(ret == 0) ret = doSystem(dmd ~ r" -release -O -inline @commands.txt");
 	}
 	else
 	{
-		if(ret == 0) ret = doSystem("g++ -c bridge/bridge.cpp -obridge.o");
-		if(!releaseOnly) if(ret == 0) ret = doSystem("dmd -debug -gc @commands.linux.txt");
-		if(!debugOnly)   if(ret == 0) ret = doSystem("dmd -release -O -inline @commands.linux.txt");
+		version (linux)
+			auto commands = "@commands.linux.txt";
+
+		else version (OSX)
+			auto commands = "@commands.osx.txt";
+
+		if(ret == 0) ret = doSystem("g++ -m32 -c bridge/bridge.cpp -obridge.o");
+		if(!releaseOnly) if(ret == 0) ret = doSystem(dmd ~ " -debug -gc " ~ commands);
+		if(!debugOnly)   if(ret == 0) ret = doSystem(dmd ~ " -release -O -inline " ~ commands);
 	}
 	
 	return ret;