From 62402cb14bd322ffc8fa03f20cd8b8703efe5356 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Thu, 22 Feb 2001 13:01:09 +0000 Subject: [PATCH] Check in built-in copy of libpopt in preparation for switching from getopt --- popt-1.2/CHANGES | 19 + popt-1.2/COPYING | 22 + popt-1.2/Makefile.am | 35 + popt-1.2/Makefile.in | 507 +++++++++ popt-1.2/README | 18 + popt-1.2/acconfig.h | 35 + popt-1.2/aclocal.m4 | 246 +++++ popt-1.2/autogen.sh | 10 + popt-1.2/config.h.in | 34 + popt-1.2/configure | 2088 ++++++++++++++++++++++++++++++++++++ popt-1.2/configure.in | 63 ++ popt-1.2/findme.c | 60 ++ popt-1.2/findme.h | 10 + popt-1.2/install-sh | 238 ++++ popt-1.2/missing | 188 ++++ popt-1.2/mkinstalldirs | 40 + popt-1.2/po/Makefile.in | 80 ++ popt-1.2/po/Makefile.in.in | 80 ++ popt-1.2/po/POTFILES | 6 + popt-1.2/po/POTFILES.in | 11 + popt-1.2/po/ro.po | 72 ++ popt-1.2/popt.3 | 715 ++++++++++++ popt-1.2/popt.c | 575 ++++++++++ popt-1.2/popt.h | 110 ++ popt-1.2/popt.spec | 41 + popt-1.2/poptconfig.c | 151 +++ popt-1.2/popthelp.c | 268 +++++ popt-1.2/poptint.h | 64 ++ popt-1.2/poptparse.c | 93 ++ popt-1.2/stamp-h.in | 0 popt-1.2/test-poptrc | 9 + popt-1.2/test1.c | 101 ++ popt-1.2/testit.sh | 47 + 33 files changed, 6036 insertions(+) create mode 100644 popt-1.2/CHANGES create mode 100644 popt-1.2/COPYING create mode 100644 popt-1.2/Makefile.am create mode 100644 popt-1.2/Makefile.in create mode 100644 popt-1.2/README create mode 100644 popt-1.2/acconfig.h create mode 100644 popt-1.2/aclocal.m4 create mode 100755 popt-1.2/autogen.sh create mode 100644 popt-1.2/config.h.in create mode 100755 popt-1.2/configure create mode 100755 popt-1.2/configure.in create mode 100644 popt-1.2/findme.c create mode 100644 popt-1.2/findme.h create mode 100755 popt-1.2/install-sh create mode 100755 popt-1.2/missing create mode 100755 popt-1.2/mkinstalldirs create mode 100644 popt-1.2/po/Makefile.in create mode 100644 popt-1.2/po/Makefile.in.in create mode 100644 popt-1.2/po/POTFILES create mode 100644 popt-1.2/po/POTFILES.in create mode 100644 popt-1.2/po/ro.po create mode 100644 popt-1.2/popt.3 create mode 100644 popt-1.2/popt.c create mode 100644 popt-1.2/popt.h create mode 100644 popt-1.2/popt.spec create mode 100644 popt-1.2/poptconfig.c create mode 100644 popt-1.2/popthelp.c create mode 100644 popt-1.2/poptint.h create mode 100644 popt-1.2/poptparse.c create mode 100644 popt-1.2/stamp-h.in create mode 100644 popt-1.2/test-poptrc create mode 100644 popt-1.2/test1.c create mode 100755 popt-1.2/testit.sh diff --git a/popt-1.2/CHANGES b/popt-1.2/CHANGES new file mode 100644 index 00000000..627f9213 --- /dev/null +++ b/popt-1.2/CHANGES @@ -0,0 +1,19 @@ +1.1 -> 1.2 + - added popt.3 man page (Robert Lynch) + - don't use mmap anymore (its lack of portability isn't worth the + trouble) + - added test script + - added support for exec + - removed support for *_POPT_ALIASES env variable -- it was a bad + idea + - reorganized into multiple source files + - added automatic help generation, POPT_AUTOHELP + - added table callbacks + - added table inclusion + - updated man page for new features + - added test scripts + +1.0 -> 1.1 + - moved to autoconf (Fred Fish) + - added STRERROR replacement (Norbert Warmuth) + - added const keywords (Bruce Perens) diff --git a/popt-1.2/COPYING b/popt-1.2/COPYING new file mode 100644 index 00000000..b4c7ca87 --- /dev/null +++ b/popt-1.2/COPYING @@ -0,0 +1,22 @@ +Copyright (c) 1998 Red Hat Software + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the X Consortium. diff --git a/popt-1.2/Makefile.am b/popt-1.2/Makefile.am new file mode 100644 index 00000000..4284910f --- /dev/null +++ b/popt-1.2/Makefile.am @@ -0,0 +1,35 @@ +# Makefile for popt library. + +AUTOMAKE_OPTIONS = 1.3 foreign + +SUBDIRS = po + +LDFLAGS = -L$(top_builddir) +INCLUDES = -I$(top_srcdir) + +noinst_PROGRAMS = test1 +test1_SOURCES = test1.c +test1_LDADD = -lpopt + +include_HEADERS = popt.h +lib_LIBRARIES = libpopt.a +libpopt_a_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c + +CVSTAG = $(PACKAGE)-$(subst .,_,$(VERSION)) + +.PHONY: archive +archive: + @echo "This is $(PACKAGE)-$(VERSION)." + @sleep 5 + @cvs -Q tag -F $(CVSTAG) . + @rm -rf /tmp/$(PACKAGE)-$(VERSION) /tmp/$(PACKAGE) + @cd /tmp; cvs -Q -d $(CVSROOT) export -r$(CVSTAG) $(PACKAGE) || : + @mv /tmp/$(PACKAGE) /tmp/$(PACKAGE)-$(VERSION) + @cd /tmp/$(PACKAGE)-$(VERSION); ./autogen.sh ; make depend; make distclean + @cd /tmp/$(PACKAGE)-$(VERSION); ./autogen.sh --noconfigure + @cd /tmp; tar czSpf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) + @rm -rf /tmp/$(PACKAGE)-$(VERSION) + @cp /tmp/$(PACKAGE)-$(VERSION).tar.gz . + @rm -f /tmp/$(PACKAGE)-$(VERSION).tar.gz + @echo " " + @echo "The final archive is ./$(PACKAGE)-$(VERSION).tar.gz." diff --git a/popt-1.2/Makefile.in b/popt-1.2/Makefile.in new file mode 100644 index 00000000..9fe78ed8 --- /dev/null +++ b/popt-1.2/Makefile.in @@ -0,0 +1,507 @@ +# Makefile.in generated automatically by automake 1.3 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Makefile for popt library. + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DISTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +CPP = @CPP@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +TARGET = @TARGET@ +U = @U@ +VERSION = @VERSION@ + +AUTOMAKE_OPTIONS = 1.3 foreign + +SUBDIRS = po + +LDFLAGS = -L$(top_builddir) +INCLUDES = -I$(top_srcdir) + +noinst_PROGRAMS = test1 +test1_SOURCES = test1.c +test1_LDADD = -lpopt + +include_HEADERS = popt.h +lib_LIBRARIES = libpopt.a +libpopt_a_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c + +CVSTAG = $(PACKAGE)-$(subst .,_,$(VERSION)) +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(lib_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I. +CPPFLAGS = @CPPFLAGS@ +LIBS = @LIBS@ +libpopt_a_LIBADD = +libpopt_a_OBJECTS = popt.o findme.o poptparse.o poptconfig.o popthelp.o +AR = ar +PROGRAMS = $(noinst_PROGRAMS) + +test1_OBJECTS = test1.o +test1_DEPENDENCIES = +test1_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(include_HEADERS) + +DIST_COMMON = README COPYING Makefile.am Makefile.in acconfig.h \ +aclocal.m4 config.h.in configure configure.in install-sh missing \ +mkinstalldirs stamp-h.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +DEP_FILES = .deps/findme.P .deps/popt.P .deps/poptconfig.P \ +.deps/popthelp.P .deps/poptparse.P .deps/test1.P +SOURCES = $(libpopt_a_SOURCES) $(test1_SOURCES) +OBJECTS = $(libpopt_a_OBJECTS) $(test1_OBJECTS) + +all: all-recursive-am all-am + +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.in + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +config.h: stamp-h + @: +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h +$(srcdir)/config.h.in: $(srcdir)/stamp-h.in +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: + +mostlyclean-libLIBRARIES: + +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) + +distclean-libLIBRARIES: + +maintainer-clean-libLIBRARIES: + +install-libLIBRARIES: $(lib_LIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \ + $(RANLIB) $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LIBRARIES)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +libpopt.a: $(libpopt_a_OBJECTS) $(libpopt_a_DEPENDENCIES) + -rm -f libpopt.a + $(AR) cru libpopt.a $(libpopt_a_OBJECTS) $(libpopt_a_LIBADD) + $(RANLIB) libpopt.a + +mostlyclean-noinstPROGRAMS: + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +distclean-noinstPROGRAMS: + +maintainer-clean-noinstPROGRAMS: + +test1: $(test1_OBJECTS) $(test1_DEPENDENCIES) + @rm -f test1 + $(LINK) $(test1_LDFLAGS) $(test1_OBJECTS) $(test1_LDADD) $(LIBS) + +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(includedir) + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(include_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(includedir)/$$p; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + target=`echo $@ | sed s/-recursive//`; \ + echo "Making $$target in $$subdir"; \ + (cd $$subdir && $(MAKE) $$target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + done; \ + for subdir in $$rev; do \ + target=`echo $@ | sed s/-recursive//`; \ + echo "Making $$target in $$subdir"; \ + (cd $$subdir && $(MAKE) $$target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + (cd $$subdir && $(MAKE) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) \ + && $(MAKE) dvi \ + && $(MAKE) check \ + && $(MAKE) install \ + && $(MAKE) installcheck \ + && $(MAKE) dist + -rm -rf $(distdir) + @echo "========================"; \ + echo "$(distdir).tar.gz is ready for distribution"; \ + echo "========================" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done + for subdir in $(SUBDIRS); do \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + +maintainer-clean-depend: + -rm -rf .deps + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< + @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ + < .deps/$(*F).p > .deps/$(*F).P + @-rm -f .deps/$(*F).p +info: info-recursive +dvi: dvi-recursive +check: all-am + $(MAKE) check-recursive +installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) all-recursive + +all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS) config.h + +install-exec-am: install-libLIBRARIES + +install-data-am: install-includeHEADERS + +uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS + +install-exec: install-exec-recursive install-exec-am + @$(NORMAL_INSTALL) + +install-data: install-data-recursive install-data-am + @$(NORMAL_INSTALL) + +install: install-recursive install-exec-am install-data-am + @: + +uninstall: uninstall-recursive uninstall-am + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: installdirs-recursive + $(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(includedir) + + +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean-am: mostlyclean-hdr mostlyclean-libLIBRARIES \ + mostlyclean-compile mostlyclean-noinstPROGRAMS \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +clean-am: clean-hdr clean-libLIBRARIES clean-compile \ + clean-noinstPROGRAMS clean-tags clean-depend \ + clean-generic mostlyclean-am + +distclean-am: distclean-hdr distclean-libLIBRARIES distclean-compile \ + distclean-noinstPROGRAMS distclean-tags \ + distclean-depend distclean-generic clean-am + +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-libLIBRARIES \ + maintainer-clean-compile \ + maintainer-clean-noinstPROGRAMS maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + +mostlyclean: mostlyclean-recursive mostlyclean-am + +clean: clean-recursive clean-am + +distclean: distclean-recursive distclean-am + -rm -f config.status + +maintainer-clean: maintainer-clean-recursive maintainer-clean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + -rm -f config.status + +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +mostlyclean-libLIBRARIES distclean-libLIBRARIES clean-libLIBRARIES \ +maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \ +install-libLIBRARIES mostlyclean-compile distclean-compile \ +clean-compile maintainer-clean-compile mostlyclean-noinstPROGRAMS \ +distclean-noinstPROGRAMS clean-noinstPROGRAMS \ +maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \ +install-includeHEADERS install-data-recursive uninstall-data-recursive \ +install-exec-recursive uninstall-exec-recursive installdirs-recursive \ +uninstalldirs-recursive all-recursive check-recursive \ +installcheck-recursive info-recursive dvi-recursive \ +mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info dvi installcheck all-recursive-am all-am \ +install-exec-am install-data-am uninstall-am install-exec install-data \ +install uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean + + +.PHONY: archive +archive: + @echo "This is $(PACKAGE)-$(VERSION)." + @sleep 5 + @cvs -Q tag -F $(CVSTAG) . + @rm -rf /tmp/$(PACKAGE)-$(VERSION) /tmp/$(PACKAGE) + @cd /tmp; cvs -Q -d $(CVSROOT) export -r$(CVSTAG) $(PACKAGE) || : + @mv /tmp/$(PACKAGE) /tmp/$(PACKAGE)-$(VERSION) + @cd /tmp/$(PACKAGE)-$(VERSION); ./autogen.sh ; make depend; make distclean + @cd /tmp/$(PACKAGE)-$(VERSION); ./autogen.sh --noconfigure + @cd /tmp; tar czSpf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) + @rm -rf /tmp/$(PACKAGE)-$(VERSION) + @cp /tmp/$(PACKAGE)-$(VERSION).tar.gz . + @rm -f /tmp/$(PACKAGE)-$(VERSION).tar.gz + @echo " " + @echo "The final archive is ./$(PACKAGE)-$(VERSION).tar.gz." + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/popt-1.2/README b/popt-1.2/README new file mode 100644 index 00000000..7fccc836 --- /dev/null +++ b/popt-1.2/README @@ -0,0 +1,18 @@ +This is the popt command line option parsing library. While it is similiar +to getopt(3), it contains a number of enhancements, including: + + 1) popt is fully reentrant + 2) popt can parse arbitrary argv[] style arrays while + getopt(2) makes this quite difficult + 3) popt allows users to alias command line arguments + 4) popt provides convience functions for parsting strings + into argv[] style arrays + +popt is used by rpm, the Red Hat install program, and many other Red Hat +utilities, all of which provide excellent examples of how to use popt. +Complete documentation on popt is available in popt.ps (included in this +tarball), which is excerpted with permission from the book "Linux +Application Development" by Michael K. Johnson and Erik Troan (availble +from Addison Wesley in May, 1998). + +Comments on popt should be addressed to ewt@redhat.com. diff --git a/popt-1.2/acconfig.h b/popt-1.2/acconfig.h new file mode 100644 index 00000000..3e2b29fd --- /dev/null +++ b/popt-1.2/acconfig.h @@ -0,0 +1,35 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +/* acconfig.h + This file is in the public domain. + + Descriptive text for the C preprocessor macros that + the distributed Autoconf macros can define. + No software package will use all of them; autoheader copies the ones + your configure.in uses into your configuration header file templates. + + The entries are in sort -df order: alphabetical, case insensitive, + ignoring punctuation (such as underscores). Although this order + can split up related entries, it makes it easier to check whether + a given entry is in the file. + + Leave the following blank line there!! Autoheader needs it. */ +^L + +/* Define to the name of the distribution. */ +#undef PACKAGE + +/* Define to the version of the distribution. */ +#undef VERSION + +/* Define to 1 if ANSI function prototypes are usable. */ +#undef PROTOTYPES + +^L +/* Leave that blank line there!! Autoheader needs it. + If you're adding to this file, keep in mind: + The entries are in sort -df order: alphabetical, case insensitive, + ignoring punctuation (such as underscores). */ + diff --git a/popt-1.2/aclocal.m4 b/popt-1.2/aclocal.m4 new file mode 100644 index 00000000..d234055d --- /dev/null +++ b/popt-1.2/aclocal.m4 @@ -0,0 +1,246 @@ +dnl aclocal.m4 generated automatically by aclocal 1.3 + +dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +dnl This Makefile.in is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN(AM_INIT_AUTOMAKE, +[AC_REQUIRE([AM_PROG_INSTALL]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") +AC_DEFINE_UNQUOTED(VERSION, "$VERSION")) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + + +# serial 1 + +AC_DEFUN(AM_PROG_INSTALL, +[AC_REQUIRE([AC_PROG_INSTALL]) +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' +AC_SUBST(INSTALL_SCRIPT)dnl +]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN(AM_SANITY_CHECK, +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN(AM_MISSING_PROG, +[AC_MSG_CHECKING(for working $2) +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +AC_DEFUN(AM_CONFIG_HEADER, +[AC_PREREQ([2.12]) +AC_CONFIG_HEADER([$1]) +dnl When config.status generates a header, we must update the stamp-h file. +dnl This file resides in the same directory as the config header +dnl that is generated. We must strip everything past the first ":", +dnl and everything past the last "/". +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) +changequote([,]))]) + + +# serial 1 + +AC_DEFUN(AM_C_PROTOTYPES, +[AC_REQUIRE([AM_PROG_CC_STDC]) +AC_REQUIRE([AC_PROG_CPP]) +AC_MSG_CHECKING([for function prototypes]) +if test "$am_cv_prog_cc_stdc" != no; then + AC_MSG_RESULT(yes) + AC_DEFINE(PROTOTYPES) + U= ANSI2KNR= +else + AC_MSG_RESULT(no) + U=_ ANSI2KNR=./ansi2knr + # Ensure some checks needed by ansi2knr itself. + AC_HEADER_STDC + AC_CHECK_HEADERS(string.h) +fi +AC_SUBST(U)dnl +AC_SUBST(ANSI2KNR)dnl +]) + + +# serial 1 + +# @defmac AC_PROG_CC_STDC +# @maindex PROG_CC_STDC +# @ovindex CC +# If the C compiler in not in ANSI C mode by default, try to add an option +# to output variable @code{CC} to make it so. This macro tries various +# options that select ANSI C on some system or another. It considers the +# compiler to be in ANSI C mode if it handles function prototypes correctly. +# +# If you use this macro, you should check after calling it whether the C +# compiler has been set to accept ANSI C; if not, the shell variable +# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +# code in ANSI C, you can make an un-ANSIfied copy of it by using the +# program @code{ansi2knr}, which comes with Ghostscript. +# @end defmac + +AC_DEFUN(AM_PROG_CC_STDC, +[AC_REQUIRE([AC_PROG_CC]) +AC_BEFORE([$0], [AC_C_INLINE]) +AC_BEFORE([$0], [AC_C_CONST]) +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) +AC_CACHE_VAL(am_cv_prog_cc_stdc, +[am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[am_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" +]) +if test -z "$am_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT($am_cv_prog_cc_stdc) +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac +]) + diff --git a/popt-1.2/autogen.sh b/popt-1.2/autogen.sh new file mode 100755 index 00000000..fd0c14d7 --- /dev/null +++ b/popt-1.2/autogen.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +autoheader +autoconf + +if [ "$1" = "--noconfigure" ]; then + exit 0; +fi + +./configure "$@" diff --git a/popt-1.2/config.h.in b/popt-1.2/config.h.in new file mode 100644 index 00000000..ffa54493 --- /dev/null +++ b/popt-1.2/config.h.in @@ -0,0 +1,34 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to the name of the distribution. */ +#undef PACKAGE + +/* Define to the version of the distribution. */ +#undef VERSION + +/* Define to 1 if ANSI function prototypes are usable. */ +#undef PROTOTYPES + +/* Define if you have the dgettext function. */ +#undef HAVE_DGETTEXT + +/* Define if you have the gettext function. */ +#undef HAVE_GETTEXT + +/* Define if you have the strerror function. */ +#undef HAVE_STRERROR + +/* Define if you have the header file. */ +#undef HAVE_ALLOCA_H + +/* Define if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H diff --git a/popt-1.2/configure b/popt-1.2/configure new file mode 100755 index 00000000..5de8258e --- /dev/null +++ b/popt-1.2/configure @@ -0,0 +1,2088 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.12" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=popt.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:552: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 +echo "configure:605: checking whether build environment is sane" >&5 +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "$*" != "X $srcdir/configure conftestfile" \ + && test "$*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { echo "configure: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" 1>&2; exit 1; } + fi + + test "$2" = conftestfile + ) +then + # Ok. + : +else + { echo "configure: error: newly created file is older than distributed files! +Check your system clock" 1>&2; exit 1; } +fi +rm -f conftest* +echo "$ac_t""yes" 1>&6 +if test "$program_transform_name" = s,x,x,; then + program_transform_name= +else + # Double any \ or $. echo might interpret backslashes. + cat <<\EOF_SED > conftestsed +s,\\,\\\\,g; s,\$,$$,g +EOF_SED + program_transform_name="`echo $program_transform_name|sed -f conftestsed`" + rm -f conftestsed +fi +test "$program_prefix" != NONE && + program_transform_name="s,^,${program_prefix},; $program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" + +# sed with no file args requires a program. +test "$program_transform_name" = "" && program_transform_name="s,x,x," + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:662: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + +PACKAGE=popt + +VERSION=1.2 + +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } +fi +cat >> confdefs.h <> confdefs.h <&6 +echo "configure:708: checking for working aclocal" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (aclocal --version) < /dev/null > /dev/null 2>&1; then + ACLOCAL=aclocal + echo "$ac_t""found" 1>&6 +else + ACLOCAL="$missing_dir/missing aclocal" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 +echo "configure:721: checking for working autoconf" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoconf --version) < /dev/null > /dev/null 2>&1; then + AUTOCONF=autoconf + echo "$ac_t""found" 1>&6 +else + AUTOCONF="$missing_dir/missing autoconf" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working automake""... $ac_c" 1>&6 +echo "configure:734: checking for working automake" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (automake --version) < /dev/null > /dev/null 2>&1; then + AUTOMAKE=automake + echo "$ac_t""found" 1>&6 +else + AUTOMAKE="$missing_dir/missing automake" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 +echo "configure:747: checking for working autoheader" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoheader --version) < /dev/null > /dev/null 2>&1; then + AUTOHEADER=autoheader + echo "$ac_t""found" 1>&6 +else + AUTOHEADER="$missing_dir/missing autoheader" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 +echo "configure:760: checking for working makeinfo" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (makeinfo --version) < /dev/null > /dev/null 2>&1; then + MAKEINFO=makeinfo + echo "$ac_t""found" 1>&6 +else + MAKEINFO="$missing_dir/missing makeinfo" + echo "$ac_t""missing" 1>&6 +fi + + + + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:780: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:809: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + ac_prog_rejected=no + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:857: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:891: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:896: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:920: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:948: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:969: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:986: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 +echo "configure:1010: checking whether ${CC-cc} needs -traditional" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_pattern="Autoconf.*'x'" + cat > conftest.$ac_ext < +Autoconf TIOCGETP +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +else + rm -rf conftest* + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat > conftest.$ac_ext < +Autoconf TCGETA +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi + +echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + + + +echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 +echo "configure:1059: checking for ${CC-cc} option to accept ANSI C" >&5 +if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + cat > conftest.$ac_ext < +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; + +int main() { + +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + +; return 0; } +EOF +if { (eval echo configure:1112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + am_cv_prog_cc_stdc="$ac_arg"; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +CC="$ac_save_CC" + +fi + +if test -z "$am_cv_prog_cc_stdc"; then + echo "$ac_t""none needed" 1>&6 +else + echo "$ac_t""$am_cv_prog_cc_stdc" 1>&6 +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac + + + +echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 +echo "configure:1138: checking for function prototypes" >&5 +if test "$am_cv_prog_cc_stdc" != no; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define PROTOTYPES 1 +EOF + + U= ANSI2KNR= +else + echo "$ac_t""no" 1>&6 + U=_ ANSI2KNR=./ansi2knr + # Ensure some checks needed by ansi2knr itself. + echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1151: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1164: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1231: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + for ac_hdr in string.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1258: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1268: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +fi + + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1300: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1337: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +if test $CC = gcc; then + CFLAGS="-Wall $CFLAGS" +fi +addlib() { + l=$1 + shift + case "$target" in + *-*-solaris*) LIBS="$LIBS -L$l -R $l $*";; + *) LIBS="$LIBS -L$l $*";; + esac +} + +if test X"$GCC" = Xyes ; then + TARGET="depend allprogs" +else + TARGET="everything" + # + # let the Makefile know that we're done with `depend', since we don't + # have gcc we're not going to rebuild our dependencies at all. + # + echo > .depend-done +fi + + +for ac_hdr in unistd.h alloca.h libintl.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1415: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1425: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +echo $ac_n "checking for /usr/ucblib in LIBS""... $ac_c" 1>&6 +echo "configure:1452: checking for /usr/ucblib in LIBS" >&5 +if test -d /usr/ucblib ; then + if test "$build" = "mips-sni-sysv4" ; then + addlib /usr/ccs/lib -lc + fi + + addlib /usr/ucblib + + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +for ac_func in strerror +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1468: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in gettext +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1523: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +for ac_func in dgettext +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1578: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + +echo $ac_n "checking for setreuid""... $ac_c" 1>&6 +echo "configure:1631: checking for setreuid" >&5 +if eval "test \"`echo '$''{'ac_cv_func_setreuid'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char setreuid(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_setreuid) || defined (__stub___setreuid) +choke me +#else +setreuid(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_setreuid=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_setreuid=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'setreuid`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 + + echo $ac_n "checking for setreuid in -lucb""... $ac_c" 1>&6 +echo "configure:1678: checking for setreuid in -lucb" >&5 +ac_lib_var=`echo ucb'_'setreuid | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lucb $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.12" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile po/Makefile.in config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@PACKAGE@%$PACKAGE%g +s%@VERSION@%$VERSION%g +s%@ACLOCAL@%$ACLOCAL%g +s%@AUTOCONF@%$AUTOCONF%g +s%@AUTOMAKE@%$AUTOMAKE%g +s%@AUTOHEADER@%$AUTOHEADER%g +s%@MAKEINFO@%$MAKEINFO%g +s%@SET_MAKE@%$SET_MAKE%g +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@U@%$U%g +s%@ANSI2KNR@%$ANSI2KNR%g +s%@RANLIB@%$RANLIB%g +s%@TARGET@%$TARGET%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h +sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/popt-1.2/configure.in b/popt-1.2/configure.in new file mode 100755 index 00000000..0b0d0a8b --- /dev/null +++ b/popt-1.2/configure.in @@ -0,0 +1,63 @@ +AC_INIT(popt.h) +AM_INIT_AUTOMAKE(popt, 1.2) +AM_CONFIG_HEADER(config.h) + +AC_PROG_CC +AC_GCC_TRADITIONAL +AM_C_PROTOTYPES + +AC_PROG_RANLIB +AC_PROG_INSTALL + +if test $CC = gcc; then + CFLAGS="-Wall $CFLAGS" +fi +addlib() { + l=$1 + shift + case "$target" in + *-*-solaris*) LIBS="$LIBS -L$l -R $l $*";; + *) LIBS="$LIBS -L$l $*";; + esac +} + +dnl +dnl if CC is gcc, we can rebuild the dependencies (since the depend rule +dnl requires gcc). If it's not, don't rebuild dependencies -- use what was +dnl shipped with RPM. +dnl +if test X"$GCC" = Xyes ; then + TARGET="depend allprogs" +else + TARGET="everything" + # + # let the Makefile know that we're done with `depend', since we don't + # have gcc we're not going to rebuild our dependencies at all. + # + echo > .depend-done +fi +AC_SUBST(TARGET) + +AC_CHECK_HEADERS(unistd.h alloca.h libintl.h) +AC_MSG_CHECKING(for /usr/ucblib in LIBS) +if test -d /usr/ucblib ; then + if test "$build" = "mips-sni-sysv4" ; then + addlib /usr/ccs/lib -lc + fi + + addlib /usr/ucblib + + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +AC_CHECK_FUNCS(strerror) +AC_CHECK_FUNCS(gettext) +AC_CHECK_FUNCS(dgettext) +AC_CHECK_FUNC(setreuid, [], [ + AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi]) +]) + +AC_OUTPUT([Makefile po/Makefile.in], + [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]) diff --git a/popt-1.2/findme.c b/popt-1.2/findme.c new file mode 100644 index 00000000..1cda62c5 --- /dev/null +++ b/popt-1.2/findme.c @@ -0,0 +1,60 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#ifdef __NeXT +/* access macros are not declared in non posix mode in unistd.h - + don't try to use posix on NeXTstep 3.3 ! */ +#include +#endif + +#if HAVE_ALLOCA_H +# include +#endif + +#include "findme.h" + +char * findProgramPath(char * argv0) { + char * path = getenv("PATH"); + char * pathbuf; + char * start, * chptr; + char * buf; + + /* If there is a / in the argv[0], it has to be an absolute + path */ + if (strchr(argv0, '/')) + return strdup(argv0); + + if (!path) return NULL; + + start = pathbuf = alloca(strlen(path) + 1); + buf = malloc(strlen(path) + strlen(argv0) + 2); + strcpy(pathbuf, path); + + chptr = NULL; + do { + if ((chptr = strchr(start, ':'))) + *chptr = '\0'; + sprintf(buf, "%s/%s", start, argv0); + + if (!access(buf, X_OK)) + return buf; + + if (chptr) + start = chptr + 1; + else + start = NULL; + } while (start && *start); + + free(buf); + + return NULL; +} diff --git a/popt-1.2/findme.h b/popt-1.2/findme.h new file mode 100644 index 00000000..fdd01d52 --- /dev/null +++ b/popt-1.2/findme.h @@ -0,0 +1,10 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifndef H_FINDME +#define H_FINDME + +char * findProgramPath(char * argv0); + +#endif diff --git a/popt-1.2/install-sh b/popt-1.2/install-sh new file mode 100755 index 00000000..58719246 --- /dev/null +++ b/popt-1.2/install-sh @@ -0,0 +1,238 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. +# + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/popt-1.2/missing b/popt-1.2/missing new file mode 100755 index 00000000..cbe2b0ef --- /dev/null +++ b/popt-1.2/missing @@ -0,0 +1,188 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Franc,ois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`configure.in'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`configure.in'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`configure.in'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER([^):]*:\([^)]*\)).*/\1/p' configure.in` + if test -z "$files"; then + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^):]*\)).*/\1/p' configure.in` + test -z "$files" || files="$files.in" + else + files=`echo "$files" | sed -e 's/:/ /g'` + fi + test -z "$files" && files="config.h.in" + touch $files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print \ + | sed 's/^\(.*\).am$/touch \1.in/' \ + | sh + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/popt-1.2/mkinstalldirs b/popt-1.2/mkinstalldirs new file mode 100755 index 00000000..d0fd194f --- /dev/null +++ b/popt-1.2/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id$ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/popt-1.2/po/Makefile.in b/popt-1.2/po/Makefile.in new file mode 100644 index 00000000..2f041d34 --- /dev/null +++ b/popt-1.2/po/Makefile.in @@ -0,0 +1,80 @@ +# Generated automatically from Makefile.in.in by configure. +srcdir = . +top_srcdir = .. + +INSTALL= /usr/bin/install -c +INSTALL_PROGRAM= ${INSTALL} +INSTALL_DATA= ${INSTALL} -m 644 +CC = gcc + +installprefix = $(DESTDIR) + +MSGMERGE = msgmerge + +NLSPACKAGE = popt + +LINGUAS = ro +CATALOGS = $(addsuffix .mo, $(LINGUAS)) + +POTFILES = \ + +all: $(NLSPACKAGE).pot $(CATALOGS) + +$(NLSPACKAGE).pot: $(POTFILES) + xgettext --default-domain=$(NLSPACKAGE) \ + --add-comments --keyword=_ --keyword=N_ $(POTFILES) + if cmp -s $(NLSPACKAGE).po $(NLSPACKAGE).pot; then \ + rm -f $(NLSPACKAGE).po; \ + else \ + mv $(NLSPACKAGE).po $(NLSPACKAGE).pot; \ + fi + +update-po: Makefile + @$(MAKE) $(NLSPACKAGE).pot + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + lang=`echo $$cat | sed 's/.mo//'`; \ + if $(MSGMERGE) $$lang.po $(NLSPACKAGE).pot > $$lang.pox ; then \ + echo "$(MSGMERGE) of $$lang succeeded" ; \ + mv $$lang.pox $$lang.po ; \ + else \ + echo "$(MSGMERGE) of $$lang failed" ; \ + rm -f $$lang.pox ; \ + fi \ + done + +clean: + rm -f *mo $(NLSPACKAGE).pot + +distclean: clean + rm -f .depend Makefile + +depend: + +install: + for n in $(CATALOGS); do \ + l=`basename $$n .mo`; \ + $(INSTALL) -m 755 -d $(installprefix)/$(LOCALEDIR)/$$l; \ + $(INSTALL) -m 755 -d $(installprefix)/$(LOCALEDIR)/$$l/LC_MESSAGES; \ + $(INSTALL) -m 644 $$n $(installprefix)/$(LOCALEDIR)/$$l/LC_MESSAGES/rpm.mo; \ + done + +check: + +POTFILES: POTFILES.in + ( if test 'x$(srcdir)' != 'x.'; then \ + posrcprefix='$(top_srcdir)/'; \ + else \ + posrcprefix="../"; \ + fi; \ + sed -e '/^#/d' -e '/^[ ]*$$/d' \ + -e "s@.*@ $$posrcprefix& \\\\@" \ + -e '$$s/\(.*\) \\/\1/' < $(srcdir)/POTFILES.in > POTFILES ) + +Makefile: Makefile.in.in ../config.status POTFILES + cd .. \ + && CONFIG_FILES=po/$@.in CONFIG_HEADERS= \ + $(SHELL) ./config.status + +%.mo: %.po + msgfmt -o $@ $< diff --git a/popt-1.2/po/Makefile.in.in b/popt-1.2/po/Makefile.in.in new file mode 100644 index 00000000..81bd73dd --- /dev/null +++ b/popt-1.2/po/Makefile.in.in @@ -0,0 +1,80 @@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = $(srcdir) + +INSTALL= @INSTALL@ +INSTALL_PROGRAM= @INSTALL_PROGRAM@ +INSTALL_DATA= @INSTALL_DATA@ +CC = @CC@ + +installprefix = $(DESTDIR) + +MSGMERGE = msgmerge + +NLSPACKAGE = @PACKAGE@ + +LINGUAS = ro +CATALOGS = $(addsuffix .mo, $(LINGUAS)) + +POTFILES = \ + +all: $(NLSPACKAGE).pot $(CATALOGS) + +$(NLSPACKAGE).pot: $(POTFILES) + xgettext --default-domain=$(NLSPACKAGE) \ + --add-comments --keyword=_ --keyword=N_ $(POTFILES) + if cmp -s $(NLSPACKAGE).po $(NLSPACKAGE).pot; then \ + rm -f $(NLSPACKAGE).po; \ + else \ + mv $(NLSPACKAGE).po $(NLSPACKAGE).pot; \ + fi + +update-po: Makefile + @$(MAKE) $(NLSPACKAGE).pot + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + lang=`echo $$cat | sed 's/.mo//'`; \ + if $(MSGMERGE) $$lang.po $(NLSPACKAGE).pot > $$lang.pox ; then \ + echo "$(MSGMERGE) of $$lang succeeded" ; \ + mv $$lang.pox $$lang.po ; \ + else \ + echo "$(MSGMERGE) of $$lang failed" ; \ + rm -f $$lang.pox ; \ + fi \ + done + +clean: + rm -f *mo $(NLSPACKAGE).pot + +distclean: clean + rm -f .depend Makefile + +depend: + +install: + for n in $(CATALOGS); do \ + l=`basename $$n .mo`; \ + $(INSTALL) -m 755 -d $(installprefix)/$(LOCALEDIR)/$$l; \ + $(INSTALL) -m 755 -d $(installprefix)/$(LOCALEDIR)/$$l/LC_MESSAGES; \ + $(INSTALL) -m 644 $$n $(installprefix)/$(LOCALEDIR)/$$l/LC_MESSAGES/rpm.mo; \ + done + +check: + +POTFILES: POTFILES.in + ( if test 'x$(srcdir)' != 'x.'; then \ + posrcprefix='$(top_srcdir)/'; \ + else \ + posrcprefix="../"; \ + fi; \ + sed -e '/^#/d' -e '/^[ ]*$$/d' \ + -e "s@.*@ $$posrcprefix& \\\\@" \ + -e '$$s/\(.*\) \\/\1/' < $(srcdir)/POTFILES.in > POTFILES ) + +Makefile: Makefile.in.in ../config.status POTFILES + cd .. \ + && CONFIG_FILES=po/$@.in CONFIG_HEADERS= \ + $(SHELL) ./config.status + +%.mo: %.po + msgfmt -o $@ $< diff --git a/popt-1.2/po/POTFILES b/popt-1.2/po/POTFILES new file mode 100644 index 00000000..688bdcbf --- /dev/null +++ b/popt-1.2/po/POTFILES @@ -0,0 +1,6 @@ + ../findme.c \ + ../popt.c \ + ../poptconfig.c \ + ../popthelp.c \ + ../poptparse.c \ + ../test1.c \ diff --git a/popt-1.2/po/POTFILES.in b/popt-1.2/po/POTFILES.in new file mode 100644 index 00000000..4817ca1d --- /dev/null +++ b/popt-1.2/po/POTFILES.in @@ -0,0 +1,11 @@ +# List of files which contain translatable strings. + +# Package source files + +findme.c +popt.c +poptconfig.c +popthelp.c +poptparse.c +test1.c + diff --git a/popt-1.2/po/ro.po b/popt-1.2/po/ro.po new file mode 100644 index 00000000..90c4e02f --- /dev/null +++ b/popt-1.2/po/ro.po @@ -0,0 +1,72 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# Cristian Gafton , 1998. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: POPT\n" +"POT-Creation-Date: 1998-10-22 14:44-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Cristian Gafton \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-2\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../popt.c:34 +msgid "unknown errno" +msgstr "eroare necunoscuta" + +#: ../popt.c:407 +#, c-format +msgid "option type (%d) not implemented in popt\n" +msgstr "optiunea de tipul (%d) nu este implementata in popt\n" + +#: ../popt.c:531 +msgid "missing argument" +msgstr "argument lipsa" + +#: ../popt.c:533 +msgid "unknown option" +msgstr "optiune necunoscuta" + +#: ../popt.c:535 +msgid "aliases nested too deeply" +msgstr "recursivitate infinita la optiunile sinonime" + +#: ../popt.c:537 +msgid "error in paramter quoting" +msgstr "eroare la insertie parametru" + +#: ../popt.c:539 +msgid "invalid numeric value" +msgstr "valoare numarica invalida" + +#: ../popt.c:541 +msgid "number too large or too small" +msgstr "numar prea mare sau prea mic" + +#: ../popt.c:545 +msgid "unknown error" +msgstr "eroare necuinoscuta" + +#: ../popthelp.c:29 +msgid "Show this help message" +msgstr "Afisare mesaj de help" + +#: ../popthelp.c:30 +msgid "Display brief usage message" +msgstr "Afisare mesaj sintaxa sumar" + +#: ../popthelp.c:41 +msgid "ARG" +msgstr "" + +#: ../popthelp.c:148 +msgid "Usage:" +msgstr "Sintaxa:" + +#: ../popthelp.c:166 +msgid "[OPTION...]" +msgstr "[OPTIUNE...]" diff --git a/popt-1.2/popt.3 b/popt-1.2/popt.3 new file mode 100644 index 00000000..eaf6c402 --- /dev/null +++ b/popt-1.2/popt.3 @@ -0,0 +1,715 @@ +.TH POPT 3 "June 30, 1998" "" "Linux Programmer's Manual" +.SH NAME +popt \- Parse command line options +.SH SYNOPSIS +.nf +.B #include +.sp +.BI "poptContext poptGetContext(char * " name ", int " argc , +.BI " char ** "argv , +.BI " struct poptOption * " options , +.BI " int " flags ); +.sp +.BI "void poptFreeContext(poptContext " con ); +.sp +.BI "void poptResetContext(poptContext " con ); +.sp +.BI "int poptGetNextOpt(poptContext " con ); +.sp +.BI "char * poptGetOptArg(poptContext " con ); +.sp +.BI "char * poptGetArg(poptContext " con ); +.sp +.BI "char * poptPeekArg(poptContext " con ); +.sp +.BI "char ** poptGetArgs(poptContext " con ); +.sp +.BI "const char * poptStrerror(const int " error ); +.sp +.BI "char * poptBadOption(poptContext " con ", int " flags ); +.sp +.BI "int poptReadDefaultConfig(poptContext " con ", int " flags ); +.sp +.BI "int poptReadConfigFile(poptContext " con ", char * " fn ); +.sp +.BI "int poptAddAlias(poptContext " con ", struct poptAlias " alias , +.BI " int " flags ); +.sp +.BI "int poptParseArgvString(char * " s ", int * " argcPtr , +.BI " char *** " argvPtr ); +.sp +.BI "int poptStuffArgs(poptContext " con ", char ** " argv ); +.sp +.fi +.SH DESCRIPTION +The popt library exists essentially for parsing command-line +options. It is found superior in many ways when compared to +parsing the argv array by hand or using the getopt functions +.B getopt() +and +.B getopt_long() +[see +.BR getopt "(3)]." +Some specific advantages of popt are: it does not utilize global +.RI "variables, thus enabling multiple passes in parsing " argv +.RI "; it can parse an arbitrary array of " argv "-style elements, " +allowing parsing of command-line-strings from any source; +it provides a standard method of option aliasing (to be +discussed at length below.); it can exec external option filters; and, +finally, it can automatically generate help and usage messages for +the application. +.sp +Like +.BR getopt_long() , +the popt library supports short and long style options. Recall +that a +.B short option +consists of a - character followed by a single alphanumeric character. +A +.BR "long option" , +common in GNU utilities, consists of two - characters followed by a +string made up of letters, numbers and hyphens. Long options are +optionally allowed to begin with a single -, primarily to allow command-line +compatibility between popt applications and X toolkit applications. +Either type of option may be followed by an argument. A space separates a +short option from its arguments; either a space or an = separates a long +option from an argument. +.sp +The popt library is highly portable and should work on any POSIX +platform. The latest version is always available from: +ftp://ftp.redhat.com/pub/redhat/code/popt. +.sp +It may be redistributed under either the GNU General Public License +or the GNU Library General Public License, at the distributor's discretion. +.SH "BASIC POPT USAGE" +.SS "1. THE OPTION TABLE" +Applications provide popt with information on their command-line +options by means of an "option table," i.e., an array of +.B struct poptOption +structures: +.sp +#include +.sp +.nf +struct poptOption { + const char * longName; /* may be NULL */ + char shortName; /* may be '\\0' */ + int argInfo; + void * arg; /* depends on argInfo */ + int val; /* 0 means don't return, just update flag */ + char * descrip; /* description for autohelp -- may be NULL */ + char * argDescrip; /* argument description for autohelp */ +}; +.fi +.sp +Each member of the table defines a single option that may be +passed to the program. Long and short options are considered +a single option that may occur in two different forms. The +first two members, +.IR longName " and " shortName ", define the names of the option;" +the first is a long name, while the latter is a single character. +.sp +The +.IR argInfo " member tell popt what type of argument is expected" +after the argument. If no option is expected, +.BR POPT_ARG_NONE " should be used. (Connoisseurs of " getopt() +.RI "will note that " argInfo " is the only required field of " +.BR "struct poptOption" " that is not directly analogous to a field in " +.RB "the " getopt_long() " argument table. The similarity between the " +.RB "two allows for easy transitions from " getopt_long " to popt.) " +The rest of the valid values are shown in the following table: +.sp +.nf +.B " Value Description arg Type" +.BR POPT_ARG_NONE " No argument expected int" +.BR POPT_ARG_STRING " No type checking to be performed char *" +.BR POPT_ARG_INT " An integer argument is expected int" +.BR POPT_ARG_LONG " A long integer is expected long" +.sp +.fi +If \fIargInfo\fR value is logically or'd with \fBPOPT_ARGFLAG_ONEDASH\fR, +the long argument may be given with a single - instead of two. For example, +if \fB--longopt\fR is an option with \fBPOPT_ARGFLAG_ONEDASH\fR, is +specified, \fB-longopt\fR is accepted as well. +.sp +.RI "The next element, " arg ", allows popt to automatically update " +.RI "program variables when the option is used. If " arg " is " +.BR NULL ", it is ignored and popt takes no special action. " +Otherwise it should point to a variable of the type indicated in the +right-most column of the table above. +.sp +.RI "If the option takes no argument (" argInfo " is " +.BR POPT_ARG_NONE "), the variable pointed to by " +.IR arg " is set to 1 when the option is used. (Incidentally, it " +will perhaps not escape the attention of hunt-and-peck typists that +.RB "the value of " POPT_ARG_NONE " is 0.) If the option does take " +an argument, the variable that +.IR arg " points to is updated to reflect the value of the argument." +.RB "Any string is acceptable for " POPT_ARG_STRING " arguments, but " +.BR POPT_ARG_INT " and " POPT_ARG_LONG " are converted to the +appropriate type, and an error returned if the conversion fails. +.sp +.RI "The next option, " val ", is the value popt's parsing function +should return when the option is encountered. If it is 0, the parsing +function does not return a value, instead parsing the next +command-line argument. +.sp +.RI "The last two options, " descrip " and " argDescrip " are only required +if automatic help messages are desired (automatic usage messages can +.RI "be generated without them). " descrip " is a text description of the +.RI "argument and " argdescrip " is a short summary of the type of arguments +.RI "the option expects, or NULL if the option doesn't require any +arguments. +.sp +.RB "If popt should automatically provide " --usage " and " --help " (" -? ") +.RB "options, one line in the table should be the macro " POPT_AUTOHELP ". +.RB "This macro includes another option table (via " POPT_ARG_INCLUDE_TABLE; +see below) in the main one which provides the table entries for these +.RB "arguments. When " --usage " or " --help " are passed to programs which +use popt's automatical help, popt displays the appropriate message on +stderr as soon as it finds the option, and exits the program with a +return code of 0. If you want to use popt's automatic help generation in +a different way, you need to explicitly add the option entries to your programs +.RB "option table instead of using " POPT_AUTOHELP ". +.sp +The final structure in the table should have all the pointer values set +.RB "to " NULL " and all the arithmetic values set to 0, marking the " +end of the table. +.sp +There are two types of option table entries which do not specify command +line options. When either of these types of entries are used, the +\fIlongName\fR element must be \fBNULL\fR and the \fBshortName\fR element +must be \fB'\\0'\fR. +.sp +The first of these special entry types allows the application to nest +another option table in the current one; such nesting may extend quite +deeply (the actual depth is limited by the program's stack). Including +other option tables allows a library to provide a standard set of +command-line options to every program which uses it (this is often done +in graphical programming toolkits, for example). To do this, set +the \fIargInfo\fR field to \fBPOPT_ARG_INCLUDE_TABLE\fR and the +\fRarg\fR field to point to the table which is being included. If +automatic help generation is being used, the \fIdescrip\fR field should +contain a overall description of the option table being included. +.sp +The other special option table entry type tells popt to call a function (a +callback) when any option in that table is found. This is especially usefull +when included option tables are being used, as the program which provides +the top-level option table doesn't need to be aware of the other options +which are provided by the included table. When a callback is set for +a table, the parsing function never returns information on an option in +the table. Instead, options information must be retained via the callback +or by having popt set a variable through the option's \fIarg\fR field. +Option callbacks should match the following prototype: +.sp +.nf +.BI "void poptCallbackType(poptContext con, +.BI " const struct poptOption * opt, +.BI " const char * arg, void * data); +.fi +.sp +The first parameter is the context which is being parsed (see the next +section for information on contexts), \fIopt\fR points to the option +which triggered this callback, and \fIarg\fR is the option's argument. +If the option does not take an argument, \fIarg\fR is \fBNULL\fR. The +final parameter, \fIdata\fR is taken from the \fIdescrip\fR field +of the option table entry which defined the callback. As \fIdescrip\fR +is a pointer, this allows callback functions to be passed an arbitrary +set of data (though a typecast will have to be used). +.sp +The option table entry which defines a callback has an \fIargInfo\fR of +\fBPOPT_ARG_CALLBACK\fR, an \fIarg\fR which points to the callback +function, and a \fIdescrip\fR field which specifies an arbitrary pointer +to be passed to the callback. +.SS "2. CREATING A CONTEXT" +popt can interleave the parsing of multiple command-line sets. It allows +this by keeping all the state information for a particular set of +command-line arguments in a +.BR poptContext " data structure, an opaque type that should not be " +modified outside the popt library. +.sp +.RB "New popt contexts are created by " poptGetContext() ":" +.sp +.nf +.BI "poptContext poptGetContext(char * " name ", int "argc ", +.BI " char ** "argv ", +.BI " struct poptOption * "options ", +.BI " int "flags ");" +.fi +.sp +The first parameter, +.IR name ", is used only for alias handling (discussed later). It " +should be the name of the application whose options are being parsed, +.RB "or should be " NULL " if no option aliasing is desired. The next " +two arguments specify the command-line arguments to parse. These are +.RB "generally passed to " poptGetContext() " exactly as they were " +.RB "passed to the program's " main() " function. The " +.IR options " parameter points to the table of command-line options, " +which was described in the previous section. The final parameter, +.IR flags ",is not currently used but should always be specified as +0 for compatibility with future versions of the popt library. +.sp +.RB "A " poptContext " keeps track of which options have already been " +parsed and which remain, among other things. If a program wishes to +restart option processing of a set of arguments, it can reset the +.BR poptContext " by passing the context as the sole argument to " +.BR poptResetContext() . +.sp +When argument processing is complete, the process should free the +.BR poptContext " as it contains dynamically allocated components. The " +.BR poptFreeContext() " function takes a " +.BR poptContext " as its sole argument and frees the resources the " +context is using. +.sp +.RB "Here are the prototypes of both " poptResetContext() " and " +.BR poptFreeContext() : +.sp +.nf +.B #include +.BI "void poptFreeContext(poptContext " con ");" +.BI "void poptResetContext(poptContext " con ");" +.fi +.sp +.SS "3. PARSING THE COMMAND LINE" +.RB "After an application has created a " poptContext ", it may begin " +.RB "parsing arguments. " poptGetNextOpt() " performs the actual " +argument parsing. +.sp +.nf +.B #include +.BI "int poptGetNextOpt(poptContext " con ");" +.fi +.sp +Taking the context as its sole argument, this function parses the next +command-line argument found. After finding the next argument in the +option table, the function fills in the object pointed to by the option +.RI "table entry's " arg +.RB "pointer if it is not " NULL ". If the val entry for the option is " +non-0, the function then returns that value. Otherwise, +.BR poptGetNextOpt() " continues on to the next argument." +.sp +.BR poptGetNextOpt() " returns -1 when the final argument has been " +parsed, and other negative values when errors occur. This makes it a +good idea to +.RI "keep the " val " elements in the options table greater than 0." +.sp +.RI "If all of the command-line options are handled through " arg +pointers, command-line parsing is reduced to the following line of code: +.sp +.nf +rc = poptGetNextOpt(poptcon); +.fi +.sp +Many applications require more complex command-line parsing than this, +however, and use the following structure: +.sp +.nf +while ((rc = poptGetNextOpt(poptcon)) > 0) { + switch (rc) { + /* specific arguments are handled here */ + } +} +.fi +.sp +When returned options are handled, the application needs to know the +value of any arguments that were specified after the option. There are two +ways to discover them. One is to ask popt to fill in a variable with the +.RI "value of the option through the option table's " arg " elements. The " +.RB "other is to use " poptGetOptArg() ":" +.sp +.nf +.B #include +.BI "char * poptGetOptArg(poptContext " con ");" +.fi +.sp +This function returns the argument given for the final option returned by +.BR poptGetNextOpt() ", or it returns " NULL " if no argument was specified." +.sp +.SS "4. LEFTOVER ARGUMENTS" +Many applications take an arbitrary number of command-line arguments, +such as a list of file names. When popt encounters an argument that does +not begin with a -, it assumes it is such an argument and adds it to a list +of leftover arguments. Three functions allow applications to access such +arguments: +.nf +.HP +.BI "char * poptGetArg(poptContext " con ");" +.fi +This function returns the next leftover argument and marks it as +processed. +.PP +.nf +.HP +.BI "char * poptPeekArg(poptContext " con ");" +.fi +The next leftover argument is returned but not marked as processed. +This allows an application to look ahead into the argument list, +without modifying the list. +.PP +.nf +.HP +.BI "char ** poptGetArgs(poptContext " con ");" +.fi +All the leftover arguments are returned in a manner identical to +.IR argv ". The final element in the returned array points to " +.BR NULL ", indicating the end of the arguments. +.sp +.SS "5. AUTOMATIC HELP MESSAGES" +The \fBpopt\fR library can automatically generate help messages which +describe the options a program accepts. There are two types of help +messages which can be generated. Usage messages are a short messages +which lists valid options, but does not describe them. Help messages +describe each option on one (or more) lines, resulting in a longer, but +more useful, message. Whenever automatic help messages are used, the +\fBdescrip\fR and \fBargDescrip\fR fields \fBstruct poptOption\fR members +should be filled in for each option. +.sp +The \fBPOPT_AUTOHELP\fR macro makes it easy to add \fB--usage\fR and +\fB--help\fR messages to your program, and is described in part 1 +of this man page. If more control is needed over your help messages, +the following two functions are available: +.sp +.nf +.B #include +.BI "void poptPrintHelp(poptContext " con ", FILE * " f ", int " flags "); +.BI "void poptPrintUsage(poptContext " con ", FILE * " f ", int " flags "); +.fi +.sp +\fBpoptPrintHelp()\fR displays the standard help message to the stdio file +descriptor f, while \fBpoptPrintUsage()\fR displays the shorter usage +message. Both functions currently ignore the \fBflags\fR argument; it is +there to allow future changes. +.sp +.SH "ERROR HANDLING" +All of the popt functions that can return errors return integers. +When an error occurs, a negative error code is returned. The +following table summarizes the error codes that occur: +.sp +.nf +.B " Error Description" +.BR "POPT_ERROR_NOARG " "Argument missing for an option." +.BR "POPT_ERROR_BADOPT " "Option's argument couldn't be parsed." +.BR "POPT_ERROR_OPTSTOODEEP " "Option aliasing nested too deeply." +.BR "POPT_ERROR_BADQUOTE " "Quotations do not match." +.BR "POPT_ERROR_BADNUMBER " "Option couldn't be converted to number." +.BR "POPT_ERROR_OVERFLOW " "A given number was too big or small." +.fi +.sp +Here is a more detailed discussion of each error: +.sp +.TP +.B POPT_ERROR_NOARG +An option that requires an argument was specified on the command +line, but no argument was given. This can be returned only by +.BR poptGetNextOpt() . +.sp +.TP +.B POPT_ERROR_BADOPT +.RI "An option was specified in " argv " but is not in the option +.RB "table. This error can be returned only from " poptGetNextOpt() . +.sp +.TP +.B POPT_ERROR_OPTSTOODEEP +A set of option aliases is nested too deeply. Currently, popt +follows options only 10 levels to prevent infinite recursion. Only +.BR poptGetNextOpt() " can return this error." +.sp +.TP +.B POPT_ERROR_BADQUOTE +A parsed string has a quotation mismatch (such as a single quotation +.RB "mark). " poptParseArgvString() ", " poptReadConfigFile() ", or " +.BR poptReadDefaultConfig() " can return this error." +.sp +.TP +.B POPT_ERROR_BADNUMBER +A conversion from a string to a number (int or long) failed due +to the string containing nonnumeric characters. This occurs when +.BR poptGetNextOpt() " is processing an argument of type " +.BR POPT_ARG_INT " or " POPT_ARG_LONG . +.sp +.TP +.B POPT_ERROR_OVERFLOW +A string-to-number conversion failed because the number was too +.RB "large or too small. Like " POPT_ERROR_BADNUMBER ", this error +.RB "can occur only when " poptGetNextOpt() " is processing an " +.RB "argument of type " POPT_ARG_INT " or " POPT_ARG_LONG . +.sp +.TP +.B POPT_ERROR_ERRNO +.RI "A system call returned with an error, and " errno " still +contains the error from the system call. Both +.BR poptReadConfigFile() " and " poptReadDefaultConfig() " can " +return this error. +.sp +.PP +Two functions are available to make it easy for applications to provide +good error messages. +.HP +.nf +.BI "const char * poptStrerror(const int " error ");" +.fi +This function takes a popt error code and returns a string describing +.RB "the error, just as with the standard " strerror() " function." +.PP +.HP +.nf +.BI "char * poptBadOption(poptContext " con ", int " flags ");" +.fi +.RB "If an error occurred during " poptGetNextOpt() ", this function " +.RI "returns the option that caused the error. If the " flags " argument" +.RB "is set to " POPT_BADOPTION_NOALIAS ", the outermost option is " +.RI "returned. Otherwise, " flags " should be 0, and the option that is " +returned may have been specified through an alias. +.PP +These two functions make popt error handling trivial for most +applications. When an error is detected from most of the functions, +an error message is printed along with the error string from +.BR poptStrerror() ". When an error occurs during argument parsing, " +code similiar to the following displays a useful error message: +.sp +.nf +fprintf(stderr, "%s: %s\\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); +.fi +.sp +.SH "OPTION ALIASING" +.RB "One of the primary benefits of using popt over " getopt() " is the " +ability to use option aliasing. This lets the user specify options that +popt expands into other options when they are specified. If the standard +.RB "grep program made use of popt, users could add a " --text " option " +.RB "that expanded to " "-i -n -E -2" " to let them more easily find " +information in text files. +.sp +.SS "1. SPECIFYING ALIASES" +.RI "Aliases are normally specified in two places: " /etc/popt +.RB "and the " .popt " file in the user's home directory (found through " +.RB "the " HOME " environment variable). Both files have the same format, " +an arbitrary number of lines formatted like this: +.sp +.IB appname " alias " newoption "" " expansion" +.sp +.RI "The " appname " is the name of the application, which must be the " +.RI "same as the " name " parameter passed to " +.BR poptGetContext() ". This allows each file to specify aliases for " +.RB "multiple programs. The " alias " keyword specifies that an alias is " +being defined; currently popt configuration files support only aliases, but +other abilities may be added in the future. The next option is the option +that should be aliased, and it may be either a short or a long option. The +rest of the line specifies the expansion for the alias. It is parsed +similarly to a shell command, which allows \\, ", and ' to be used for +quoting. If a backslash is the final character on a line, the next line +in the file is assumed to be a logical continuation of the line containing +the backslash, just as in shell. +.sp +.RB "The following entry would add a " --text " option to the grep command, " +as suggested at the beginning of this section. +.sp +.B "grep alias --text -i -n -E -2" +.SS "2. ENABLING ALIASES" +.RB "An application must enable alias expansion for a " poptContext +.RB "before calling " poptGetNextArg() " for the first time. There are " +three functions that define aliases for a context: +.HP +.nf +.BI "int poptReadDefaultConfig(poptContext " con ", int " flags ");" +.fi +.RI "This function reads aliases from " /etc/popt " and the " +.BR .popt " file in the user's home directory. Currently, " +.IR flags " should be " +.BR NULL ", as it is provided only for future expansion." +.PP +.HP +.nf +.BI "int poptReadConfigFile(poptContext " con ", char * " fn ");" +.fi +.RI "The file specified by " fn " is opened and parsed as a popt " +configuration file. This allows programs to use program-specific +configuration files. +.PP +.HP +.nf +.BI "int poptAddAlias(poptContext " con ", struct poptAlias " alias ", +.BI " int " flags ");" +.fi +Occasionally, processes want to specify aliases without having to +read them from a configuration file. This function adds a new alias +.RI "to a context. The " flags " argument should be 0, as it is " +currently reserved for future expansion. The new alias is specified +.RB "as a " "struct poptAlias" ", which is defined as:" +.sp +.nf +struct poptAlias { + char * longName; /* may be NULL */ + char shortName; /* may be '\\0' */ + int argc; + char ** argv; /* must be free()able */ +}; +.fi +.sp +.RI "The first two elements, " longName " and " shortName ", specify " +.RI "the option that is aliased. The final two, " argc " and " argv "," +define the expansion to use when the aliases option is encountered. +.PP +.SH "PARSING ARGUMENT STRINGS" +Although popt is usually used for parsing arguments already divided into +.RI "an " argv "-style array, some programs need to parse strings that " +are formatted identically to command lines. To facilitate this, popt +provides a function that parses a string into an array of strings, +using rules similiar to normal shell parsing. +.sp +.nf +.B "#include " +.BI "int poptParseArgvString(char * " s ", int * "argcPtr ", +.BI " char *** " argvPtr ");" +.fi +.sp +.RI "The string s is parsed into an " argv "-style array. The integer " +.RI "pointed to by the second parameter, " argcPtr ", contains the number " +of elements parsed, and the pointer pointed to by the final parameter is +set to point to the newly created array. The array is dynamically +.RB "allocated and should be " free() "ed when the application is finished " +with it. +.sp +.RI "The " argvPtr +.RB "created by " poptParseArgvString() " is suitable to pass directly " +.RB "to " poptGetContext() . +.SH "HANDLING EXTRA ARGUMENTS" +Some applications implement the equivalent of option aliasing but need +.RB "to do so through special logic. The " poptStuffArgs() " function " +allows an application to insert new arguments into the current +.BR poptContext . +.sp +.nf +.B "#include " +.BI "int poptStuffArgs(poptContext "con ", char ** " argv ");" +.fi +.sp +.RI "The passed " argv +.RB "must have a " NULL " pointer as its final element. When " +.BR poptGetNextOpt() " is next called, the " +"stuffed" arguments are the first to be parsed. popt returns to the +normal arguments once all the stuffed arguments have been exhausted. +.SH "EXAMPLE" +The following example is a simplified version of the program "robin" +which appears in Chapter 15 of the text cited below. Robin has +been stripped of everything but its argument-parsing logic, slightly +reworked, and renamed "parse." It may prove useful in illustrating +at least some of the features of the extremely rich popt library. +.sp +.nf +#include +#include + +void usage(poptContext optCon, int exitcode, char *error, char *addl) { + poptPrintUsage(optCon, stderr, 0); + if (error) fprintf(stderr, "%s: %s\n", error, addl); + exit(exitcode); +} + +int main(int argc, char *argv[]) { + char c; /* used for argument parsing */ + int i = 0; /* used for tracking options */ + char *portname; + int speed = 0; /* used in argument parsing to set speed */ + int raw = 0; /* raw mode? */ + int j; + char buf[BUFSIZ+1]; + poptContext optCon; /* context for parsing command-line options */ + + struct poptOption optionsTable[] = { + { "bps", 'b', POPT_ARG_INT, &speed, 0, + "signaling rate in bits-per-second", "BPS" }, + { "crnl", 'c', 0, 0, 'c', + "expand cr characters to cr/lf sequences" }, + { "hwflow", 'h', 0, 0, 'h', + "use hardware (RTS/CTS) flow control" }, + { "noflow", 'n', 0, 0, 'n', + "use no flow control" }, + { "raw", 'r', 0, &raw, 0, + "don't perform any character conversions" }, + { "swflow", 's', 0, 0, 's', + "use software (XON/XOF) flow control" } , + POPT_AUTOHELP + { NULL, 0, 0, NULL, 0 } + }; + + optCon = poptGetContext(NULL, argc, argv, optionsTable, 0); + poptSetOtherOptionHelp(optCon, "[OPTIONS]* "); + + if (argc < 2) { + poptPrintUsage(optCon, stderr, 0); + exit(1); + } + + /* Now do options processing, get portname */ + while ((c = poptGetNextOpt(optCon)) >= 0) { + switch (c) { + case 'c': + buf[i++] = 'c'; + break; + case 'h': + buf[i++] = 'h'; + break; + case 's': + buf[i++] = 's'; + break; + case 'n': + buf[i++] = 'n'; + break; + } + } + portname = poptGetArg(optCon); + if((portname == NULL) || !(poptPeekArg(optCon) == NULL)) + usage(optCon, 1, "Specify a single port", ".e.g., /dev/cua0"); + + if (c < -1) { + /* an error occurred during option processing */ + fprintf(stderr, "%s: %s\\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(c)); + return 1; + } + + /* Print out options, portname chosen */ + printf("Options chosen: "); + for(j = 0; j < i ; j++) + printf("-%c ", buf[j]); + if(raw) printf("-r "); + if(speed) printf("-b %d ", speed); + printf("\\nPortname chosen: %s\\n", portname); + + poptFreeContext(optCon); + exit(0); +} +.fi +.sp +RPM, a popular Linux package management program, makes heavy use +of popt's features. Many of its command-line arguments are implemented +through popt aliases, which makes RPM an excellent example of how to +take advantage of the popt library. For more information on RPM, see +http://www.rpm.org. The popt source code distribution includes test +program(s) which use all of the features of the popt libraries in +various ways. If a feature isn't working for you, the popt test code +is the first place to look. +.SH BUGS +None presently known. +.SH AUTHOR +Erik W. Troan +.PP +This man page is derived in part from +.IR "Linux Application Development" +by Michael K. Johnson and Erik W. Troan, Copyright (c) 1998 by Addison +Wesley Longman, Inc., and included in the popt documentation with the +permission of the Publisher and the appreciation of the Authors. +.PP +Thanks to Robert Lynch for his extensive work on this man page. +.SH "SEE ALSO" +.BR getopt (3) +.sp +.IR "Linux Application Development" ", by Michael K. Johnson and " +Erik W. Troan (Addison-Wesley, 1998; ISBN 0-201-30821-5), Chapter 24. +.sp +.BR popt.ps " is a Postscript version of the above cited book " +chapter. It can be found in the source archive for popt available at: +ftp://ftp.redhat.com/pub/redhat/code/popt diff --git a/popt-1.2/popt.c b/popt-1.2/popt.c new file mode 100644 index 00000000..9ebc81bb --- /dev/null +++ b/popt-1.2/popt.c @@ -0,0 +1,575 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#if HAVE_ALLOCA_H +# include +#endif + +#include "findme.h" +#include "popt.h" +#include "poptint.h" + +#ifndef HAVE_STRERROR +static char * strerror(int errno) { + extern int sys_nerr; + extern char * sys_errlist[]; + + if ((0 <= errno) && (errno < sys_nerr)) + return sys_errlist[errno]; + else + return POPT_("unknown errno"); +} +#endif + +void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) { + if (con->execPath) free(con->execPath); + con->execPath = strdup(path); + con->execAbsolute = allowAbsolute; +} + +static void invokeCallbacks(poptContext con, const struct poptOption * table, + int post) { + const struct poptOption * opt = table; + poptCallbackType cb; + + while (opt->longName || opt->shortName || opt->arg) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + invokeCallbacks(con, opt->arg, post); + } else if (((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) && + ((!post && (opt->argInfo & POPT_CBFLAG_PRE)) || + ( post && (opt->argInfo & POPT_CBFLAG_POST)))) { + cb = opt->arg; + cb(con, post ? POPT_CALLBACK_REASON_POST : POPT_CALLBACK_REASON_PRE, + NULL, NULL, opt->descrip); + } + opt++; + } +} + +poptContext poptGetContext(char * name, int argc, char ** argv, + const struct poptOption * options, int flags) { + poptContext con = malloc(sizeof(*con)); + + memset(con, 0, sizeof(*con)); + + con->os = con->optionStack; + con->os->argc = argc; + con->os->argv = argv; + + if (!(flags & POPT_CONTEXT_KEEP_FIRST)) + con->os->next = 1; /* skip argv[0] */ + + con->leftovers = malloc(sizeof(char *) * (argc + 1)); + con->options = options; + con->finalArgv = malloc(sizeof(*con->finalArgv) * (argc * 2)); + con->finalArgvAlloced = argc * 2; + con->flags = flags; + con->execAbsolute = 1; + + if (getenv("POSIXLY_CORRECT") || getenv("POSIX_ME_HARDER")) + con->flags |= POPT_CONTEXT_POSIXMEHARDER; + + if (name) + con->appName = strcpy(malloc(strlen(name) + 1), name); + + invokeCallbacks(con, con->options, 0); + + return con; +} + +void poptResetContext(poptContext con) { + con->os = con->optionStack; + con->os->currAlias = NULL; + con->os->nextCharArg = NULL; + con->os->nextArg = NULL; + con->os->next = 1; /* skip argv[0] */ + + con->numLeftovers = 0; + con->nextLeftover = 0; + con->restLeftover = 0; + con->doExec = NULL; + con->finalArgvCount = 0; +} + +/* Only one of longName, shortName may be set at a time */ +static int handleExec(poptContext con, char * longName, char shortName) { + int i; + + i = con->numExecs - 1; + if (longName) { + while (i >= 0 && (!con->execs[i].longName || + strcmp(con->execs[i].longName, longName))) i--; + } else { + while (i >= 0 && + con->execs[i].shortName != shortName) i--; + } + + if (i < 0) return 0; + + if (con->flags & POPT_CONTEXT_NO_EXEC) + return 1; + + if (!con->doExec) { + con->doExec = con->execs + i; + return 1; + } + + /* We already have an exec to do; remember this option for next + time 'round */ + if ((con->finalArgvCount + 1) >= (con->finalArgvAlloced)) { + con->finalArgvAlloced += 10; + con->finalArgv = realloc(con->finalArgv, + sizeof(*con->finalArgv) * con->finalArgvAlloced); + } + + i = con->finalArgvCount++; + con->finalArgv[i] = malloc((longName ? strlen(longName) : 0) + 3); + if (longName) + sprintf(con->finalArgv[i], "--%s", longName); + else + sprintf(con->finalArgv[i], "-%c", shortName); + + return 1; +} + +/* Only one of longName, shortName may be set at a time */ +static int handleAlias(poptContext con, char * longName, char shortName, + char * nextCharArg) { + int i; + + if (con->os->currAlias && con->os->currAlias->longName && longName && + !strcmp(con->os->currAlias->longName, longName)) + return 0; + if (con->os->currAlias && shortName == con->os->currAlias->shortName) + return 0; + + i = con->numAliases - 1; + if (longName) { + while (i >= 0 && (!con->aliases[i].longName || + strcmp(con->aliases[i].longName, longName))) i--; + } else { + while (i >= 0 && + con->aliases[i].shortName != shortName) i--; + } + + if (i < 0) return 0; + + if ((con->os - con->optionStack + 1) + == POPT_OPTION_DEPTH) + return POPT_ERROR_OPTSTOODEEP; + + if (nextCharArg && *nextCharArg) + con->os->nextCharArg = nextCharArg; + + con->os++; + con->os->next = 0; + con->os->stuffed = 0; + con->os->nextArg = con->os->nextCharArg = NULL; + con->os->currAlias = con->aliases + i; + con->os->argc = con->os->currAlias->argc; + con->os->argv = con->os->currAlias->argv; + + return 1; +} + +static void execCommand(poptContext con) { + char ** argv; + int pos = 0; + char * script = con->doExec->script; + + argv = malloc(sizeof(*argv) * + (6 + con->numLeftovers + con->finalArgvCount)); + + if (!con->execAbsolute && strchr(script, '/')) return; + + if (!strchr(script, '/') && con->execPath) { + argv[pos] = alloca(strlen(con->execPath) + strlen(script) + 2); + sprintf(argv[pos], "%s/%s", con->execPath, script); + } else { + argv[pos] = script; + } + pos++; + + argv[pos] = findProgramPath(con->os->argv[0]); + if (argv[pos]) pos++; + argv[pos++] = ";"; + + memcpy(argv + pos, con->finalArgv, sizeof(*argv) * con->finalArgvCount); + pos += con->finalArgvCount; + + if (con->numLeftovers) { + argv[pos++] = "--"; + memcpy(argv + pos, con->leftovers, sizeof(*argv) * con->numLeftovers); + pos += con->numLeftovers; + } + + argv[pos++] = NULL; + +#ifdef __hpux + setresuid(getuid(), getuid(),-1); +#else + setreuid(getuid(), getuid()); /*hlauer: not portable to hpux9.01 */ +#endif + + execvp(argv[0], argv); +} + +static const struct poptOption * findOption(const struct poptOption * table, + const char * longName, + const char shortName, + poptCallbackType * callback, + void ** callbackData, + int singleDash) { + const struct poptOption * opt = table; + const struct poptOption * opt2; + const struct poptOption * cb = NULL; + + while (opt->longName || opt->shortName || opt->arg) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + opt2 = findOption(opt->arg, longName, shortName, callback, + callbackData, singleDash); + if (opt2) { + if (*callback && !*callbackData) + *callbackData = opt->descrip; + return opt2; + } + } else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK) { + cb = opt; + } else if (longName && opt->longName && + (!singleDash || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) && + !strcmp(longName, opt->longName)) { + break; + } else if (shortName && shortName == opt->shortName) { + break; + } + opt++; + } + + if (!opt->longName && !opt->shortName) return NULL; + *callbackData = NULL; + *callback = NULL; + if (cb) { + *callback = cb->arg; + if (!(cb->argInfo & POPT_CBFLAG_INC_DATA)) + *callbackData = cb->descrip; + } + + return opt; +} + +/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */ +int poptGetNextOpt(poptContext con) { + char * optString, * chptr, * localOptString; + char * longArg = NULL; + char * origOptString; + long aLong; + char * end; + const struct poptOption * opt = NULL; + int done = 0; + int i; + poptCallbackType cb; + void * cbData; + int singleDash; + + while (!done) { + while (!con->os->nextCharArg && con->os->next == con->os->argc + && con->os > con->optionStack) + con->os--; + if (!con->os->nextCharArg && con->os->next == con->os->argc) { + invokeCallbacks(con, con->options, 1); + if (con->doExec) execCommand(con); + return -1; + } + + if (!con->os->nextCharArg) { + + origOptString = con->os->argv[con->os->next++]; + + if (con->restLeftover || *origOptString != '-') { + con->leftovers[con->numLeftovers++] = origOptString; + if (con->flags & POPT_CONTEXT_POSIXMEHARDER) + con->restLeftover = 1; + continue; + } + + /* Make a copy we can hack at */ + localOptString = optString = + strcpy(alloca(strlen(origOptString) + 1), + origOptString); + + if (!optString[0]) + return POPT_ERROR_BADOPT; + + if (optString[1] == '-' && !optString[2]) { + con->restLeftover = 1; + continue; + } else { + optString++; + if (*optString == '-') + singleDash = 0, optString++; + else + singleDash = 1; + + if (handleAlias(con, optString, '\0', NULL)) + continue; + if (handleExec(con, optString, '\0')) + continue; + + chptr = optString; + while (*chptr && *chptr != '=') chptr++; + if (*chptr == '=') { + longArg = origOptString + (chptr - localOptString) + 1; + *chptr = '\0'; + } + + opt = findOption(con->options, optString, '\0', &cb, &cbData, + singleDash); + if (!opt && !singleDash) return POPT_ERROR_BADOPT; + } + + if (!opt) + con->os->nextCharArg = origOptString + 1; + } + + if (con->os->nextCharArg) { + origOptString = con->os->nextCharArg; + + con->os->nextCharArg = NULL; + + if (handleAlias(con, NULL, *origOptString, + origOptString + 1)) { + origOptString++; + continue; + } + if (handleExec(con, NULL, *origOptString)) + continue; + + opt = findOption(con->options, NULL, *origOptString, &cb, + &cbData, 0); + if (!opt) return POPT_ERROR_BADOPT; + + origOptString++; + if (*origOptString) + con->os->nextCharArg = origOptString; + } + + if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) + *((int *)opt->arg) = 1; + else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) { + if (longArg) { + con->os->nextArg = longArg; + } else if (con->os->nextCharArg) { + con->os->nextArg = con->os->nextCharArg; + con->os->nextCharArg = NULL; + } else { + while (con->os->next == con->os->argc && + con->os > con->optionStack) + con->os--; + if (con->os->next == con->os->argc) + return POPT_ERROR_NOARG; + + con->os->nextArg = con->os->argv[con->os->next++]; + } + + if (opt->arg) { + switch (opt->argInfo & POPT_ARG_MASK) { + case POPT_ARG_STRING: + *((char **) opt->arg) = con->os->nextArg; + break; + + case POPT_ARG_INT: + case POPT_ARG_LONG: + aLong = strtol(con->os->nextArg, &end, 0); + if (*end) + return POPT_ERROR_BADNUMBER; + + if (aLong == LONG_MIN || aLong == LONG_MAX) + return POPT_ERROR_OVERFLOW; + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) { + *((long *) opt->arg) = aLong; + } else { + if (aLong > INT_MAX || aLong < INT_MIN) + return POPT_ERROR_OVERFLOW; + *((int *) opt->arg) =aLong; + } + break; + + default: + fprintf(stdout, POPT_("option type (%d) not implemented in popt\n"), + opt->argInfo & POPT_ARG_MASK); + exit(1); + } + } + } + + if (cb) + cb(con, POPT_CALLBACK_REASON_OPTION, opt, con->os->nextArg, cbData); + else if (opt->val) + done = 1; + + if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) { + con->finalArgvAlloced += 10; + con->finalArgv = realloc(con->finalArgv, + sizeof(*con->finalArgv) * con->finalArgvAlloced); + } + + i = con->finalArgvCount++; + con->finalArgv[i] = + malloc((opt->longName ? strlen(opt->longName) : 0) + 3); + if (opt->longName) + sprintf(con->finalArgv[i], "--%s", opt->longName); + else + sprintf(con->finalArgv[i], "-%c", opt->shortName); + + if (opt->arg && (opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) + con->finalArgv[con->finalArgvCount++] = strdup(con->os->nextArg); + } + + return opt->val; +} + +char * poptGetOptArg(poptContext con) { + char * ret = con->os->nextArg; + con->os->nextArg = NULL; + return ret; +} + +char * poptGetArg(poptContext con) { + if (con->numLeftovers == con->nextLeftover) return NULL; + return (con->leftovers[con->nextLeftover++]); +} + +char * poptPeekArg(poptContext con) { + if (con->numLeftovers == con->nextLeftover) return NULL; + return (con->leftovers[con->nextLeftover]); +} + +char ** poptGetArgs(poptContext con) { + if (con->numLeftovers == con->nextLeftover) return NULL; + + /* some apps like [like RPM ;-) ] need this NULL terminated */ + con->leftovers[con->numLeftovers] = NULL; + + return (con->leftovers + con->nextLeftover); +} + +void poptFreeContext(poptContext con) { + int i; + + for (i = 0; i < con->numAliases; i++) { + if (con->aliases[i].longName) free(con->aliases[i].longName); + free(con->aliases[i].argv); + } + + for (i = 0; i < con->numExecs; i++) { + if (con->execs[i].longName) free(con->execs[i].longName); + free(con->execs[i].script); + } + + for (i = 0; i < con->finalArgvCount; i++) + free(con->finalArgv[i]); + + free(con->leftovers); + free(con->finalArgv); + if (con->appName) free(con->appName); + if (con->aliases) free(con->aliases); + if (con->otherHelp) free(con->otherHelp); + free(con); +} + +int poptAddAlias(poptContext con, struct poptAlias newAlias, int flags) { + int aliasNum = con->numAliases++; + struct poptAlias * alias; + + /* SunOS won't realloc(NULL, ...) */ + if (!con->aliases) + con->aliases = malloc(sizeof(newAlias) * con->numAliases); + else + con->aliases = realloc(con->aliases, + sizeof(newAlias) * con->numAliases); + alias = con->aliases + aliasNum; + + *alias = newAlias; + if (alias->longName) + alias->longName = strcpy(malloc(strlen(alias->longName) + 1), + alias->longName); + else + alias->longName = NULL; + + return 0; +} + +char * poptBadOption(poptContext con, int flags) { + struct optionStackEntry * os; + + if (flags & POPT_BADOPTION_NOALIAS) + os = con->optionStack; + else + os = con->os; + + return os->argv[os->next - 1]; +} + +#define POPT_ERROR_NOARG -10 +#define POPT_ERROR_BADOPT -11 +#define POPT_ERROR_OPTSTOODEEP -13 +#define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */ +#define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */ + +const char * poptStrerror(const int error) { + switch (error) { + case POPT_ERROR_NOARG: + return POPT_("missing argument"); + case POPT_ERROR_BADOPT: + return POPT_("unknown option"); + case POPT_ERROR_OPTSTOODEEP: + return POPT_("aliases nested too deeply"); + case POPT_ERROR_BADQUOTE: + return POPT_("error in paramter quoting"); + case POPT_ERROR_BADNUMBER: + return POPT_("invalid numeric value"); + case POPT_ERROR_OVERFLOW: + return POPT_("number too large or too small"); + case POPT_ERROR_ERRNO: + return strerror(errno); + default: + return POPT_("unknown error"); + } +} + +int poptStuffArgs(poptContext con, char ** argv) { + int i; + + if ((con->os - con->optionStack) == POPT_OPTION_DEPTH) + return POPT_ERROR_OPTSTOODEEP; + + for (i = 0; argv[i]; i++); + + con->os++; + con->os->next = 0; + con->os->nextArg = con->os->nextCharArg = NULL; + con->os->currAlias = NULL; + con->os->argc = i; + con->os->argv = argv; + con->os->stuffed = 1; + + return 0; +} + +const char * poptGetInvocationName(poptContext con) { + return con->os->argv[0]; +} diff --git a/popt-1.2/popt.h b/popt-1.2/popt.h new file mode 100644 index 00000000..9bac7972 --- /dev/null +++ b/popt-1.2/popt.h @@ -0,0 +1,110 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifndef H_POPT +#define H_POPT + +#include /* for FILE * */ + +#define POPT_OPTION_DEPTH 10 + +#define POPT_ARG_NONE 0 +#define POPT_ARG_STRING 1 +#define POPT_ARG_INT 2 +#define POPT_ARG_LONG 3 +#define POPT_ARG_INCLUDE_TABLE 4 /* arg points to table */ +#define POPT_ARG_CALLBACK 5 /* table-wide callback... must be + set first in table; arg points + to callback, descrip points to + callback data to pass */ +#define POPT_ARG_MASK 0x0000FFFF +#define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */ +#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */ +#define POPT_CBFLAG_PRE 0x80000000 /* call the callback before parse */ +#define POPT_CBFLAG_POST 0x40000000 /* call the callback after parse */ +#define POPT_CBFLAG_INC_DATA 0x20000000 /* use data from the include line, + not the subtable */ + +#define POPT_ERROR_NOARG -10 +#define POPT_ERROR_BADOPT -11 +#define POPT_ERROR_OPTSTOODEEP -13 +#define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */ +#define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */ +#define POPT_ERROR_BADNUMBER -17 +#define POPT_ERROR_OVERFLOW -18 + +/* poptBadOption() flags */ +#define POPT_BADOPTION_NOALIAS (1 << 0) /* don't go into an alias */ + +/* poptGetContext() flags */ +#define POPT_CONTEXT_NO_EXEC (1 << 0) /* ignore exec expansions */ +#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /* pay attention to argv[0] */ +#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /* options can't follow args */ + +struct poptOption { + const char * longName; /* may be NULL */ + char shortName; /* may be '\0' */ + int argInfo; + void * arg; /* depends on argInfo */ + int val; /* 0 means don't return, just update flag */ + char * descrip; /* description for autohelp -- may be NULL */ + char * argDescrip; /* argument description for autohelp */ +}; + +struct poptAlias { + char * longName; /* may be NULL */ + char shortName; /* may be '\0' */ + int argc; + char ** argv; /* must be free()able */ +}; + +extern struct poptOption poptHelpOptions[]; +#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \ + 0, "Help options", NULL }, + +typedef struct poptContext_s * poptContext; +#ifndef __cplusplus +typedef struct poptOption * poptOption; +#endif + +enum poptCallbackReason { POPT_CALLBACK_REASON_PRE, + POPT_CALLBACK_REASON_POST, + POPT_CALLBACK_REASON_OPTION }; +typedef void (*poptCallbackType)(poptContext con, + enum poptCallbackReason reason, + const struct poptOption * opt, + const char * arg, void * data); + +poptContext poptGetContext(char * name, int argc, char ** argv, + const struct poptOption * options, int flags); +void poptResetContext(poptContext con); + +/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */ +int poptGetNextOpt(poptContext con); +/* returns NULL if no argument is available */ +char * poptGetOptArg(poptContext con); +/* returns NULL if no more options are available */ +char * poptGetArg(poptContext con); +char * poptPeekArg(poptContext con); +char ** poptGetArgs(poptContext con); +/* returns the option which caused the most recent error */ +char * poptBadOption(poptContext con, int flags); +void poptFreeContext(poptContext con); +int poptStuffArgs(poptContext con, char ** argv); +int poptAddAlias(poptContext con, struct poptAlias alias, int flags); +int poptReadConfigFile(poptContext con, char * fn); +/* like above, but reads /etc/popt and $HOME/.popt along with environment + vars */ +int poptReadDefaultConfig(poptContext con, int useEnv); +/* argv should be freed -- this allows ', ", and \ quoting, but ' is treated + the same as " and both may include \ quotes */ +int poptParseArgvString(char * s, int * argcPtr, char *** argvPtr); +const char * poptStrerror(const int error); +void poptSetExecPath(poptContext con, const char * path, int allowAbsolute); +void poptPrintHelp(poptContext con, FILE * f, int flags); +void poptPrintUsage(poptContext con, FILE * f, int flags); +void poptSetOtherOptionHelp(poptContext con, const char * text); +const char * poptGetInvocationName(poptContext con); + +#endif diff --git a/popt-1.2/popt.spec b/popt-1.2/popt.spec new file mode 100644 index 00000000..adfea95a --- /dev/null +++ b/popt-1.2/popt.spec @@ -0,0 +1,41 @@ +Summary: C library for parsing command line parameters +Name: popt +Version: 1.2 +Release: 1 +Copyright: LGPL +Group: Libraries +Source: ftp://ftp.redhat.com/pub/redhat/code/popt/popt-%{version}.tar.gz +BuildRoot: /var/tmp/popt.root + +%description +Popt is a C library for pasing command line parameters. It was heavily +influenced by the getopt() and getopt_long() functions, but it allows +more powerfull argument expansion. It can parse arbitrary argv[] style +arrays and automatically set variables based on command line arguments. +It also allows command line arguments to be aliased via configuration +files and includes utility functions for parsing arbitrary strings into +argv[] arrays using shell-like rules. + +%prep +%setup -q +CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=/usr + +%build +make + +%install +make DESTDIR=$RPM_BUILD_ROOT install + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%attr(0644, root, root) /usr/lib/libpopt.a +%attr(0644, root, root) /usr/include/popt.h + +%changelog +* Thu Oct 22 1998 Erik Troan +- see CHANGES file for 1.2 + +* Thu Apr 09 1998 Erik Troan +- added ./configure step to spec file diff --git a/popt-1.2/poptconfig.c b/popt-1.2/poptconfig.c new file mode 100644 index 00000000..8f2656d7 --- /dev/null +++ b/popt-1.2/poptconfig.c @@ -0,0 +1,151 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +#if HAVE_ALLOCA_H +# include +#endif + +#include "popt.h" +#include "poptint.h" + +static void configLine(poptContext con, char * line) { + int nameLength = strlen(con->appName); + char * opt; + struct poptAlias alias; + char * entryType; + char * longName = NULL; + char shortName = '\0'; + + if (strncmp(line, con->appName, nameLength)) return; + line += nameLength; + if (!*line || !isspace(*line)) return; + while (*line && isspace(*line)) line++; + entryType = line; + + while (!*line || !isspace(*line)) line++; + *line++ = '\0'; + while (*line && isspace(*line)) line++; + if (!*line) return; + opt = line; + + while (!*line || !isspace(*line)) line++; + *line++ = '\0'; + while (*line && isspace(*line)) line++; + if (!*line) return; + + if (opt[0] == '-' && opt[1] == '-') + longName = opt + 2; + else if (opt[0] == '-' && !opt[2]) + shortName = opt[1]; + + if (!strcmp(entryType, "alias")) { + if (poptParseArgvString(line, &alias.argc, &alias.argv)) return; + alias.longName = longName, alias.shortName = shortName; + poptAddAlias(con, alias, 0); + } else if (!strcmp(entryType, "exec")) { + con->execs = realloc(con->execs, + sizeof(*con->execs) * (con->numExecs + 1)); + if (longName) + con->execs[con->numExecs].longName = strdup(longName); + else + con->execs[con->numExecs].longName = NULL; + + con->execs[con->numExecs].shortName = shortName; + con->execs[con->numExecs].script = strdup(line); + + con->numExecs++; + } +} + +int poptReadConfigFile(poptContext con, char * fn) { + char * file, * chptr, * end; + char * buf, * dst; + int fd, rc; + int fileLength; + + fd = open(fn, O_RDONLY); + if (fd < 0) { + if (errno == ENOENT) + return 0; + else + return POPT_ERROR_ERRNO; + } + + fileLength = lseek(fd, 0, SEEK_END); + lseek(fd, 0, 0); + + file = alloca(fileLength + 1); + if ((fd = read(fd, file, fileLength)) != fileLength) { + rc = errno; + close(fd); + errno = rc; + return POPT_ERROR_ERRNO; + } + close(fd); + + dst = buf = alloca(fileLength + 1); + + chptr = file; + end = (file + fileLength); + while (chptr < end) { + switch (*chptr) { + case '\n': + *dst = '\0'; + dst = buf; + while (*dst && isspace(*dst)) dst++; + if (*dst && *dst != '#') { + configLine(con, dst); + } + chptr++; + break; + case '\\': + *dst++ = *chptr++; + if (chptr < end) { + if (*chptr == '\n') + dst--, chptr++; + /* \ at the end of a line does not insert a \n */ + else + *dst++ = *chptr++; + } + break; + default: + *dst++ = *chptr++; + } + } + + return 0; +} + +int poptReadDefaultConfig(poptContext con, int useEnv) { + char * fn, * home; + int rc; + + if (!con->appName) return 0; + + rc = poptReadConfigFile(con, "/etc/popt"); + if (rc) return rc; + if (getuid() != geteuid()) return 0; + + if ((home = getenv("HOME"))) { + fn = alloca(strlen(home) + 20); + strcpy(fn, home); + strcat(fn, "/.popt"); + rc = poptReadConfigFile(con, fn); + if (rc) return rc; + } + + return 0; +} + diff --git a/popt-1.2/popthelp.c b/popt-1.2/popthelp.c new file mode 100644 index 00000000..021e0445 --- /dev/null +++ b/popt-1.2/popthelp.c @@ -0,0 +1,268 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "popt.h" +#include "poptint.h" + +static void displayArgs(poptContext con, enum poptCallbackReason foo, + struct poptOption * key, + const char * arg, void * data) { + if (key->shortName== '?') + poptPrintHelp(con, stderr, 0); + else + poptPrintUsage(con, stderr, 0); + exit(0); +} + +struct poptOption poptHelpOptions[] = { + { NULL, '\0', POPT_ARG_CALLBACK, &displayArgs, '\0', NULL }, + { "help", '?', 0, NULL, '?', N_("Show this help message") }, + { "usage", '\0', 0, NULL, 'u', N_("Display brief usage message") }, + { NULL, '\0', 0, NULL, 0 } +} ; + +static const char * getArgDescrip(const struct poptOption * opt) { + if (!(opt->argInfo & POPT_ARG_MASK)) return NULL; + + if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2)) + if (opt->argDescrip) return POPT_(opt->argDescrip); + + if (opt->argDescrip) return _(opt->argDescrip); + return POPT_("ARG"); +} + +static void singleOptionHelp(FILE * f, int maxLeftCol, + const struct poptOption * opt) { + int indentLength = maxLeftCol + 5; + int lineLength = 79 - indentLength; + const char * help = _(opt->descrip); + int helpLength; + const char * ch; + char format[10]; + char * left = alloca(maxLeftCol + 1); + const char * argDescrip = getArgDescrip(opt); + + *left = '\0'; + if (opt->longName && opt->shortName) + sprintf(left, "-%c, --%s", opt->shortName, opt->longName); + else if (opt->shortName) + sprintf(left, "-%c", opt->shortName); + else if (opt->longName) + sprintf(left, "--%s", opt->longName); + if (!*left) return ; + if (argDescrip) { + strcat(left, "="); + strcat(left, argDescrip); + } + + if (help) + fprintf(f," %-*s ", maxLeftCol, left); + else { + fprintf(f," %s\n", left); + return; + } + + helpLength = strlen(help); + while (helpLength > lineLength) { + ch = help + lineLength - 1; + while (ch > help && !isspace(*ch)) ch--; + if (ch == help) break; /* give up */ + while (ch > (help + 1) && isspace(*ch)) ch--; + ch++; + + sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength); + fprintf(f, format, help, " "); + help = ch; + while (isspace(*help) && *help) help++; + helpLength = strlen(help); + } + + if (helpLength) fprintf(f, "%s\n", help); +} + +static int maxArgWidth(const struct poptOption * opt) { + int max = 0; + int this; + const char * s; + + while (opt->longName || opt->shortName || opt->arg) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + this = maxArgWidth(opt->arg); + if (this > max) max = this; + } else if (!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) { + this = opt->shortName ? 2 : 0; + if (opt->longName) { + if (this) this += 2; + this += strlen(opt->longName) + 2; + } + + s = getArgDescrip(opt); + if (s) + this += strlen(s) + 1; + if (this > max) max = this; + } + + opt++; + } + + return max; +} + +static void singleTableHelp(FILE * f, const struct poptOption * table, + int left) { + const struct poptOption * opt; + + opt = table; + while (opt->longName || opt->shortName || opt->arg) { + if ((opt->longName || opt->shortName) && + !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) + singleOptionHelp(f, left, opt); + opt++; + } + + opt = table; + while (opt->longName || opt->shortName || opt->arg) { + if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { + if (opt->descrip) + fprintf(f, "\n%s\n", _(opt->descrip)); + singleTableHelp(f, opt->arg, left); + } + opt++; + } +} + +static int showHelpIntro(poptContext con, FILE * f) { + int len = 6; + char * fn; + + fprintf(f, POPT_("Usage:")); + if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) { + fn = con->optionStack->argv[0]; + if (strchr(fn, '/')) fn = strchr(fn, '/') + 1; + fprintf(f, " %s", fn); + len += strlen(fn) + 1; + } + + return len; +} + +void poptPrintHelp(poptContext con, FILE * f, int flags) { + int leftColWidth; + + showHelpIntro(con, f); + if (con->otherHelp) + fprintf(f, " %s\n", con->otherHelp); + else + fprintf(f, " %s\n", POPT_("[OPTION...]")); + + leftColWidth = maxArgWidth(con->options); + singleTableHelp(f, con->options, leftColWidth); +} + +static int singleOptionUsage(FILE * f, int cursor, + const struct poptOption * opt) { + int len = 3; + char shortStr[2]; + const char * item = shortStr; + const char * argDescrip = getArgDescrip(opt); + + if (opt->shortName) { + if (!(opt->argInfo & POPT_ARG_MASK)) + return cursor; /* we did these already */ + len++; + *shortStr = opt->shortName; + shortStr[1] = '\0'; + } else if (opt->longName) { + len += 1 + strlen(opt->longName); + item = opt->longName; + } + + if (len == 3) return cursor; + + if (argDescrip) + len += strlen(argDescrip) + 1; + + if ((cursor + len) > 79) { + fprintf(f, "\n "); + cursor = 7; + } + + fprintf(f, " [-%s%s%s%s]", opt->shortName ? "" : "-", item, + argDescrip ? (opt->shortName ? " " : "=") : "", + argDescrip ? argDescrip : ""); + + return cursor + len + 1; +} + +int singleTableUsage(FILE * f, int cursor, const struct poptOption * table) { + const struct poptOption * opt; + + opt = table; + while (opt->longName || opt->shortName || opt->arg) { + if ((opt->longName || opt->shortName) && + !(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) + cursor = singleOptionUsage(f, cursor, opt); + else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) + cursor = singleTableUsage(f, cursor, opt->arg); + opt++; + } + + return cursor; +} + +static int showShortOptions(const struct poptOption * opt, FILE * f, + char * str) { + char s[300]; /* this is larger then the ascii set, so + it should do just fine */ + + if (!str) { + str = s; + memset(str, 0, sizeof(str)); + } + + while (opt->longName || opt->shortName || opt->arg) { + if (opt->shortName && !(opt->argInfo & POPT_ARG_MASK)) + str[strlen(str)] = opt->shortName; + else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) + showShortOptions(opt->arg, f, str); + + opt++; + } + + if (s != str || !*s) + return 0; + + fprintf(f, " [-%s]", s); + return strlen(s) + 4; +} + +void poptPrintUsage(poptContext con, FILE * f, int flags) { + int cursor; + + cursor = showHelpIntro(con, f); + cursor += showShortOptions(con->options, f, NULL); + singleTableUsage(f, cursor, con->options); + + if (con->otherHelp) { + cursor += strlen(con->otherHelp) + 1; + if (cursor > 79) fprintf(f, "\n "); + fprintf(f, " %s", con->otherHelp); + } + + fprintf(f, "\n"); +} + +void poptSetOtherOptionHelp(poptContext con, const char * text) { + if (con->otherHelp) free(con->otherHelp); + con->otherHelp = strdup(text); +} diff --git a/popt-1.2/poptint.h b/popt-1.2/poptint.h new file mode 100644 index 00000000..5d99be57 --- /dev/null +++ b/popt-1.2/poptint.h @@ -0,0 +1,64 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifndef H_POPTINT +#define H_POPTINT + +struct optionStackEntry { + int argc; + char ** argv; + int next; + char * nextArg; + char * nextCharArg; + struct poptAlias * currAlias; + int stuffed; +}; + +struct execEntry { + char * longName; + char shortName; + char * script; +}; + +struct poptContext_s { + struct optionStackEntry optionStack[POPT_OPTION_DEPTH], * os; + char ** leftovers; + int numLeftovers; + int nextLeftover; + const struct poptOption * options; + int restLeftover; + char * appName; + struct poptAlias * aliases; + int numAliases; + int flags; + struct execEntry * execs; + int numExecs; + char ** finalArgv; + int finalArgvCount; + int finalArgvAlloced; + struct execEntry * doExec; + char * execPath; + int execAbsolute; + char * otherHelp; +}; + +#ifdef HAVE_LIBINTL_H +#include +#endif + +#ifdef HAVE_GETTEXT +#define _(foo) gettext(foo) +#else +#define _(foo) (foo) +#endif + +#ifdef HAVE_DGETTEXT +#define POPT_(foo) dgettext("popt", foo) +#else +#define POPT_(foo) (foo) +#endif + +#define N_(foo) (foo) + +#endif diff --git a/popt-1.2/poptparse.c b/popt-1.2/poptparse.c new file mode 100644 index 00000000..cd97ec6e --- /dev/null +++ b/popt-1.2/poptparse.c @@ -0,0 +1,93 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "popt.h" + +int poptParseArgvString(char * s, int * argcPtr, char *** argvPtr) { + char * buf = strcpy(alloca(strlen(s) + 1), s); + char * bufStart = buf; + char * src, * dst; + char quote = '\0'; + int argvAlloced = 5; + char ** argv = malloc(sizeof(*argv) * argvAlloced); + char ** argv2; + int argc = 0; + int i; + + src = s; + dst = buf; + argv[argc] = buf; + + memset(buf, '\0', strlen(s) + 1); + + while (*src) { + if (quote == *src) { + quote = '\0'; + } else if (quote) { + if (*src == '\\') { + src++; + if (!*src) { + free(argv); + return POPT_ERROR_BADQUOTE; + } + if (*src != quote) *buf++ = '\\'; + } + *buf++ = *src; + } else if (isspace(*src)) { + if (*argv[argc]) { + buf++, argc++; + if (argc == argvAlloced) { + argvAlloced += 5; + argv = realloc(argv, sizeof(*argv) * argvAlloced); + } + argv[argc] = buf; + } + } else switch (*src) { + case '"': + case '\'': + quote = *src; + break; + case '\\': + src++; + if (!*src) { + free(argv); + return POPT_ERROR_BADQUOTE; + } + /* fallthrough */ + default: + *buf++ = *src; + } + + src++; + } + + if (strlen(argv[argc])) { + argc++, buf++; + } + + dst = malloc(argc * sizeof(*argv) + (buf - bufStart)); + argv2 = (void *) dst; + dst += argc * sizeof(*argv); + memcpy(argv2, argv, argc * sizeof(*argv)); + memcpy(dst, bufStart, buf - bufStart); + + for (i = 0; i < argc; i++) { + argv2[i] = dst + (argv[i] - bufStart); + } + + free(argv); + + *argvPtr = argv2; + *argcPtr = argc; + + return 0; +} diff --git a/popt-1.2/stamp-h.in b/popt-1.2/stamp-h.in new file mode 100644 index 00000000..e69de29b diff --git a/popt-1.2/test-poptrc b/popt-1.2/test-poptrc new file mode 100644 index 00000000..8a6d86cb --- /dev/null +++ b/popt-1.2/test-poptrc @@ -0,0 +1,9 @@ +test1 alias --simple --arg2 +test1 alias --two --arg1 --arg2 alias +test1 alias --takerest -- +test1 alias -T --arg2 +test1 alias -O --arg1 + +test1 exec --echo-args echo +test1 alias -e --echo-args +test1 exec -a /bin/echo diff --git a/popt-1.2/test1.c b/popt-1.2/test1.c new file mode 100644 index 00000000..28ee2692 --- /dev/null +++ b/popt-1.2/test1.c @@ -0,0 +1,101 @@ +/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING + file accompanying popt source distributions, available from + ftp://ftp.redhat.com/pub/code/popt */ + +#include +#include + +#include "popt.h" + +void option_callback(poptContext con, enum poptCallbackReason reason, + const struct poptOption * opt, + char * arg, void * data) { + fprintf(stdout, "callback: %c %s %s ", opt->val, (char *) data, arg); +} + +int main(int argc, char ** argv) { + int rc; + int arg1 = 0; + char * arg2 = "(none)"; + poptContext optCon; + char ** rest; + int arg3 = 0; + int inc = 0; + int help = 0; + int usage = 0; + int shortopt = 0; + struct poptOption moreCallbackArgs[] = { + { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA, + option_callback, 0, NULL }, + { "cb2", 'c', POPT_ARG_STRING, NULL, 'c', "Test argument callbacks" }, + { NULL, '\0', 0, NULL, 0 } + }; + struct poptOption callbackArgs[] = { + { NULL, '\0', POPT_ARG_CALLBACK, option_callback, 0, "sampledata" }, + { "cb", 'c', POPT_ARG_STRING, NULL, 'c', "Test argument callbacks" }, + { "long", '\0', 0, NULL, 'l', "Unused option for help testing" }, + { NULL, '\0', 0, NULL, 0 } + }; + struct poptOption moreArgs[] = { + { "inc", 'i', 0, &inc, 0, "An included argument" }, + { NULL, '\0', 0, NULL, 0 } + }; + struct poptOption options[] = { + { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &moreCallbackArgs, 0, "arg for cb2" }, + { "arg1", '\0', 0, &arg1, 0, "First argument with a really long" + " description. After all, we have to test argument help" + " wrapping somehow, right?", NULL }, + { "arg2", '2', POPT_ARG_STRING, &arg2, 0, "Another argument", "ARG" }, + { "arg3", '3', POPT_ARG_INT, &arg3, 0, "A third argument", "ANARG" }, + { "shortoption", '\0', POPT_ARGFLAG_ONEDASH, &shortopt, 0, + "Needs a single -", NULL }, + { "hidden", '\0', POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN, NULL, 0, + "This shouldn't show up", NULL }, + { "unused", '\0', POPT_ARG_STRING, NULL, 0, + "Unused option for help testing", "UNUSED" }, + { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &moreArgs, 0, NULL }, + { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &callbackArgs, 0, "Callback arguments" }, + POPT_AUTOHELP + { NULL, '\0', 0, NULL, 0 } + }; + + optCon = poptGetContext("test1", argc, argv, options, 0); + poptReadConfigFile(optCon, "./test-poptrc"); + + if ((rc = poptGetNextOpt(optCon)) < -1) { + fprintf(stderr, "test1: bad argument %s: %s\n", + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); + return 2; + } + + if (help) { + poptPrintHelp(optCon, stdout, 0); + return 0; + } if (usage) { + poptPrintUsage(optCon, stdout, 0); + return 0; + } + + fprintf(stdout, "arg1: %d arg2: %s", arg1, arg2); + + if (arg3) + fprintf(stdout, " arg3: %d", arg3); + if (inc) + fprintf(stdout, " inc: %d", inc); + if (shortopt) + fprintf(stdout, " short: %d", shortopt); + + rest = poptGetArgs(optCon); + if (rest) { + fprintf(stdout, " rest:"); + while (*rest) { + fprintf(stdout, " %s", *rest); + rest++; + } + } + + fprintf(stdout, "\n"); + + return 0; +} diff --git a/popt-1.2/testit.sh b/popt-1.2/testit.sh new file mode 100755 index 00000000..bdb78ab1 --- /dev/null +++ b/popt-1.2/testit.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +run() { + prog=$1; shift + name=$1; shift + answer=$1; shift + + echo Running test $name. + + result=`./$prog $*` + if [ "$answer" != "$result" ]; then + echo "Test \"$*\" failed with: $result" + exit 2 + fi +} + +make -q testcases + +run test1 "test1 - 1" "arg1: 1 arg2: (none)" --arg1 +run test1 "test1 - 2" "arg1: 0 arg2: foo" --arg2 foo +run test1 "test1 - 3" "arg1: 1 arg2: something" --arg1 --arg2 something +run test1 "test1 - 4" "arg1: 0 arg2: another" --simple another +run test1 "test1 - 5" "arg1: 1 arg2: alias" --two +run test1 "test1 - 6" "arg1: 1 arg2: (none) rest: --arg2" --arg1 -- --arg2 +run test1 "test1 - 7" "arg1: 0 arg2: abcd rest: --arg1" --simple abcd -- --arg1 +run test1 "test1 - 8" "arg1: 1 arg2: (none) rest: --arg2" --arg1 --takerest --arg2 +run test1 "test1 - 9" "arg1: 0 arg2: foo" -2 foo +run test1 "test1 - 10" "arg1: 0 arg2: (none) arg3: 50" -3 50 +run test1 "test1 - 11" "arg1: 0 arg2: bar" -T bar +run test1 "test1 - 12" "arg1: 1 arg2: (none)" -O +run test1 "test1 - 13" "arg1: 1 arg2: foo" -OT foo +run test1 "test1 - 14" "arg1: 0 arg2: (none) inc: 1" --inc +run test1 "test1 - 15" "arg1: 0 arg2: foo inc: 1" -i --arg2 foo +POSIX_ME_HARDER=1 run test1 "test1 - 16" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something +POSIXLY_CORRECT=1 run test1 "test1 - 17" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something +run test1 "test1 - 18" "callback: c sampledata bar arg1: 1 arg2: (none)" --arg1 --cb bar +run test1 "test1 - 19" "./test1 ;" --echo-args +run test1 "test1 - 20" "./test1 ; --arg1" --echo-args --arg1 +run test1 "test1 - 21" "./test1 ; --arg2 something" -T something -e +run test1 "test1 - 22" "./test1 ; --arg2 something -- more args" -T something -a more args +run test1 "test1 - 23" "./test1 ; --echo-args -a" --echo-args -e -a +run test1 "test1 - 24" "arg1: 0 arg2: (none) short: 1" -shortoption +run test1 "test1 - 25" "arg1: 0 arg2: (none) short: 1" --shortoption +run test1 "test1 - 26" "callback: c arg for cb2 foo arg1: 0 arg2: (none)" --cb2 foo + +echo "" +echo "Passed." -- 2.34.1