xref: /csrg-svn/lib/libc/db/PORT/README (revision 66207)
1*66207Sbostic#	@(#)README	8.4 (Berkeley) 02/21/94
257978Sbostic
364447SbosticThis is the area for building the libdb library.  There are a number
464447Sbosticof porting directories, for various architecture/OS combinations.  Pick
564447Sbosticthe one that's closest to yours and try "make".  For the rest of this
664447Sbosticfile, I'll use "MACH" as a fake architecture/OS name.
757984Sbostic
864447SbosticTo PORT to a new system, create the following subdirectories and
964447Sbosticsymbolic links.
1057984Sbostic
1164447Sbostic	mkdir MACH		(for example: mkdir sunos.4.0)
1264447Sbostic	cd MACH
1364447Sbostic	cp ../Makefile .
1464447Sbostic	chmod 664 Makefile
1564447Sbostic	ln -s ../clib .
1666199Sbostic	mkdir include
1764447Sbostic	ln -s include sys
1864447Sbostic	cd include
1964447Sbostic	ln -s ../../include/*.h .
2064447Sbostic	rm compat.h
2164447Sbostic	cp ../../include/compat.h .
2264447Sbostic	chmod 664 compat.h
2364447Sbostic	cd ..
2457984Sbostic
2564447SbosticThe basic idea is that you now have a local area that you can modify.
2664447SbosticIn particular, you have local copies of the Makefile and the include
2764447Sbosticfile compat.h.  Read through the Makefile and compat.h and make whatever
2864447Sbosticchanges are appropriate to your system.  If there's an architecture
2964447Sbosticthat's close to yours, you probably should diff the Makefile and
3064447Sbosticcompat.h in that tree against the standard ones and see what changes
3164447Sbosticwere necessary, as they're probably necessary for you as well.  Then,
3264447Sbosticenter "make" and see what happens!
3359564Sbostic
3466199SbosticThere are several subroutines that are found in POSIX 1003.2, ANSI
3564447SbosticC, or 4.4BSD that you may not have.  Once you get libdb.a to compile,
3664447Sbosticgo through the list of undefined routines and add entries to the MISC
3764447Sbosticline in the Makefile as necessary.
3859564Sbostic
3966199SbosticIf you have to add some functions that are missing (and which aren't
4066199Sbosticin the PORT/clib directory), please don't add them in the PORT/clib
4166199Sbosticdirectory.  Add them in a MACH/local directory, and add lines of the
4266199Sbosticform:
4364447Sbostic
4464447Sbostic	function.o: local/function.o
4564447Sbostic		${CL} -Ilocal local/function.o
4664447Sbostic
4764447Sbosticto your local Makefile.
4864447Sbostic
4964447SbosticHopefully, over time, we'll develop a set of system directories that
5066199Sbosticare known to work.  If you send me the changes that were necessary to
5166199Sbosticmake your system work, this will happen much more quickly.
5264447Sbostic
5364447SbosticIn some of the system directories, you'll see a file named OTHER_PATCHES.
5464447SbosticThis is a set of patches which you'll have to make from the top-level db
5566199Sbosticdirectory to get libdb.a to run on this system:
5664447Sbostic
5766199Sbostic	cd ..
5866199Sbostic	patch < PORT/MACH/OTHER_PATCHES
5966199Sbostic
6066199SbosticIf patch prompts you for the name of the file to modify (some versions
6166199Sbosticof patch don't figure it out on their own) use the file name which patch
6266199Sbosticdisplays.
6366199Sbostic
6464447SbosticSome knobs you may have to turn:
6564447Sbostic
6657984SbosticIn include/compat.h:
6766199Sbostic	Before attempting to build libdb, you should look through the
6864447Sbostic	compat.h file, and adjust it as necessary for your system.
6957984Sbostic	It's possible to use the #ifndef construct to figure out if a
7057984Sbostic	#ifdef has been set, but C provides no similar method to figure
7164447Sbostic	out if a typedef has been done.  Your compile errors should
7264447Sbostic	give you a good indication of which ones you need.
7357984Sbostic
7464447SbosticYou may see warning messages about illegal pointer combinations.  Systems
7564447Sbosticprototype malloc, calloc and realloc in different places, and the missing
7664447Sbosticprototypes will produce such warnings.  You may also see lots of warning
7764447Sbosticmessages about #define's being redefined.  These can mostly be ignored.
7864447SbosticIn general, I ignore all warning messages until something doesn't work.
7964447SbosticSome systems produce thousands of lines of completely useless warnings.
8057984Sbostic
8164447SbosticThe other parts of the PORT directory are as follows:
8259564Sbostic
8364447Sbostic	The directory PORT/clib is a set of functions that the 4.4BSD
8464447Sbostic	C library had and which your system may not have.  They are
8564447Sbostic	added to the MISC line of the Makefile if they aren't defined
8664447Sbostic	when you try and load libdb.a.
8764447Sbostic
8864447Sbostic	The directory PORT/include is header files that the 4.4BSD
8966199Sbostic	system had which your system may not have.  There is also
9066199Sbostic	one really important extra one, named compat.h, which is a
9166199Sbostic	set of compatibility work-arounds that you'll almost certainly
9266199Sbostic	have to copy and modify for a new system.
9359564Sbostic
9464447Sbostic	The symbolic link PORT/sys points to the PORT/include directory
9566199Sbostic	so that includes of the form <sys/include.h> work.
9659564Sbostic
9764447SbosticSome of the more common portability problems:
9864447Sbostic
9964447Sbostic	If you don't have:
10064447Sbostic
10166199Sbostic		memmove(3):	add memmove.o
10266199Sbostic		mkstemp(3):	add mktemp.o
10364447Sbostic
10464447Sbostic			... to the MISC line in the Makefile.
10564447Sbostic
10664447Sbostic	If realloc(3) of a NULL pointer on your system isn't the same
10764447Sbostic	as a malloc(3) call, add realloc.o to the MISC line in the
10864447Sbostic	Makefile.
10964447Sbostic
11064447Sbostic	If you don't have snprintf/vsnprintf(3), add snprintf.o to the
11164447Sbostic	MISC line in the Makefile.  This workaround depends on your
11264447Sbostic	system having vsprintf(3) -- if you don't, there's no workaround
11364447Sbostic	other than changing the source code to not use the snprintf calls.
11464447Sbostic	If you have to make that change, check to see if your vsprintf
11564447Sbostic	returns a length or a char *; if it's the latter, make sure you
11666199Sbostic	set VSPRINTF_CHARSTAR in the MACH/include/compat.h file.
11766199Sbostic
11866199SbosticInstalling the DB library:
11966199Sbostic
12066199Sbostic	The Makefile builds a C library named libdb.a.  This file needs
12166199Sbostic	to be installed in a place where the loader will automatically
12266199Sbostic	look for it (or, if you're building it for a single project,
12366199Sbostic	wherever that project's Makefile loads it from).
12466199Sbostic
12566199Sbostic	In addition, the header file PORT/include/db.h must be copied to
12666199Sbostic	a directory (often /usr/include/) where programs that use the
12766199Sbostic	db package can include it in their source.  (If you intend to use
12866199Sbostic	the ndbm interface to libdb, you'll need to copy the header file
12966199Sbostic	PORT/include/ndbm.h as well.)
130