1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

Add endianness support to cap_mkdb(1), useful for cross builds.

This commit is contained in:
Ruslan Ermilov 2005-02-22 23:29:54 +00:00
parent 470273d7d9
commit 6fe37d1365
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=142262
7 changed files with 65 additions and 10 deletions

View File

@ -760,6 +760,10 @@ _groff= gnu/usr.bin/groff/tmac
.endif
.endif
.if ${BOOTSTRAPPING} < 600015
_cap_mkdb= usr.bin/cap_mkdb
.endif
.if ${BOOTSTRAPPING} < 502102
_lex= usr.bin/lex
.endif
@ -798,6 +802,7 @@ bootstrap-tools:
${_gperf} \
${_groff} \
gnu/usr.bin/texinfo \
${_cap_mkdb} \
usr.bin/colldef \
${_lex} \
usr.bin/lorder \

View File

@ -2,8 +2,8 @@
# @(#)Makefile 8.1 (Berkeley) 6/8/93
FILES= bsd.README
FILES+= bsd.compat.mk bsd.cpu.mk bsd.dep.mk bsd.doc.mk bsd.files.mk
FILES+= bsd.incs.mk bsd.info.mk bsd.init.mk
FILES+= bsd.compat.mk bsd.cpu.mk bsd.dep.mk bsd.doc.mk bsd.endian.mk
FILES+= bsd.files.mk bsd.incs.mk bsd.info.mk bsd.init.mk
FILES+= bsd.kmod.mk
FILES+= bsd.lib.mk bsd.libnames.mk bsd.links.mk bsd.man.mk bsd.nls.mk
FILES+= bsd.obj.mk bsd.own.mk

11
share/mk/bsd.endian.mk Normal file
View File

@ -0,0 +1,11 @@
# $FreeBSD$
.if ${MACHINE_ARCH} == "alpha" || \
${MACHINE_ARCH} == "amd64" || \
${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "ia64"
TARGET_ENDIANNESS= 1234
.elif ${MACHINE_ARCH} == "powerpc" || \
${MACHINE_ARCH} == "sparc64"
TARGET_ENDIANNESS= 4321
.endif

View File

@ -14,8 +14,17 @@ CLEANFILES+= termcap termcap.db
termcap: reorder termcap.src
TERM=dumb TERMCAP=dumb: ex - ${.CURDIR}/termcap.src < ${.CURDIR}/reorder
.include <bsd.endian.mk>
.if ${TARGET_ENDIANNESS} == "1234"
CAP_MKDB_ENDIAN= -l
.elif ${TARGET_ENDIANNESS} == "4321"
CAP_MKDB_ENDIAN= -b
.else
CAP_MKDB_ENDIAN=
.endif
termcap.db: termcap
cap_mkdb termcap
cap_mkdb ${CAP_MKDB_ENDIAN} termcap
etc-termcap:
ln -fs ${BINDIR}/misc/termcap ${DESTDIR}/etc/termcap

View File

@ -32,7 +32,7 @@
.\" @(#)cap_mkdb.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
.Dd June 6, 1993
.Dd February 22, 2005
.Dt CAP_MKDB 1
.Os
.Sh NAME
@ -40,10 +40,10 @@
.Nd create capability database
.Sh SYNOPSIS
.Nm
.Op Fl b | l
.Op Fl v
.Op Fl f Ar outfile
.Ar file
.Op Ar
.Ar
.Sh DESCRIPTION
The
.Nm
@ -65,11 +65,22 @@ record is stored into the database.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl b
Use big-endian byte order for database metadata.
.It Fl f Ar outfile
Specify a different database basename.
.It Fl l
Use little-endian byte order for database metadata.
.It Fl v
Print out the number of capability records in the database.
.El
.Pp
The
.Fl b
and
.Fl l
flags are mutually exclusive.
The default byte ordering is the current host order.
.Sh FORMAT
Each record is stored in the database using two different types of keys.
.Pp

View File

@ -84,11 +84,18 @@ HASHINFO openinfo = {
int
main(int argc, char *argv[])
{
int c;
int byteorder, c;
capname = NULL;
while ((c = getopt(argc, argv, "f:v")) != -1) {
byteorder = 0;
while ((c = getopt(argc, argv, "bf:lv")) != -1) {
switch(c) {
case 'b':
case 'l':
if (byteorder != 0)
usage();
byteorder = c == 'b' ? 4321 : 1234;
break;
case 'f':
capname = optarg;
break;
@ -106,6 +113,9 @@ main(int argc, char *argv[])
if (*argv == NULL)
usage();
/* Set byte order. */
openinfo.lorder = byteorder;
/*
* The database file is the first argument if no name is specified.
* Make arrangements to unlink it if exit badly.
@ -257,6 +267,6 @@ void
usage(void)
{
(void)fprintf(stderr,
"usage: cap_mkdb [-v] [-f outfile] file [file ...]\n");
"usage: cap_mkdb [-b | -l] [-v] [-f outfile] file ...\n");
exit(1);
}

View File

@ -16,7 +16,16 @@ SCRIPTSDIR=/usr/bin
CLEANFILES= vgrindefs.src.db
.include <bsd.endian.mk>
.if ${TARGET_ENDIANNESS} == "1234"
CAP_MKDB_ENDIAN= -l
.elif ${TARGET_ENDIANNESS} == "4321"
CAP_MKDB_ENDIAN= -b
.else
CAP_MKDB_ENDIAN=
.endif
vgrindefs.src.db: vgrindefs.src
cap_mkdb -f vgrindefs.src ${.ALLSRC}
cap_mkdb ${CAP_MKDB_ENDIAN} -f vgrindefs.src ${.ALLSRC}
.include <bsd.prog.mk>