Commit 3d5f555407cb1c162fa6a1d3135f8b0e8773a3cf

Con Kolivas 2011-08-25T14:42:03

Allow a custom kernel path to be entered on the command line.

diff --git a/configure.ac b/configure.ac
index 795f50d..8092757 100644
--- a/configure.ac
+++ b/configure.ac
@@ -167,7 +167,7 @@ if test "x$prefix" = xNONE; then
 	prefix=/usr
 fi
 
-AC_DEFINE_UNQUOTED([CGMINER_PREFIX], ["$prefix/bin/"], [Path to cgminer install])
+AC_DEFINE_UNQUOTED([CGMINER_PREFIX], ["$prefix/bin"], [Path to cgminer install])
 
 AC_SUBST(OPENCL_LIBS)
 AC_SUBST(JANSSON_LIBS)
diff --git a/main.c b/main.c
index b4bd3fb..76a515e 100644
--- a/main.c
+++ b/main.c
@@ -220,6 +220,7 @@ static int num_processors;
 static int scan_intensity;
 static bool use_curses = true;
 static bool opt_submit_stale;
+char *opt_kernel_path;
 
 #define QUIET	(opt_quiet || opt_realquiet)
 
@@ -1082,6 +1083,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--intensity|-I",
 		     forced_int_1010, opt_show_intval, &scan_intensity,
 		     "Intensity of GPU scanning (-10 -> 10, default: dynamic to maintain desktop interactivity)"),
+	OPT_WITH_ARG("--kernel-path|-K",
+		     opt_set_charp, opt_show_charp, &opt_kernel_path,
+	             "Specify a path to where the kernel .cl files are"),
 	OPT_WITH_ARG("--kernel|-k",
 		     opt_set_charp, NULL, &opt_kernel,
 		     "Select kernel to use (poclbm or phatk - default: auto)"),
@@ -4486,6 +4490,9 @@ int main (int argc, char *argv[])
 	sigaction(SIGTERM, &handler, &termhandler);
 	sigaction(SIGINT, &handler, &inthandler);
 
+	opt_kernel_path = malloc(PATH_MAX);
+	strcat(opt_kernel_path, CGMINER_PREFIX);
+
 	// Hack to make cgminer silent when called recursively on WIN32
 	int skip_to_bench = 0;
 	#if defined(WIN32)
@@ -4557,6 +4564,8 @@ int main (int argc, char *argv[])
 	if (argc != 1)
 		quit(1, "Unexpected extra commandline arguments");
 
+	strcat(opt_kernel_path, "/");
+
 	if (want_per_device_stats)
 		opt_log_output = true;
 
@@ -4922,6 +4931,8 @@ int main (int argc, char *argv[])
 		free(block);
 	}
 
+	free(opt_kernel_path);
+
 	curl_global_cleanup();
 
 	return 0;
diff --git a/miner.h b/miner.h
index f928563..89894eb 100644
--- a/miner.h
+++ b/miner.h
@@ -256,6 +256,7 @@ struct pool;
 extern bool opt_debug;
 extern bool opt_protocol;
 extern bool opt_log_output;
+extern char *opt_kernel_path;
 extern const uint32_t sha256_init_state[];
 extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
 			     const char *rpc_req, bool, bool, bool *,
diff --git a/ocl.c b/ocl.c
index 5977e06..6ababb6 100644
--- a/ocl.c
+++ b/ocl.c
@@ -32,11 +32,11 @@ extern int opt_worksize;
 
 char *file_contents(const char *filename, int *length)
 {
-	char *fullpath = alloca(strlen(CGMINER_PREFIX) + strlen(filename));
+	char *fullpath = alloca(PATH_MAX);
 	void *buffer;
 	FILE *f;
 
-	strcpy(fullpath, CGMINER_PREFIX);
+	strcpy(fullpath, opt_kernel_path);
 	strcat(fullpath, filename);
 
 	f = fopen(filename, "rb");