Blame PORTING

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