xref: /csrg-svn/lib/libc/db/PORT/README (revision 66199)
1*66199Sbostic#	@(#)README	8.3 (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 .
16*66199Sbostic	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
34*66199SbosticThere 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
39*66199SbosticIf you have to add some functions that are missing (and which aren't
40*66199Sbosticin the PORT/clib directory), please don't add them in the PORT/clib
41*66199Sbosticdirectory.  Add them in a MACH/local directory, and add lines of the
42*66199Sbosticform:
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
50*66199Sbosticare known to work.  If you send me the changes that were necessary to
51*66199Sbosticmake 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
55*66199Sbosticdirectory to get libdb.a to run on this system:
5664447Sbostic
57*66199Sbostic	cd ..
58*66199Sbostic	patch < PORT/MACH/OTHER_PATCHES
59*66199Sbostic
60*66199SbosticIf patch prompts you for the name of the file to modify (some versions
61*66199Sbosticof patch don't figure it out on their own) use the file name which patch
62*66199Sbosticdisplays.
63*66199Sbostic
6464447SbosticSome knobs you may have to turn:
6564447Sbostic
6657984SbosticIn include/compat.h:
67*66199Sbostic	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
89*66199Sbostic	system had which your system may not have.  There is also
90*66199Sbostic	one really important extra one, named compat.h, which is a
91*66199Sbostic	set of compatibility work-arounds that you'll almost certainly
92*66199Sbostic	have to copy and modify for a new system.
9359564Sbostic
9464447Sbostic	The symbolic link PORT/sys points to the PORT/include directory
95*66199Sbostic	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
101*66199Sbostic		memmove(3):	add memmove.o
102*66199Sbostic		mkstemp(3):	add mktemp.o
103*66199Sbostic		strerror(3):	add strerror.o
10464447Sbostic
10564447Sbostic			... to the MISC line in the Makefile.
10664447Sbostic
10764447Sbostic	If realloc(3) of a NULL pointer on your system isn't the same
10864447Sbostic	as a malloc(3) call, add realloc.o to the MISC line in the
10964447Sbostic	Makefile.
11064447Sbostic
11164447Sbostic	If you don't have snprintf/vsnprintf(3), add snprintf.o to the
11264447Sbostic	MISC line in the Makefile.  This workaround depends on your
11364447Sbostic	system having vsprintf(3) -- if you don't, there's no workaround
11464447Sbostic	other than changing the source code to not use the snprintf calls.
11564447Sbostic	If you have to make that change, check to see if your vsprintf
11664447Sbostic	returns a length or a char *; if it's the latter, make sure you
117*66199Sbostic	set VSPRINTF_CHARSTAR in the MACH/include/compat.h file.
118*66199Sbostic
119*66199SbosticInstalling the DB library:
120*66199Sbostic
121*66199Sbostic	The Makefile builds a C library named libdb.a.  This file needs
122*66199Sbostic	to be installed in a place where the loader will automatically
123*66199Sbostic	look for it (or, if you're building it for a single project,
124*66199Sbostic	wherever that project's Makefile loads it from).
125*66199Sbostic
126*66199Sbostic	In addition, the header file PORT/include/db.h must be copied to
127*66199Sbostic	a directory (often /usr/include/) where programs that use the
128*66199Sbostic	db package can include it in their source.  (If you intend to use
129*66199Sbostic	the ndbm interface to libdb, you'll need to copy the header file
130*66199Sbostic	PORT/include/ndbm.h as well.)
131