# pcb-rnd hacking - simple core plugins

## Introduction

## Setting up a new core plugin

- 1. make up a name for the plugin. There are a few conventions. This document will refer to the name as plg, always replace it with your chosen name.
- 2. cd src_plugins; svn mkdir plg
- 3. copy Makefile, Plug.tmpasm and README from another, small plugin, for example from the report plugin (the next points will assume you picked this plugin as the source of the copy)
- 4. edit Makefile: replace report to plg
- 5. edit README; there should be short summary about the purpose of the plugin then "#key: value" pairs for statistics:
  - #state: either works or disabled
  - #lstate: if state is disabled, add a new line #lstate: with a few words on why the plugin is disabled
  - #default: disabled or builtin or plugin (this field might be removed later because of redundancy)
  - #implements: the same as the plugin name prefix (see conventions. ) or (feature) for feature plugins; it's redundant but is kept for supporting external plugins
- 6. edit Plug.tmpasm:

      put /local/pcb/mod {plg}
      put /local/pcb/mod/OBJS [@ $(PLUGDIR)/plg/foo.o $(PLUGDIR)/plg/bar.o @]
      put /local/pcb/mod/CONF {$(PLUGDIR)/plg/foo_conf.h}
      put /local/pcb/mod/YACC [@ $(PLUGDIR)/plg/bary @]
      put /local/pcb/mod/LEX  [@ $(PLUGDIR)/plg/barl @]

  - /local/pcb/mod: the name of the module we are compiling
  - /local/pcb/mod/OBJS: a space separated list of object files to compile
  - /local/pcb/mod/CONF: optional: the name of the conf struct header - if the plugin doesn't have runtime configuration settings, remove this line
  - /local/pcb/mod/YACC: optional: if you have files for yacc-processing, list them without the .y suffix here (space separated)
  - /local/pcb/mod/LEX: optional: if you have files for lex-processing, list them without the .l suffix here (space separated)
  - Leave the switch part on the bottom intact.
- 7. create your C sources and headers in src_plugins/plg/
- 8. edit scconfig/plugins.h: copy an existing line and edit it:

      plugin_def("plg",       "short description",       default)

  Default is one of:
  - sbuildin - unless the user requests otherwise, your plugin is linked into the executable
  - sdisable - unless the user requests otherwise, your plugin is not compiled (recommended until the plugin gets some user testing)
  - splugin - unless the user requests otherwise, your plugin is dynamically linked; not recommended: the policy is to let users explicitly request dynamic linking
  The order of entries in the file is the same as the order in the summary table at the end of ./configure; insert your plugin in the right group!
- 9. add your plugin to the build list in one of the src_plugins/plugins_*.tmpasm files; choose the file that lists plugins similar to yours.
- 10. run ./configure --buildin-plg
- 11. run make to see if it compiles and test
- (12. while developing, you can run make from src_plugins/plg - if your plugin is a builtin, it will recompile pcb-rnd. For some of us it's convenient to run make in the same directory where all the source files are.)