Index: trunk/scconfig/plugin_3state.h =================================================================== --- trunk/scconfig/plugin_3state.h (revision 29654) +++ trunk/scconfig/plugin_3state.h (nonexistent) @@ -1,63 +0,0 @@ -/* 3-state plugin system; possible states of each plugin, stored in - /local/pcb/PLUGIN_NAME/controls: - "disable" = do not compile it at all - "buildin" = enable, static link into the executable - "plugin" = enable, make it a dynamic link library (runtime load plugin) -*/ - -#define sdisable "disable" -#define sbuildin "buildin" -#define splugin "plugin" - - -/* Macros to check the state */ - -#define plug_eq(name, val) \ - ((get("/local/pcb/" name "/controls") != NULL) && (strcmp(get("/local/pcb/" name "/controls"), val) == 0)) - -#define plug_is_enabled(name) (plug_eq(name, splugin) || plug_eq(name, sbuildin)) -#define plug_is_disabled(name) (plug_eq(name, sdisabled)) -#define plug_is_buildin(name) (plug_eq(name, sbuildin)) -#define plug_is_plugin(name) (plug_eq(name, splugin)) - -/* auto-set tables to change control to the desired value */ -const arg_auto_set_node_t arg_disable[] = { - {"controls", sdisable}, - {"explicit", sdisable}, - {NULL, NULL} -}; - -const arg_auto_set_node_t arg_Disable[] = { - {"controls", sdisable}, - {NULL, NULL} -}; - -const arg_auto_set_node_t arg_buildin[] = { - {"controls", sbuildin}, - {"explicit", sbuildin}, - {NULL, NULL} -}; - -const arg_auto_set_node_t arg_plugin[] = { - {"controls", splugin}, - {"explicit", splugin}, - {NULL, NULL} -}; - - -/* plugin_def implementation to create CLI args */ -#define plugin3_args(name, desc) \ - {"disable-" name, "/local/pcb/" name, arg_disable, "$do not compile " desc}, \ - {"Disable-" name, "/local/pcb/" name, arg_Disable, NULL }, \ - {"buildin-" name, "/local/pcb/" name, arg_buildin, "$static link " desc " into the executable"}, \ - {"plugin-" name, "/local/pcb/" name, arg_plugin, "$" desc " is a dynamic loadable plugin"}, - - -/* plugin_def implementation to set default state */ -#define plugin3_default(name, default_) \ - db_mkdir("/local/pcb/" name); \ - put("/local/pcb/" name "/controls", default_); - -/* plugin_def implementation to print a report with the final state */ -#define plugin3_stat(name, desc) \ - plugin_stat(desc, "/local/pcb/" name "/controls", name); Index: trunk/scconfig/Makefile =================================================================== --- trunk/scconfig/Makefile (revision 29654) +++ trunk/scconfig/Makefile (revision 29655) @@ -61,7 +61,7 @@ # --- you shouldn't edit the lines below --- OBJS = $(USER_OBJS) hooks.o $(DEFAULT_NOMAIN_OBJS) $(SCRIPT_OBJS) $(PARSER_OBJS) $(GENERATOR_OBJS) $(TMPASM_OBJS) $(C99_OBJS) $(PARSGEN_OBJS) $(MATH_OBJS) $(SOCKET_OBJS) $(USERPASS_OBJS) $(GUI_OBJS) $(SUL_OBJS) -CFLAGS = $(USER_CFLAGS) $(DEFAULT_CFLAGS) $(SCRIPT_CFLAGS) $(PARSER_CFLAGS) $(GENERATOR_CFLAGS) $(TMPASM_CFLAGS) $(C99_CFLAGS) $(PARSGEN_CFLAGS) $(MATH_CFLAGS) $(SOCKET_CFLAGS) $(USERPASS_CFLAGS) $(GUI_CFLAGS) $(SUL_CFLAGS) $(MENULIB_CFLAGS) -Isrc/default +CFLAGS = $(USER_CFLAGS) $(DEFAULT_CFLAGS) $(SCRIPT_CFLAGS) $(PARSER_CFLAGS) $(GENERATOR_CFLAGS) $(TMPASM_CFLAGS) $(C99_CFLAGS) $(PARSGEN_CFLAGS) $(MATH_CFLAGS) $(SOCKET_CFLAGS) $(USERPASS_CFLAGS) $(GUI_CFLAGS) $(SUL_CFLAGS) $(MENULIB_CFLAGS) -Isrc/default -I. LDFLAGS = $(USER_LDFLAGS) $(DEFAULT_LDFLAGS) $(SCRIPT_LDFLAGS) $(PARSER_LDFLAGS) $(GENERATOR_LDFLAGS) $(TMPASM_LDFLAGS) $(C99_LDFLAGS) $(PARSGEN_LDFLAGS) $(MATH_LDFLAGS) $(SOCKET_LDFLAGS) $(USERPASS_LDFLAGS) $(GUI_LDFLAGS) $(SUL_LDFLAGS) $(MENULIB_LDFLAGS) all: configure revtest sccbox @@ -84,7 +84,7 @@ menucfg.o: menucfg.c $(CC) -c $(CFLAGS) -o menucfg.o menucfg.c -hooks.o: plugin_3state.h plugins.h Rev.h ../src_3rd/puplug/scconfig_hooks.h ../src_3rd/libfungw/scconfig_hooks.h +hooks.o: librnd/scconfig/plugin_3state.h librnd/scconfig/hooks_common.h plugins.h Rev.h ../src_3rd/puplug/scconfig_hooks.h ../src_3rd/libfungw/scconfig_hooks.h src/util/arg_auto_set.o: src/util/arg_auto_set.c src/util/arg_auto_set.h $(CC) -c $(CFLAGS) -o src/util/arg_auto_set.o src/util/arg_auto_set.c Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 29654) +++ trunk/scconfig/Rev.h (revision 29655) @@ -1 +1 @@ -static const int myrev = 29647; +static const int myrev = 29655; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 29654) +++ trunk/scconfig/Rev.tab (revision 29655) @@ -1,3 +1,4 @@ +29655 configure librnd separation: scconfig hooks code 29647 configure generalize the toolbar code so it can be reused in camv-rnd and sch-rnd 29567 configure import_sch conf changes, new netlist import formats 29412 configure move generic actions from core to librnd Index: trunk/scconfig/hooks.c =================================================================== --- trunk/scconfig/hooks.c (revision 29654) +++ trunk/scconfig/hooks.c (revision 29655) @@ -12,11 +12,12 @@ #define version "2.2.0" -#include "plugin_3state.h" - #include "../src_3rd/puplug/scconfig_hooks.h" #include "../src_3rd/libfungw/scconfig_hooks.h" +#include "librnd/scconfig/plugin_3state.h" +#include "librnd/scconfig/hooks_common.h" + int want_coord_bits; /* if any of these are enabled, we need the dialog plugin; dialog can not be @@ -55,74 +56,32 @@ static void help1(void) { - argtbl_t *a; + help1_common("pcb-rnd"); - printf("./configure: configure pcb-rnd.\n"); - printf("\n"); - printf("Usage: ./configure [options]\n"); - printf("\n"); - printf("options are:\n"); - printf(" --prefix=path change installation prefix from /usr/local to path\n"); - printf(" --debug build full debug version (-g -O0, extra asserts)\n"); - printf(" --profile build profiling version if available (-pg)\n"); - printf(" --symbols include symbols (add -g, but no -O0 or extra asserts)\n"); printf(" --coord=32|64 set coordinate integer type's width in bits\n"); printf(" --dot_pcb_pcb=path .pcb-rnd config path under $HOME/\n"); printf(" --workaround-gtk-ctrl enable GTK control key query workaround\n"); - printf(" --man1dir=path change installation path of man1 files (under prefix)\n"); - printf(" --libarchdir=relpath relative path under prefix for arch-lib-dir (e.g. lib64)\n"); - printf(" --confdir=path change installed conf path (normally matches sharedir)\n"); - printf(" --all=plugin enable all working plugins for dynamic load\n"); - printf(" --all=buildin enable all working plugins for static link\n"); - printf(" --all=disable disable all plugins (compile core only)\n"); - printf(" --force-all=plugin enable even broken plugins for dynamic load\n"); - printf(" --force-all=buildin enable even broken plugins for static link\n"); } -static void help2(void) -{ - printf("\n"); - printf("Some of the --disable options will make ./configure to skip detection of the given feature and mark them \"not found\"."); - printf("\n"); -} - -char *repeat = NULL; -#define report_repeat(msg) \ -do { \ - report(msg); \ - if (repeat != NULL) { \ - char *old = repeat; \ - repeat = str_concat("", old, msg, NULL); \ - free(old); \ - } \ - else \ - repeat = strclone(msg); \ -} while(0) - -static void all_plugin_select(const char *state, int force); - /* Runs when a custom command line argument is found returns true if no further argument processing should be done */ int hook_custom_arg(const char *key, const char *value) { - if (strcmp(key, "prefix") == 0) { - report("Setting prefix to '%s'\n", value); - put("/local/prefix", strclone(value)); + hook_custom_arg_common(key, value); + if (strncmp(key, "workaround-", 11) == 0) { + const char *what = key+11; + if (strcmp(what, "gtk-ctrl") == 0) append("/local/pcb/workaround_defs", "\n#define PCB_WORKAROUND_GTK_CTRL 1"); + else if (strcmp(what, "gtk-shift") == 0) append("/local/pcb/workaround_defs", "\n#define PCB_WORKAROUND_GTK_SHIFT 1"); + else { + report("ERROR: unknown workaround '%s'\n", what); + exit(1); + } return 1; } - if (strcmp(key, "debug") == 0) { - put("/local/pcb/debug", strue); - pup_set_debug(strue); + if ((strcmp(key, "with-intl") == 0) || (strcmp(key, "enable-intl") == 0)) { + report("ERROR: --with-intl is no longer supported, please do not use it\n"); return 1; } - if (strcmp(key, "profile") == 0) { - put("/local/pcb/profile", strue); - return 1; - } - if (strcmp(key, "symbols") == 0) { - put("/local/pcb/symbols", strue); - return 1; - } if (strcmp(key, "coord") == 0) { int v = atoi(value); if ((v != 32) && (v != 64)) { @@ -133,54 +92,10 @@ want_coord_bits = v; return 1; } - if ((strcmp(key, "all") == 0) || (strcmp(key, "force-all") == 0)) { - if ((strcmp(value, sbuildin) == 0) || (strcmp(value, splugin) == 0) || (strcmp(value, sdisable) == 0)) { - all_plugin_select(value, (key[0] == 'f')); - return 1; - } - report("Error: unknown --all argument: %s\n", value); - exit(1); - } - if (strcmp(key, "coord") == 0) { + if (strcmp(key, "dot_pcb_rnd") == 0) { put("/local/pcb/dot_pcb_rnd", value); return 1; } - if (strcmp(key, "man1dir") == 0) { - put("/local/man1dir", value); - return 1; - } - if (strcmp(key, "libarchdir") == 0) { - put("/local/libarchdir", value); - return 1; - } - if (strcmp(key, "confdir") == 0) { - put("/local/confdir", value); - return 1; - } - if (strncmp(key, "workaround-", 11) == 0) { - const char *what = key+11; - if (strcmp(what, "gtk-ctrl") == 0) append("/local/pcb/workaround_defs", "\n#define PCB_WORKAROUND_GTK_CTRL 1"); - else if (strcmp(what, "gtk-shift") == 0) append("/local/pcb/workaround_defs", "\n#define PCB_WORKAROUND_GTK_SHIFT 1"); - else { - report("ERROR: unknown workaround '%s'\n", what); - exit(1); - } - return 1; - } - if ((strcmp(key, "with-intl") == 0) || (strcmp(key, "enable-intl") == 0)) { - report("ERROR: --with-intl is no longer supported, please do not use it\n"); - return 1; - } - else if (strcmp(key, "help") == 0) { - help1(); - printf("\nplugin control:\n"); - arg_auto_print_options(stdout, " ", " ", disable_libs); - help2(); - printf("\n"); - help_default_args(stdout, ""); - exit(0); - } - if (arg_auto_set(key, value, disable_libs) == 0) { fprintf(stderr, "Error: unknown argument %s\n", key); exit(1); @@ -188,114 +103,6 @@ return 1; /* handled by arg_auto_set() */ } -/* execute plugin dependency statements, depending on "require": - require = 0 - attempt to mark any dep as buildin - require = 1 - check if dependencies are met, disable plugins that have - unmet deps -*/ -int plugin_dep1(int require, const char *plugin, const char *deps_on, int hidlib) -{ - char buff[1024]; - const char *st_plugin, *st_deps_on; - int dep_chg = 0; - - sprintf(buff, "/local/pcb/%s/hidlib", plugin); - if (!hidlib) { /* may be inherited */ - hidlib = get(buff) != NULL; - } - - if (hidlib) { - put(buff, strue); - sprintf(buff, "/local/pcb/%s/hidlib", deps_on); - put(buff, strue); - } - - sprintf(buff, "/local/pcb/%s/controls", plugin); - st_plugin = get(buff); - sprintf(buff, "/local/pcb/%s/controls", deps_on); - st_deps_on = get(buff); - - if (require) { - if ((strcmp(st_plugin, sbuildin) == 0)) { - if (strcmp(st_deps_on, sbuildin) != 0) { - sprintf(buff, "WARNING: disabling (ex-buildin) %s because the %s is not enabled as a buildin...\n", plugin, deps_on); - report_repeat(buff); - sprintf(buff, "disable-%s", plugin); - hook_custom_arg(buff, NULL); - dep_chg++; - } - } - else if ((strcmp(st_plugin, splugin) == 0)) { - if ((strcmp(st_deps_on, sbuildin) != 0) && (strcmp(st_deps_on, splugin) != 0)) { - sprintf(buff, "WARNING: disabling (ex-plugin) %s because the %s is not enabled as a buildin or plugin...\n", plugin, deps_on); - report_repeat(buff); - sprintf(buff, "disable-%s", plugin); - hook_custom_arg(buff, NULL); - dep_chg++; - } - } - } - else { - if (strcmp(st_plugin, sbuildin) == 0) - put(buff, sbuildin); - else if (strcmp(st_plugin, splugin) == 0) { - if ((st_deps_on == NULL) || (strcmp(st_deps_on, "disable") == 0)) - put(buff, splugin); - } - dep_chg++; - } - return dep_chg; -} - -static void all_plugin_select(const char *state, int force) -{ - char buff[1024]; - -#undef plugin_def -#undef plugin_header -#undef plugin_dep -#define plugin_def(name, desc, default_, all_, hidlib_) \ - if ((all_) || force) { \ - sprintf(buff, "/local/pcb/%s/controls", name); \ - put(buff, state); \ - } -#define plugin_header(sect) -#define plugin_dep(plg, on, hidlib) -#include "plugins.h" -} - -/* set up /hidlib nodes in the db to indicate which plugins are in the hidlib */ -static void plugin_db_hidlib(void) -{ - char buff[1024]; - -#undef plugin_def -#undef plugin_header -#undef plugin_dep -#define plugin_def(name, desc, default_, all_, hidlib_) \ - if (hidlib_) { \ - sprintf(buff, "/local/pcb/%s/hidlib", name); \ - put(buff, strue); \ - } -#define plugin_header(sect) -#define plugin_dep(plg, on, hidlib) -#include "plugins.h" -} - -int plugin_deps(int require) -{ - int dep_chg = 0; -#undef plugin_def -#undef plugin_header -#undef plugin_dep -#define plugin_def(name, desc, default_, all_, hidlib_) -#define plugin_header(sect) -#define plugin_dep(plg, on, hidlib) dep_chg += plugin_dep1(require, plg, on, hidlib); -#include "plugins.h" - return dep_chg; -} - - /* Runs before anything else */ int hook_preinit() { @@ -311,24 +118,9 @@ pup_hook_postinit(); fungw_hook_postinit(); - /* DEFAULTS */ - put("/local/prefix", "/usr/local"); - put("/local/man1dir", "/share/man/man1"); - put("/local/libarchdir", "lib"); - put("/local/confdir", ""); + hook_postinit_common(); -#undef plugin_def -#undef plugin_header -#undef plugin_dep -#define plugin_def(name, desc, default_, all_, hidlib_) plugin3_default(name, default_) -#define plugin_header(sect) -#define plugin_dep(plg, on, hidlib) -#include "plugins.h" - put("/local/pcb/want_bison", sfalse); - put("/local/pcb/debug", sfalse); - put("/local/pcb/profile", sfalse); - put("/local/pcb/symbols", sfalse); put("/local/pcb/coord_bits", "32"); want_coord_bits = 32; put("/local/pcb/dot_pcb_rnd", ".pcb-rnd"); @@ -336,43 +128,10 @@ return 0; } -static int all_plugin_check_explicit(void) -{ - char pwanted[1024], pgot[1024]; - const char *wanted, *got; - int tainted = 0; - -#undef plugin_def -#undef plugin_header -#undef plugin_dep -#define plugin_def(name, desc, default_, all_, hidlib_) \ - sprintf(pwanted, "/local/pcb/%s/explicit", name); \ - wanted = get(pwanted); \ - if (wanted != NULL) { \ - sprintf(pgot, "/local/pcb/%s/controls", name); \ - got = get(pgot); \ - if (strcmp(got, wanted) != 0) {\ - report("ERROR: %s was requested to be %s but I had to %s it\n", name, wanted, got); \ - tainted = 1; \ - } \ - } -#define plugin_header(sect) -#define plugin_dep(plg, on, hidlib) -#include "plugins.h" - return tainted; -} - - /* Runs after all arguments are read and parsed */ int hook_postarg() { - int limit = 128; - - /* repeat as long as there are changes - this makes it "recursive" on - resolving deps */ - while(plugin_deps(0) && (limit > 0)) limit--; - - return 0; + return hook_postarg_common(); } @@ -400,13 +159,6 @@ return 0; } -int safe_atoi(const char *s) -{ - if (s == NULL) - return 0; - return atoi(s); -} - /* figure if we need the dialogs plugin */ static void calc_dialog_deps(void) { @@ -875,53 +627,6 @@ } #endif -static void plugin_stat(const char *header, const char *path, const char *name) -{ - const char *val = get(path); - - if (*header == '#') /* don't print hidden plugins */ - return; - - printf(" %-32s", header); - - if (val == NULL) - printf("??? (NULL) "); - else if (strcmp(val, sbuildin) == 0) - printf("yes, buildin "); - else if (strcmp(val, splugin) == 0) - printf("yes, PLUGIN "); - else - printf("no "); - - printf(" [%s]\n", name); -} - -static void print_sum_setting_or(const char *node, const char *desc, int or) -{ - const char *res, *state; - state = get(node); - if (or) - res = "enabled (implicit)"; - else if (istrue(state)) - res = "enabled"; - else if (isfalse(state)) - res = "disabled"; - else - res = "UNKNOWN - disabled?"; - printf("%-55s %s\n", desc, res); -} - -static void print_sum_setting(const char *node, const char *desc) -{ - print_sum_setting_or(node, desc, 0); -} - -static void print_sum_cfg_val(const char *node, const char *desc) -{ - const char *state = get(node); - printf("%-55s %s\n", desc, state); -} - /* Runs after detection hooks, should generate the output (Makefiles, etc.) */ int hook_generate() { Index: trunk/scconfig/librnd/scconfig/hooks_common.h =================================================================== --- trunk/scconfig/librnd/scconfig/hooks_common.h (nonexistent) +++ trunk/scconfig/librnd/scconfig/hooks_common.h (revision 29655) @@ -0,0 +1,331 @@ +/* the caller needs to provide these: */ +static void help1(void); +const arg_auto_set_t disable_libs[]; +int hook_custom_arg(const char *key, const char *value); + + + +/*** implementation ***/ +static void all_plugin_select(const char *state, int force); + +static void help1_common(const char *progname) +{ + printf("./configure: configure %s.\n", progname); + printf("\n"); + printf("Usage: ./configure [options]\n"); + printf("\n"); + printf("options are:\n"); + printf(" --prefix=path change installation prefix from /usr/local to path\n"); + printf(" --debug build full debug version (-g -O0, extra asserts)\n"); + printf(" --profile build profiling version if available (-pg)\n"); + printf(" --symbols include symbols (add -g, but no -O0 or extra asserts)\n"); + printf(" --man1dir=path change installation path of man1 files (under prefix)\n"); + printf(" --libarchdir=relpath relative path under prefix for arch-lib-dir (e.g. lib64)\n"); + printf(" --confdir=path change installed conf path (normally matches sharedir)\n"); + printf(" --all=plugin enable all working plugins for dynamic load\n"); + printf(" --all=buildin enable all working plugins for static link\n"); + printf(" --all=disable disable all plugins (compile core only)\n"); + printf(" --force-all=plugin enable even broken plugins for dynamic load\n"); + printf(" --force-all=buildin enable even broken plugins for static link\n"); +} + +static void help2(void) +{ + printf("\n"); + printf("Some of the --disable options will make ./configure to skip detection of the given feature and mark them \"not found\"."); + printf("\n"); +} + +char *repeat = NULL; +#define report_repeat(msg) \ +do { \ + report(msg); \ + if (repeat != NULL) { \ + char *old = repeat; \ + repeat = str_concat("", old, msg, NULL); \ + free(old); \ + } \ + else \ + repeat = strclone(msg); \ +} while(0) + +static int hook_custom_arg_common_(const char *key, const char *value) +{ + if (strcmp(key, "prefix") == 0) { + report("Setting prefix to '%s'\n", value); + put("/local/prefix", strclone(value)); + return 1; + } + if (strcmp(key, "debug") == 0) { + put("/local/pcb/debug", strue); + pup_set_debug(strue); + return 1; + } + if (strcmp(key, "profile") == 0) { + put("/local/pcb/profile", strue); + return 1; + } + if (strcmp(key, "symbols") == 0) { + put("/local/pcb/symbols", strue); + return 1; + } + if ((strcmp(key, "all") == 0) || (strcmp(key, "force-all") == 0)) { + if ((strcmp(value, sbuildin) == 0) || (strcmp(value, splugin) == 0) || (strcmp(value, sdisable) == 0)) { + all_plugin_select(value, (key[0] == 'f')); + return 1; + } + report("Error: unknown --all argument: %s\n", value); + exit(1); + } + if (strcmp(key, "man1dir") == 0) { + put("/local/man1dir", value); + return 1; + } + if (strcmp(key, "libarchdir") == 0) { + put("/local/libarchdir", value); + return 1; + } + if (strcmp(key, "confdir") == 0) { + put("/local/confdir", value); + return 1; + } + if (strcmp(key, "help") == 0) { + help1(); + printf("\nplugin control:\n"); + arg_auto_print_options(stdout, " ", " ", disable_libs); + help2(); + printf("\n"); + help_default_args(stdout, ""); + exit(0); + } + return 0; +} + +#define hook_custom_arg_common(key, value) \ +do { \ + if (hook_custom_arg_common_(key, value)) \ + return 1; \ +} while(0) + +/* execute plugin dependency statements, depending on "require": + require = 0 - attempt to mark any dep as buildin + require = 1 - check if dependencies are met, disable plugins that have + unmet deps +*/ +int plugin_dep1(int require, const char *plugin, const char *deps_on, int hidlib) +{ + char buff[1024]; + const char *st_plugin, *st_deps_on; + int dep_chg = 0; + + sprintf(buff, "/local/pcb/%s/hidlib", plugin); + if (!hidlib) { /* may be inherited */ + hidlib = get(buff) != NULL; + } + + if (hidlib) { + put(buff, strue); + sprintf(buff, "/local/pcb/%s/hidlib", deps_on); + put(buff, strue); + } + + sprintf(buff, "/local/pcb/%s/controls", plugin); + st_plugin = get(buff); + sprintf(buff, "/local/pcb/%s/controls", deps_on); + st_deps_on = get(buff); + + if (require) { + if ((strcmp(st_plugin, sbuildin) == 0)) { + if (strcmp(st_deps_on, sbuildin) != 0) { + sprintf(buff, "WARNING: disabling (ex-buildin) %s because the %s is not enabled as a buildin...\n", plugin, deps_on); + report_repeat(buff); + sprintf(buff, "disable-%s", plugin); + hook_custom_arg(buff, NULL); + dep_chg++; + } + } + else if ((strcmp(st_plugin, splugin) == 0)) { + if ((strcmp(st_deps_on, sbuildin) != 0) && (strcmp(st_deps_on, splugin) != 0)) { + sprintf(buff, "WARNING: disabling (ex-plugin) %s because the %s is not enabled as a buildin or plugin...\n", plugin, deps_on); + report_repeat(buff); + sprintf(buff, "disable-%s", plugin); + hook_custom_arg(buff, NULL); + dep_chg++; + } + } + } + else { + if (strcmp(st_plugin, sbuildin) == 0) + put(buff, sbuildin); + else if (strcmp(st_plugin, splugin) == 0) { + if ((st_deps_on == NULL) || (strcmp(st_deps_on, "disable") == 0)) + put(buff, splugin); + } + dep_chg++; + } + return dep_chg; +} + +static void all_plugin_select(const char *state, int force) +{ + char buff[1024]; + +#undef plugin_def +#undef plugin_header +#undef plugin_dep +#define plugin_def(name, desc, default_, all_, hidlib_) \ + if ((all_) || force) { \ + sprintf(buff, "/local/pcb/%s/controls", name); \ + put(buff, state); \ + } +#define plugin_header(sect) +#define plugin_dep(plg, on, hidlib) +#include "plugins.h" +} + +/* set up /hidlib nodes in the db to indicate which plugins are in the hidlib */ +static void plugin_db_hidlib(void) +{ + char buff[1024]; + +#undef plugin_def +#undef plugin_header +#undef plugin_dep +#define plugin_def(name, desc, default_, all_, hidlib_) \ + if (hidlib_) { \ + sprintf(buff, "/local/pcb/%s/hidlib", name); \ + put(buff, strue); \ + } +#define plugin_header(sect) +#define plugin_dep(plg, on, hidlib) +#include "plugins.h" +} + +int plugin_deps(int require) +{ + int dep_chg = 0; +#undef plugin_def +#undef plugin_header +#undef plugin_dep +#define plugin_def(name, desc, default_, all_, hidlib_) +#define plugin_header(sect) +#define plugin_dep(plg, on, hidlib) dep_chg += plugin_dep1(require, plg, on, hidlib); +#include "plugins.h" + return dep_chg; +} + + +void hook_postinit_common() +{ + /* DEFAULTS */ + put("/local/prefix", "/usr/local"); + put("/local/man1dir", "/share/man/man1"); + put("/local/libarchdir", "lib"); + put("/local/confdir", ""); + put("/local/pcb/debug", sfalse); + put("/local/pcb/profile", sfalse); + put("/local/pcb/symbols", sfalse); + +#undef plugin_def +#undef plugin_header +#undef plugin_dep +#define plugin_def(name, desc, default_, all_, hidlib_) plugin3_default(name, default_) +#define plugin_header(sect) +#define plugin_dep(plg, on, hidlib) +#include "plugins.h" + +} + + +static int all_plugin_check_explicit(void) +{ + char pwanted[1024], pgot[1024]; + const char *wanted, *got; + int tainted = 0; + +#undef plugin_def +#undef plugin_header +#undef plugin_dep +#define plugin_def(name, desc, default_, all_, hidlib_) \ + sprintf(pwanted, "/local/pcb/%s/explicit", name); \ + wanted = get(pwanted); \ + if (wanted != NULL) { \ + sprintf(pgot, "/local/pcb/%s/controls", name); \ + got = get(pgot); \ + if (strcmp(got, wanted) != 0) {\ + report("ERROR: %s was requested to be %s but I had to %s it\n", name, wanted, got); \ + tainted = 1; \ + } \ + } +#define plugin_header(sect) +#define plugin_dep(plg, on, hidlib) +#include "plugins.h" + return tainted; +} + + +/* Runs after all arguments are read and parsed */ +int hook_postarg_common() +{ + int limit = 128; + + /* repeat as long as there are changes - this makes it "recursive" on + resolving deps */ + while(plugin_deps(0) && (limit > 0)) limit--; + + return 0; +} + +int safe_atoi(const char *s) +{ + if (s == NULL) + return 0; + return atoi(s); +} + +static void plugin_stat(const char *header, const char *path, const char *name) +{ + const char *val = get(path); + + if (*header == '#') /* don't print hidden plugins */ + return; + + printf(" %-32s", header); + + if (val == NULL) + printf("??? (NULL) "); + else if (strcmp(val, sbuildin) == 0) + printf("yes, buildin "); + else if (strcmp(val, splugin) == 0) + printf("yes, PLUGIN "); + else + printf("no "); + + printf(" [%s]\n", name); +} + +static void print_sum_setting_or(const char *node, const char *desc, int or) +{ + const char *res, *state; + state = get(node); + if (or) + res = "enabled (implicit)"; + else if (istrue(state)) + res = "enabled"; + else if (isfalse(state)) + res = "disabled"; + else + res = "UNKNOWN - disabled?"; + printf("%-55s %s\n", desc, res); +} + +static void print_sum_setting(const char *node, const char *desc) +{ + print_sum_setting_or(node, desc, 0); +} + +static void print_sum_cfg_val(const char *node, const char *desc) +{ + const char *state = get(node); + printf("%-55s %s\n", desc, state); +} Index: trunk/scconfig/librnd/scconfig/plugin_3state.h =================================================================== --- trunk/scconfig/librnd/scconfig/plugin_3state.h (nonexistent) +++ trunk/scconfig/librnd/scconfig/plugin_3state.h (revision 29655) @@ -0,0 +1,63 @@ +/* 3-state plugin system; possible states of each plugin, stored in + /local/pcb/PLUGIN_NAME/controls: + "disable" = do not compile it at all + "buildin" = enable, static link into the executable + "plugin" = enable, make it a dynamic link library (runtime load plugin) +*/ + +#define sdisable "disable" +#define sbuildin "buildin" +#define splugin "plugin" + + +/* Macros to check the state */ + +#define plug_eq(name, val) \ + ((get("/local/pcb/" name "/controls") != NULL) && (strcmp(get("/local/pcb/" name "/controls"), val) == 0)) + +#define plug_is_enabled(name) (plug_eq(name, splugin) || plug_eq(name, sbuildin)) +#define plug_is_disabled(name) (plug_eq(name, sdisabled)) +#define plug_is_buildin(name) (plug_eq(name, sbuildin)) +#define plug_is_plugin(name) (plug_eq(name, splugin)) + +/* auto-set tables to change control to the desired value */ +const arg_auto_set_node_t arg_disable[] = { + {"controls", sdisable}, + {"explicit", sdisable}, + {NULL, NULL} +}; + +const arg_auto_set_node_t arg_Disable[] = { + {"controls", sdisable}, + {NULL, NULL} +}; + +const arg_auto_set_node_t arg_buildin[] = { + {"controls", sbuildin}, + {"explicit", sbuildin}, + {NULL, NULL} +}; + +const arg_auto_set_node_t arg_plugin[] = { + {"controls", splugin}, + {"explicit", splugin}, + {NULL, NULL} +}; + + +/* plugin_def implementation to create CLI args */ +#define plugin3_args(name, desc) \ + {"disable-" name, "/local/pcb/" name, arg_disable, "$do not compile " desc}, \ + {"Disable-" name, "/local/pcb/" name, arg_Disable, NULL }, \ + {"buildin-" name, "/local/pcb/" name, arg_buildin, "$static link " desc " into the executable"}, \ + {"plugin-" name, "/local/pcb/" name, arg_plugin, "$" desc " is a dynamic loadable plugin"}, + + +/* plugin_def implementation to set default state */ +#define plugin3_default(name, default_) \ + db_mkdir("/local/pcb/" name); \ + put("/local/pcb/" name "/controls", default_); + +/* plugin_def implementation to print a report with the final state */ +#define plugin3_stat(name, desc) \ + plugin_stat(desc, "/local/pcb/" name "/controls", name); Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 29654) +++ trunk/src/Makefile.in (revision 29655) @@ -559,7 +559,7 @@ $(SCCBOX) $(HOW) "default_font" "$(DATADIR)/default_font"@/local/pcb/rules/install_@ install_librnd: librnd - $(SCCBOX) mkdir -p "$(HL_LIBDIR)/librnd" "$(HL_INCDIR)/core" "$(HL_INCDIR)/poly" "$(HL_INCDIR)/src_3rd/liblihata" "$(HL_INCDIR)/src_3rd/liblhtpers" "$(HL_INCDIR)/src_3rd/puplug" "$(HL_INCDIR)/src_3rd/libfungw" "$(HL_INCDIR)/src_3rd/genvector" "$(HL_INCDIR)/src_3rd/genregex" "$(HL_INCDIR)/src_3rd/genrtree" "$(HL_INCDIR)/src_3rd/genlist" "$(HL_INCDIR)/src_3rd/genht" "$(HL_INCDIR)/src_3rd/libfungwbind/c" "$(HL_SHAREDIR)" + $(SCCBOX) mkdir -p "$(HL_LIBDIR)/librnd" "$(HL_INCDIR)/core" "$(HL_INCDIR)/poly" "$(HL_INCDIR)/scconfig" "$(HL_INCDIR)/src_3rd/liblihata" "$(HL_INCDIR)/src_3rd/liblhtpers" "$(HL_INCDIR)/src_3rd/puplug" "$(HL_INCDIR)/src_3rd/libfungw" "$(HL_INCDIR)/src_3rd/genvector" "$(HL_INCDIR)/src_3rd/genregex" "$(HL_INCDIR)/src_3rd/genrtree" "$(HL_INCDIR)/src_3rd/genlist" "$(HL_INCDIR)/src_3rd/genht" "$(HL_INCDIR)/src_3rd/libfungwbind/c" "$(HL_SHAREDIR)" $(SCCBOX) $(HOW) "librnd-hid.so.$(PCB_RND_VER)" "$(HL_LIBDIR)/librnd-hid.so.$(PCB_RND_VER)" $(SCCBOX) $(HOW) "librnd-hid.a" "$(HL_LIBDIR)/librnd-hid.a" $(SCCBOX) $(HOW) "librnd-3rd.so.$(PCB_RND_VER)" "$(HL_LIBDIR)/librnd-3rd.so.$(PCB_RND_VER)" @@ -570,6 +570,8 @@ $(SCCBOX) $(HOW) "../config.h" "$(HL_INCDIR)/core/config.h" $(SCCBOX) $(HOW) "../src_3rd/puplug/util/puplug" "$(HL_LIBDIR)/librnd/puplug" $(SCCBOX) $(HOW) "../scconfig/gen_conf.sh" "$(HL_LIBDIR)/librnd/gen_conf" + $(SCCBOX) $(HOW) "../scconfig/librnd/scconfig/hooks_common.h" "$(HL_INCDIR)/scconfig/hooks_common.h" + $(SCCBOX) $(HOW) "../scconfig/librnd/scconfig/plugin_3state.h" "$(HL_INCDIR)/scconfig/plugin_3state.h" cd ../src_3rd/puplug && $(MAKE) install_hdr_ MKDR="../$(SCCBOX) mkdir -p" INST="../$(SCCBOX) $(HOW)" INCDIR="$(HL_INCDIR)/src_3rd/puplug" @]