1*68ba9be9Sbostic# @(#)README 8.4 (Berkeley) 02/21/94 2dde3078dSbostic 392d7b7b3SbosticThis is the area for building the libdb library. There are a number 492d7b7b3Sbosticof porting directories, for various architecture/OS combinations. Pick 592d7b7b3Sbosticthe one that's closest to yours and try "make". For the rest of this 692d7b7b3Sbosticfile, I'll use "MACH" as a fake architecture/OS name. 737cbba89Sbostic 892d7b7b3SbosticTo PORT to a new system, create the following subdirectories and 992d7b7b3Sbosticsymbolic links. 1037cbba89Sbostic 1192d7b7b3Sbostic mkdir MACH (for example: mkdir sunos.4.0) 1292d7b7b3Sbostic cd MACH 1392d7b7b3Sbostic cp ../Makefile . 1492d7b7b3Sbostic chmod 664 Makefile 1592d7b7b3Sbostic ln -s ../clib . 16bfd1e883Sbostic mkdir include 1792d7b7b3Sbostic ln -s include sys 1892d7b7b3Sbostic cd include 1992d7b7b3Sbostic ln -s ../../include/*.h . 2092d7b7b3Sbostic rm compat.h 2192d7b7b3Sbostic cp ../../include/compat.h . 2292d7b7b3Sbostic chmod 664 compat.h 2392d7b7b3Sbostic cd .. 2456a972e5Sbostic 2592d7b7b3SbosticThe basic idea is that you now have a local area that you can modify. 2692d7b7b3SbosticIn particular, you have local copies of the Makefile and the include 2792d7b7b3Sbosticfile compat.h. Read through the Makefile and compat.h and make whatever 2892d7b7b3Sbosticchanges are appropriate to your system. If there's an architecture 2992d7b7b3Sbosticthat's close to yours, you probably should diff the Makefile and 3092d7b7b3Sbosticcompat.h in that tree against the standard ones and see what changes 3192d7b7b3Sbosticwere necessary, as they're probably necessary for you as well. Then, 3292d7b7b3Sbosticenter "make" and see what happens! 3356a972e5Sbostic 34bfd1e883SbosticThere are several subroutines that are found in POSIX 1003.2, ANSI 3592d7b7b3SbosticC, or 4.4BSD that you may not have. Once you get libdb.a to compile, 3692d7b7b3Sbosticgo through the list of undefined routines and add entries to the MISC 3792d7b7b3Sbosticline in the Makefile as necessary. 3892d7b7b3Sbostic 39bfd1e883SbosticIf you have to add some functions that are missing (and which aren't 40bfd1e883Sbosticin the PORT/clib directory), please don't add them in the PORT/clib 41bfd1e883Sbosticdirectory. Add them in a MACH/local directory, and add lines of the 42bfd1e883Sbosticform: 4392d7b7b3Sbostic 4492d7b7b3Sbostic function.o: local/function.o 4592d7b7b3Sbostic ${CL} -Ilocal local/function.o 4692d7b7b3Sbostic 4792d7b7b3Sbosticto your local Makefile. 4892d7b7b3Sbostic 4992d7b7b3SbosticHopefully, over time, we'll develop a set of system directories that 50bfd1e883Sbosticare known to work. If you send me the changes that were necessary to 51bfd1e883Sbosticmake your system work, this will happen much more quickly. 5292d7b7b3Sbostic 5392d7b7b3SbosticIn some of the system directories, you'll see a file named OTHER_PATCHES. 5492d7b7b3SbosticThis is a set of patches which you'll have to make from the top-level db 55bfd1e883Sbosticdirectory to get libdb.a to run on this system: 56bfd1e883Sbostic 57bfd1e883Sbostic cd .. 58bfd1e883Sbostic patch < PORT/MACH/OTHER_PATCHES 59bfd1e883Sbostic 60bfd1e883SbosticIf patch prompts you for the name of the file to modify (some versions 61bfd1e883Sbosticof patch don't figure it out on their own) use the file name which patch 62bfd1e883Sbosticdisplays. 6392d7b7b3Sbostic 6492d7b7b3SbosticSome knobs you may have to turn: 6537cbba89Sbostic 6637cbba89SbosticIn include/compat.h: 67bfd1e883Sbostic Before attempting to build libdb, you should look through the 6892d7b7b3Sbostic compat.h file, and adjust it as necessary for your system. 6937cbba89Sbostic It's possible to use the #ifndef construct to figure out if a 7037cbba89Sbostic #ifdef has been set, but C provides no similar method to figure 7192d7b7b3Sbostic out if a typedef has been done. Your compile errors should 7292d7b7b3Sbostic give you a good indication of which ones you need. 7337cbba89Sbostic 7492d7b7b3SbosticYou may see warning messages about illegal pointer combinations. Systems 7592d7b7b3Sbosticprototype malloc, calloc and realloc in different places, and the missing 7692d7b7b3Sbosticprototypes will produce such warnings. You may also see lots of warning 7792d7b7b3Sbosticmessages about #define's being redefined. These can mostly be ignored. 7892d7b7b3SbosticIn general, I ignore all warning messages until something doesn't work. 7992d7b7b3SbosticSome systems produce thousands of lines of completely useless warnings. 8037cbba89Sbostic 8192d7b7b3SbosticThe other parts of the PORT directory are as follows: 8256a972e5Sbostic 8392d7b7b3Sbostic The directory PORT/clib is a set of functions that the 4.4BSD 8492d7b7b3Sbostic C library had and which your system may not have. They are 8592d7b7b3Sbostic added to the MISC line of the Makefile if they aren't defined 8692d7b7b3Sbostic when you try and load libdb.a. 8756a972e5Sbostic 8892d7b7b3Sbostic The directory PORT/include is header files that the 4.4BSD 89bfd1e883Sbostic system had which your system may not have. There is also 90bfd1e883Sbostic one really important extra one, named compat.h, which is a 91bfd1e883Sbostic set of compatibility work-arounds that you'll almost certainly 92bfd1e883Sbostic have to copy and modify for a new system. 9356a972e5Sbostic 9492d7b7b3Sbostic The symbolic link PORT/sys points to the PORT/include directory 95bfd1e883Sbostic so that includes of the form <sys/include.h> work. 9692d7b7b3Sbostic 9792d7b7b3SbosticSome of the more common portability problems: 9892d7b7b3Sbostic 9992d7b7b3Sbostic If you don't have: 10092d7b7b3Sbostic 101bfd1e883Sbostic memmove(3): add memmove.o 102bfd1e883Sbostic mkstemp(3): add mktemp.o 10392d7b7b3Sbostic 10492d7b7b3Sbostic ... to the MISC line in the Makefile. 10592d7b7b3Sbostic 10692d7b7b3Sbostic If realloc(3) of a NULL pointer on your system isn't the same 10792d7b7b3Sbostic as a malloc(3) call, add realloc.o to the MISC line in the 10892d7b7b3Sbostic Makefile. 10992d7b7b3Sbostic 11092d7b7b3Sbostic If you don't have snprintf/vsnprintf(3), add snprintf.o to the 11192d7b7b3Sbostic MISC line in the Makefile. This workaround depends on your 11292d7b7b3Sbostic system having vsprintf(3) -- if you don't, there's no workaround 11392d7b7b3Sbostic other than changing the source code to not use the snprintf calls. 11492d7b7b3Sbostic If you have to make that change, check to see if your vsprintf 11592d7b7b3Sbostic returns a length or a char *; if it's the latter, make sure you 116bfd1e883Sbostic set VSPRINTF_CHARSTAR in the MACH/include/compat.h file. 117bfd1e883Sbostic 118bfd1e883SbosticInstalling the DB library: 119bfd1e883Sbostic 120bfd1e883Sbostic The Makefile builds a C library named libdb.a. This file needs 121bfd1e883Sbostic to be installed in a place where the loader will automatically 122bfd1e883Sbostic look for it (or, if you're building it for a single project, 123bfd1e883Sbostic wherever that project's Makefile loads it from). 124bfd1e883Sbostic 125bfd1e883Sbostic In addition, the header file PORT/include/db.h must be copied to 126bfd1e883Sbostic a directory (often /usr/include/) where programs that use the 127bfd1e883Sbostic db package can include it in their source. (If you intend to use 128bfd1e883Sbostic the ndbm interface to libdb, you'll need to copy the header file 129bfd1e883Sbostic PORT/include/ndbm.h as well.) 130