Blame PORTING

Packit Service b38f0b
--- INTRODUCTION
Packit Service b38f0b
Packit Service b38f0b
Just a quick note on porting and sending me patches:
Packit Service b38f0b
Packit Service b38f0b
First off, you probably should subscribe to
Packit Service b38f0b
net-snmp-coders@lists.sourceforge.net by sending a message to
Packit Service b38f0b
net-snmp-coders-request@lists.sourceforge.net with a subject line of
Packit Service b38f0b
subscribe.  This is a mailing list to discuss all oft the coding
Packit Service b38f0b
aspects of the project.
Packit Service b38f0b
Packit Service b38f0b
Additionally, you should probably be developing against the latest
Packit Service b38f0b
snapshot of the source code, which can be obtained through the
Packit Service b38f0b
net-snmp cvs server.  Details can be found at
Packit Service b38f0b
http://www.net-snmp.org/cvs/.
Packit Service b38f0b
Packit Service b38f0b
If you send patches to us, it would greatly help us if you sent them
Packit Service b38f0b
to us based on the current checked out copy from CVS.  To do this,
Packit Service b38f0b
send us the output of "cvs diff -u" run in the top level net-snmp
Packit Service b38f0b
source tree after you have modified the files that will fix the
Packit Service b38f0b
problem or add the feature you're submitting the patch for.
Packit Service b38f0b
Packit Service b38f0b
Quite a while back I started using the GNU autoconf testing suite to
Packit Service b38f0b
greatly enhance portability.  Because of this porting to new
Packit Service b38f0b
architectures is much easier than before.  However, new people porting
Packit Service b38f0b
the package to new architectures rarely take advantage of this setup
Packit Service b38f0b
and send me patches with lots of '#ifdef ARCH' type C code in it.  Let
Packit Service b38f0b
me say up front, I *hate* this type of coding now (even though I used
Packit Service b38f0b
to use it a lot).  What is better is to check for the necessary
Packit Service b38f0b
functionality using the configure script and then use the results of
Packit Service b38f0b
those tests.
Packit Service b38f0b
Packit Service b38f0b
To do this, you need to install the GNU 'autoconf' package which also
Packit Service b38f0b
requires the GNU 'm4' (gm4) package as well.  This double installation
Packit Service b38f0b
is extremely easy and shouldn't take you more than 15 minutes max.
Packit Service b38f0b
After that, modify the configure.in and acconfig.h files as needed
Packit Service b38f0b
instead of modifying the config.h or configure files directly.  The
Packit Service b38f0b
Makefile will re-produce these files from the first two.
Packit Service b38f0b
Packit Service b38f0b
Worst case: Don't put in #ifdef architecture style statements.
Packit Service b38f0b
Rather, create a new define in the s/ and m/ system specific header
Packit Service b38f0b
files and use those defines to test against in the C code.  This
Packit Service b38f0b
should only be done for things that can't be checked using configure
Packit Service b38f0b
though.
Packit Service b38f0b
Packit Service b38f0b
Some autoconf examples:
Packit Service b38f0b
Packit Service b38f0b
--- HEADER FILES
Packit Service b38f0b
Packit Service b38f0b
In configure.in:
Packit Service b38f0b
  AC_CHECK_HEADERS(headdir/header.h)
Packit Service b38f0b
Packit Service b38f0b
Then in your source code:
Packit Service b38f0b
  #ifdef HAVE_HEADDIR_HEADER_H
Packit Service b38f0b
    #include <headdir/header.h>
Packit Service b38f0b
  #ENDIF
Packit Service b38f0b
Packit Service b38f0b
--- LIBRARY ROUTIENS
Packit Service b38f0b
Packit Service b38f0b
In configure.in:
Packit Service b38f0b
  AC_CHECK_LIB(libexample, example_function)
Packit Service b38f0b
Packit Service b38f0b
Thats it.  The Makefiles will automatically link against -llibexample
Packit Service b38f0b
if example_function is found in the library.
Packit Service b38f0b
Packit Service b38f0b
--- FUNCTION CHECKS
Packit Service b38f0b
Packit Service b38f0b
In configure.in:
Packit Service b38f0b
  AC_CHECK_FUNCS(example_function)
Packit Service b38f0b
Packit Service b38f0b
In source code:
Packit Service b38f0b
  #ifdef HAVE_EXAMPLE_FUNCTION
Packit Service b38f0b
    /* use it */
Packit Service b38f0b
  #endif
Packit Service b38f0b
Packit Service b38f0b
--- STRUCTURE MEMBER CHECKS
Packit Service b38f0b
Packit Service b38f0b
In configure.in:
Packit Service b38f0b
  AC_CHECK_MEMBERS([struct STRUCTURE.MEMBER],,,[[
Packit Service b38f0b
#include lines
Packit Service b38f0b
]])
Packit Service b38f0b
                           ^^^^^^^^^ ^^^^^^  (change)
Packit Service b38f0b
Packit Service b38f0b
In source code:
Packit Service b38f0b
  #ifdef HAVE_STRUCT_STRUCTURE_MEMBER
Packit Service b38f0b
    /* use it */
Packit Service b38f0b
  #endif
Packit Service b38f0b
Packit Service b38f0b
--- READ THE MANUAL
Packit Service b38f0b
Packit Service b38f0b
The GNU autoconf info files are extremely well written and easy to
Packit Service b38f0b
follow.  Please check them out.
Packit Service b38f0b
Packit Service b38f0b
I'd be happy to help you through anything you don't understand or
Packit Service b38f0b
through more complex examples (eg, checking for structure parts or
Packit Service b38f0b
existance).  I'd be far less happy to get patches ignoring the above
Packit Service b38f0b
request.  If you simple can't abide by this, please send the patches
Packit Service b38f0b
anyway, but it'll just take me longer to get them applied.
Packit Service b38f0b
Packit Service b38f0b
Submit the patch to http://www.net-snmp.org/patches/.
Packit Service b38f0b
Please include what version of the net-snmp package it was applied to
Packit Service b38f0b
and state the arcitectures you have tested it on.
Packit Service b38f0b
Packit Service b38f0b
Thanks a lot for the consideration,
Packit Service b38f0b
Wes