1# @(#)README 8.3 (Berkeley) 02/21/94 2 3This is the area for building the libdb library. There are a number 4of porting directories, for various architecture/OS combinations. Pick 5the one that's closest to yours and try "make". For the rest of this 6file, I'll use "MACH" as a fake architecture/OS name. 7 8To PORT to a new system, create the following subdirectories and 9symbolic links. 10 11 mkdir MACH (for example: mkdir sunos.4.0) 12 cd MACH 13 cp ../Makefile . 14 chmod 664 Makefile 15 ln -s ../clib . 16 mkdir include 17 ln -s include sys 18 cd include 19 ln -s ../../include/*.h . 20 rm compat.h 21 cp ../../include/compat.h . 22 chmod 664 compat.h 23 cd .. 24 25The basic idea is that you now have a local area that you can modify. 26In particular, you have local copies of the Makefile and the include 27file compat.h. Read through the Makefile and compat.h and make whatever 28changes are appropriate to your system. If there's an architecture 29that's close to yours, you probably should diff the Makefile and 30compat.h in that tree against the standard ones and see what changes 31were necessary, as they're probably necessary for you as well. Then, 32enter "make" and see what happens! 33 34There are several subroutines that are found in POSIX 1003.2, ANSI 35C, or 4.4BSD that you may not have. Once you get libdb.a to compile, 36go through the list of undefined routines and add entries to the MISC 37line in the Makefile as necessary. 38 39If you have to add some functions that are missing (and which aren't 40in the PORT/clib directory), please don't add them in the PORT/clib 41directory. Add them in a MACH/local directory, and add lines of the 42form: 43 44 function.o: local/function.o 45 ${CL} -Ilocal local/function.o 46 47to your local Makefile. 48 49Hopefully, over time, we'll develop a set of system directories that 50are known to work. If you send me the changes that were necessary to 51make your system work, this will happen much more quickly. 52 53In some of the system directories, you'll see a file named OTHER_PATCHES. 54This is a set of patches which you'll have to make from the top-level db 55directory to get libdb.a to run on this system: 56 57 cd .. 58 patch < PORT/MACH/OTHER_PATCHES 59 60If patch prompts you for the name of the file to modify (some versions 61of patch don't figure it out on their own) use the file name which patch 62displays. 63 64Some knobs you may have to turn: 65 66In include/compat.h: 67 Before attempting to build libdb, you should look through the 68 compat.h file, and adjust it as necessary for your system. 69 It's possible to use the #ifndef construct to figure out if a 70 #ifdef has been set, but C provides no similar method to figure 71 out if a typedef has been done. Your compile errors should 72 give you a good indication of which ones you need. 73 74You may see warning messages about illegal pointer combinations. Systems 75prototype malloc, calloc and realloc in different places, and the missing 76prototypes will produce such warnings. You may also see lots of warning 77messages about #define's being redefined. These can mostly be ignored. 78In general, I ignore all warning messages until something doesn't work. 79Some systems produce thousands of lines of completely useless warnings. 80 81The other parts of the PORT directory are as follows: 82 83 The directory PORT/clib is a set of functions that the 4.4BSD 84 C library had and which your system may not have. They are 85 added to the MISC line of the Makefile if they aren't defined 86 when you try and load libdb.a. 87 88 The directory PORT/include is header files that the 4.4BSD 89 system had which your system may not have. There is also 90 one really important extra one, named compat.h, which is a 91 set of compatibility work-arounds that you'll almost certainly 92 have to copy and modify for a new system. 93 94 The symbolic link PORT/sys points to the PORT/include directory 95 so that includes of the form <sys/include.h> work. 96 97Some of the more common portability problems: 98 99 If you don't have: 100 101 memmove(3): add memmove.o 102 mkstemp(3): add mktemp.o 103 strerror(3): add strerror.o 104 105 ... to the MISC line in the Makefile. 106 107 If realloc(3) of a NULL pointer on your system isn't the same 108 as a malloc(3) call, add realloc.o to the MISC line in the 109 Makefile. 110 111 If you don't have snprintf/vsnprintf(3), add snprintf.o to the 112 MISC line in the Makefile. This workaround depends on your 113 system having vsprintf(3) -- if you don't, there's no workaround 114 other than changing the source code to not use the snprintf calls. 115 If you have to make that change, check to see if your vsprintf 116 returns a length or a char *; if it's the latter, make sure you 117 set VSPRINTF_CHARSTAR in the MACH/include/compat.h file. 118 119Installing the DB library: 120 121 The Makefile builds a C library named libdb.a. This file needs 122 to be installed in a place where the loader will automatically 123 look for it (or, if you're building it for a single project, 124 wherever that project's Makefile loads it from). 125 126 In addition, the header file PORT/include/db.h must be copied to 127 a directory (often /usr/include/) where programs that use the 128 db package can include it in their source. (If you intend to use 129 the ndbm interface to libdb, you'll need to copy the header file 130 PORT/include/ndbm.h as well.) 131