From 3d5f555407cb1c162fa6a1d3135f8b0e8773a3cf Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 25 Aug 2011 14:42:03 +1000 Subject: [PATCH] Allow a custom kernel path to be entered on the command line. --- configure.ac | 2 +- main.c | 11 +++++++++++ miner.h | 1 + ocl.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 795f50d1..8092757a 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 b4bd3fb3..76a515e1 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 f928563a..89894ebc 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 5977e065..6ababb64 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");