pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/libgetopt 1.4 - overhaul:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/72ebfe4838f8
branches:  trunk
changeset: 490450:72ebfe4838f8
user:      tv <tv%pkgsrc.org@localhost>
date:      Thu Mar 10 19:19:46 2005 +0000

description:
1.4 - overhaul:

- pull sources directly into pkgsrc
- do not depend on namespace.h, <sys/cdefs.h> (de-__P()ify), or <err.h>
- use libtool for better portability in shlib creation

The resultant library is still ABI compatible with prior versions and
should have the same shlib major version number.

Thanks to Roland Illig <roland.illig%gmx.de@localhost> for help in getting this
working properly on Solaris.

diffstat:

 devel/libgetopt/Makefile                 |   51 +-
 devel/libgetopt/PLIST                    |   11 +-
 devel/libgetopt/distinfo                 |    6 +-
 devel/libgetopt/files/Makefile.libgetopt |    9 -
 devel/libgetopt/files/getopt.h           |   20 +-
 devel/libgetopt/files/getopt_long.3      |  273 +++++++++++++
 devel/libgetopt/files/getopt_long.c      |  494 +++++++++++++++++++++++++
 devel/libgetopt/files/namespace.h        |  606 -------------------------------
 devel/libgetopt/files/shlib_version      |    5 -
 9 files changed, 800 insertions(+), 675 deletions(-)

diffs (truncated from 1555 to 300 lines):

diff -r 877d999ea7e5 -r 72ebfe4838f8 devel/libgetopt/Makefile
--- a/devel/libgetopt/Makefile  Thu Mar 10 17:27:06 2005 +0000
+++ b/devel/libgetopt/Makefile  Thu Mar 10 19:19:46 2005 +0000
@@ -1,19 +1,15 @@
-# $NetBSD: Makefile,v 1.17 2005/02/21 20:26:10 hubertf Exp $
+# $NetBSD: Makefile,v 1.18 2005/03/10 19:19:46 tv Exp $
 #
 
-DISTNAME=      libgetopt-${VERS}
-PKGREVISION=   1
+DISTNAME=      libgetopt-1.4
 CATEGORIES=    pkgtools sysutils
-MASTER_SITES=  ${MASTER_SITE_LOCAL}
-# MASTER_SITES=        ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-current/src/lib/libc/stdlib/ \
-#              ftp://ftp.de.NetBSD.org/pub/NetBSD/NetBSD-current/src/lib/libc/stdlib/
-DISTFILES=     getopt_long.c-${VERS} getopt_long.3-${VERS}
+MASTER_SITES=  # empty
+DISTFILES=     # empty
 
-MAINTAINER=    tech-pkg%NetBSD.org@localhost,mcr%NetBSD.org@localhost
+MAINTAINER=    tech-pkg%NetBSD.org@localhost
 COMMENT=       Library for handling --long options
 
-NO_SRC_ON_FTP= Already in MASTER_SITE_LOCAL
-
+USE_LIBTOOL=   YES
 WRKSRC=                ${WRKDIR}/libgetopt
 
 .include "../../mk/bsd.prefs.mk"
@@ -22,36 +18,23 @@
 PKG_SKIP_REASON= "${PKGNAME} is part of your ${OPSYS} distribution"
 .endif
 
-VERS=          1.3
-# I have NFC why the mkdir in pre-extract doesn't work, so do it here:
-EXTRACT_CMD=   ${MKDIR} ${WRKSRC} && ${CP} ${DOWNLOADED_DISTFILE} ${WRKSRC}
-MANCOMPRESSED_IF_MANZ=  yes
-MAKE_FLAGS+=   LIBDIR=${PREFIX}/lib MANDIR=${PREFIX}/man
-MAKE_FLAGS+=   MKLINT=no
-
 .if ${OPSYS} == "SunOS"
 MAKEFLAGS+=    NETBSD_COMPATIBLE=YES
 CFLAGS+=       -DREPLACE_GETOPT
 .endif
 
-.if ${OPSYS} != "NetBSD"
-MAKE_FLAGS+=   MKMAN=no
-MAN_INCLUDED=  '@comment '
-.else
-MAN_INCLUDED=
-.endif
-
-PLIST_SUBST+=  MAN_INCLUDED=${MAN_INCLUDED}
+do-extract:
+       ${MKDIR} ${WRKSRC}
+       ${CP} ${FILESDIR}/getopt_long.? ${WRKSRC}
+       ${CP} ${FILESDIR}/getopt.h ${WRKSRC}
 
-post-extract:
-               ${CP} ${FILESDIR}/getopt.h ${WRKSRC}
-               ${CP} ${FILESDIR}/namespace.h ${WRKSRC}
-               ${CP} ${FILESDIR}/shlib_version ${WRKSRC}
-               ${CP} ${FILESDIR}/Makefile.libgetopt ${WRKSRC}/Makefile
-               ${MV} ${WRKSRC}/getopt_long.c-${VERS} ${WRKSRC}/getopt_long.c
-               ${MV} ${WRKSRC}/getopt_long.3-${VERS} ${WRKSRC}/getopt_long.3
+do-build:
+       cd ${WRKSRC} && ${LIBTOOL} --mode=compile ${COMPILE.c} getopt_long.c
+       cd ${WRKSRC} && ${LIBTOOL} --mode=link ${LINK.c} -o libgetopt.la getopt_long.lo -version-info 5:0:4 -rpath ${PREFIX}/lib
 
-post-install:
-               ${INSTALL_DATA} ${FILESDIR}/getopt.h ${PREFIX}/include/getopt.h
+do-install:
+       ${LIBTOOL} --mode=install ${INSTALL_LIB} ${WRKSRC}/libgetopt.la ${PREFIX}/lib/
+       ${INSTALL_DATA} ${WRKSRC}/getopt.h ${PREFIX}/include/
+       ${INSTALL_MAN} ${WRKSRC}/getopt_long.3 ${PREFIX}/man/man3/
 
 .include "../../mk/bsd.pkg.mk"
diff -r 877d999ea7e5 -r 72ebfe4838f8 devel/libgetopt/PLIST
--- a/devel/libgetopt/PLIST     Thu Mar 10 17:27:06 2005 +0000
+++ b/devel/libgetopt/PLIST     Thu Mar 10 19:19:46 2005 +0000
@@ -1,9 +1,4 @@
-@comment $NetBSD: PLIST,v 1.1 2001/11/01 01:24:30 zuntum Exp $
-lib/libgetopt.a
-lib/libgetopt_pic.a
-lib/libgetopt.so
-lib/libgetopt.so.1
-lib/libgetopt.so.1.1
-${MAN_INCLUDED}man/man3/getopt_long.3
-${MAN_INCLUDED}man/cat3/getopt_long.0
+@comment $NetBSD: PLIST,v 1.2 2005/03/10 19:19:46 tv Exp $
+lib/libgetopt.la
+man/man3/getopt_long.3
 include/getopt.h
diff -r 877d999ea7e5 -r 72ebfe4838f8 devel/libgetopt/distinfo
--- a/devel/libgetopt/distinfo  Thu Mar 10 17:27:06 2005 +0000
+++ b/devel/libgetopt/distinfo  Thu Mar 10 19:19:46 2005 +0000
@@ -1,6 +1,2 @@
-$NetBSD: distinfo,v 1.2 2001/04/21 00:44:27 wiz Exp $
+$NetBSD: distinfo,v 1.3 2005/03/10 19:19:46 tv Exp $
 
-SHA1 (getopt_long.c-1.3) = 1cacfb054f19ae8c7ad713caf0ccd02eeb1a4524
-Size (getopt_long.c-1.3) = 12789 bytes
-SHA1 (getopt_long.3-1.3) = 29379706e3537a3a323d16c8ebea8dc9a2bd9ccf
-Size (getopt_long.3-1.3) = 8281 bytes
diff -r 877d999ea7e5 -r 72ebfe4838f8 devel/libgetopt/files/Makefile.libgetopt
--- a/devel/libgetopt/files/Makefile.libgetopt  Thu Mar 10 17:27:06 2005 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#       $NetBSD: Makefile.libgetopt,v 1.1.1.1 1999/08/06 16:37:22 hubertf Exp $
-
-LIB=    getopt
-SRCS=   getopt_long.c
-MAN=    getopt_long.3
-
-MKPROFILE=no
-
-.include <bsd.lib.mk>
diff -r 877d999ea7e5 -r 72ebfe4838f8 devel/libgetopt/files/getopt.h
--- a/devel/libgetopt/files/getopt.h    Thu Mar 10 17:27:06 2005 +0000
+++ b/devel/libgetopt/files/getopt.h    Thu Mar 10 19:19:46 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getopt.h,v 1.3 2005/02/11 17:29:06 tv Exp $    */
+/*     $NetBSD: getopt.h,v 1.4 2005/03/10 19:19:47 tv Exp $    */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -39,7 +39,6 @@
 #ifndef _GETOPT_H_
 #define _GETOPT_H_
 
-#include <sys/cdefs.h>
 #include <unistd.h>
 
 /*
@@ -64,15 +63,20 @@
        int val;
 };
 
-__BEGIN_DECLS
-int getopt_long __P((int, char * const *, const char *,
-    const struct option *, int *));
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int getopt_long(int, char * const *, const char *,
+    const struct option *, int *);
 
-#ifdef __INTERIX
-/* XXX this is in libc, but not in a system header */
+/* On some platforms, this is in libc, but not in a system header */
 extern int optreset;
+
+#ifdef __cplusplus
+};
 #endif
-__END_DECLS
+
 #endif
  
 #endif /* !_GETOPT_H_ */
diff -r 877d999ea7e5 -r 72ebfe4838f8 devel/libgetopt/files/getopt_long.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libgetopt/files/getopt_long.3       Thu Mar 10 19:19:46 2005 +0000
@@ -0,0 +1,273 @@
+.\"    $NetBSD: getopt_long.3,v 1.1 2005/03/10 19:19:47 tv Exp $
+.\"
+.\" Copyright (c) 1988, 1991, 1993
+.\"    The Regents of the University of California.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)getopt.3   8.5 (Berkeley) 4/27/95
+.\"
+.Dd April 1, 2000
+.Dt GETOPT_LONG 3
+.Os 
+.Sh NAME
+.Nm getopt_long
+.Nd get long options from command line argument list
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.Fd #include <getopt.h>
+.Ft int
+.Fn getopt_long "int argc" "char * const *argv" "const char *optstring" "struct options *long options" "int *index"
+.Sh DESCRIPTION
+The
+.Fn getopt_long
+function is similar to 
+.Xr getopt 3
+but it accepts options in two forms: words and characters. The
+.Fn getopt_long
+function provides a superset of of the functionality of 
+.Xr getopt 3 .
+.Fn getopt_long
+can be used in two ways. In the first way, every long option understood
+by the program has a corresponding short option, and the option
+structure is only used to translate from long options to short
+options. When used in this fashion, 
+.Fn getopt_long
+behaves identically to 
+.Xr getopt 3 .
+This is a good way to add long option processing to an existing program
+with the minimum of rewriting.
+.Pp
+In the second mechanism, a long option sets a flag in the 
+.Fa option
+structure passed, or will store a pointer to the command line argument
+in the 
+.Fa option 
+structure passed to it for options that take arguments. Additionally,
+the long option's argument may be specified as a single argument with
+an equal sign, e.g. 
+.Bd -literal
+myprogram --myoption=somevalue
+.Ed
+.Pp
+When a long option is processed the call to 
+.Fn getopt_long
+will return 0. For this reason, long option processing without
+shortcuts is not backwards compatible with 
+.Xr getopt 3 .
+.Pp
+It is possible to combine these methods, providing for long options
+processing with short option equivalents for some options. Less
+frequently used options would be processed as long options only.
+.Sh USAGE
+.Pp
+The 
+.Fn getopt_long
+call requires a structure to be initialized describing the long
+options. The structure is:
+.Bd -literal
+struct option {
+       char *name;
+       int has_arg;
+       int *flag;
+       int val;
+};
+.Ed
+.Pp
+The 
+.Fa name
+field should contain the option name without the leading double dash.
+.Pp
+The 
+.Fa has_arg
+field should be one of:
+.Bl -tag -width "optional_argument"
+.It Li no_argument
+no argument to the option is expect.
+.It Li required_argument
+an argument to the option is required.
+.It Li optional_argument
+an argument to the option may be presented.
+.El
+.Pp
+If
+.Fa flag
+is non-NULL, then the integer pointed to by it will be set to the 
+value in the 
+.Fa val
+field. If the 
+.Fa flag 
+field is NULL, then the 
+.Fa val
+field will be returned. Setting 
+.Fa flag
+to NULL and setting
+.Fa val
+to the corresponding short option will make this function act just
+like
+.Xr getopt 3 .



Home | Main Index | Thread Index | Old Index