Browse Source

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

Con Kolivas 14 years ago
parent
commit
3d5f555407
4 changed files with 15 additions and 3 deletions
  1. 1 1
      configure.ac
  2. 11 0
      main.c
  3. 1 0
      miner.h
  4. 2 2
      ocl.c

+ 1 - 1
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)

+ 11 - 0
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;

+ 1 - 0
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 *,

+ 2 - 2
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");