Allow a custom kernel path to be entered on the command line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
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");