From 7d593fa69b20a5bf1d8d8b1280a0aacd5296026c Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 16 Aug 2014 23:04:25 +0000 Subject: When BUILD_DB is active, link apropos(1) into the mandoc binary. This is the first step on the way to a man(1) implementation. The new ./configure is flexible enough to make this step quite easy. --- Makefile | 20 +++++++++----------- apropos.c | 4 ++-- configure | 4 ++++ main.c | 12 +++++++++++- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 21f5232f..7d162948 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.440 2014/08/16 19:00:01 schwarze Exp $ +# $Id: Makefile,v 1.441 2014/08/16 23:04:25 schwarze Exp $ # # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons # Copyright (c) 2011, 2013, 2014 Ingo Schwarze @@ -16,7 +16,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. BASEBIN = mandoc preconv demandoc -DBBIN = apropos makewhatis +DBBIN = makewhatis CGIBIN = man.cgi TESTSRCS = test-dirent-namlen.c \ @@ -222,6 +222,8 @@ MANDOC_OBJS = $(MANDOC_HTML_OBJS) \ out.o \ tree.o +MAN_OBJS = $(MANDOC_OBJS) + MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o PRECONV_OBJS = preconv.o @@ -295,13 +297,12 @@ distclean: clean clean: rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS) - rm -f apropos $(APROPOS_OBJS) + rm -f mandoc $(MANDOC_OBJS) $(APROPOS_OBJS) rm -f makewhatis $(MAKEWHATIS_OBJS) rm -f preconv $(PRECONV_OBJS) rm -f man.cgi $(CGI_OBJS) rm -f manpage $(MANPAGE_OBJS) rm -f demandoc $(DEMANDOC_OBJS) - rm -f mandoc $(MANDOC_OBJS) rm -f $(WWW_MANS) $(WWW_OBJS) rm -rf *.dSYM @@ -331,8 +332,8 @@ db-install: db-build mkdir -p $(DESTDIR)$(MANDIR)/man3 mkdir -p $(DESTDIR)$(MANDIR)/man5 mkdir -p $(DESTDIR)$(MANDIR)/man8 - $(INSTALL_PROGRAM) apropos $(DESTDIR)$(BINDIR) - ln -f $(DESTDIR)$(BINDIR)/apropos $(DESTDIR)$(BINDIR)/whatis + ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/apropos + ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/whatis $(INSTALL_PROGRAM) makewhatis $(DESTDIR)$(SBINDIR) $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1 ln -f $(DESTDIR)$(MANDIR)/man1/apropos.1 \ @@ -374,8 +375,8 @@ depend: config.h libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS) $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS) -mandoc: $(MANDOC_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a +mandoc: $(MAN_OBJS) libmandoc.a + $(CC) $(LDFLAGS) -o $@ $(MAN_OBJS) libmandoc.a $(DBLIB) makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB) @@ -386,9 +387,6 @@ preconv: $(PRECONV_OBJS) manpage: $(MANPAGE_OBJS) libmandoc.a $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB) -apropos: $(APROPOS_OBJS) libmandoc.a - $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB) - man.cgi: $(CGI_OBJS) libmandoc.a $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB) diff --git a/apropos.c b/apropos.c index 0aa988be..505bce88 100644 --- a/apropos.c +++ b/apropos.c @@ -1,4 +1,4 @@ -/* $Id: apropos.c,v 1.40 2014/08/10 23:54:41 schwarze Exp $ */ +/* $Id: apropos.c,v 1.41 2014/08/16 23:04:25 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013 Ingo Schwarze @@ -33,7 +33,7 @@ int -main(int argc, char *argv[]) +apropos(int argc, char *argv[]) { int ch, whatis; struct mansearch search; diff --git a/configure b/configure index 6f521237..eb9311e3 100755 --- a/configure +++ b/configure @@ -280,6 +280,7 @@ cat << __HEREDOC__ #define HAVE_STRPTIME ${HAVE_STRPTIME} #define HAVE_STRSEP ${HAVE_STRSEP} #define HAVE_WCHAR ${HAVE_WCHAR} +#define HAVE_SQLITE3 ${HAVE_SQLITE3} #define HAVE_SQLITE3_ERRSTR ${HAVE_SQLITE3_ERRSTR} #define HAVE_OHASH ${HAVE_OHASH} #define HAVE_MANPATH ${HAVE_MANPATH} @@ -385,6 +386,9 @@ INSTALL_MAN = ${INSTALL_MAN} INSTALL_DATA = ${INSTALL_DATA} __HEREDOC__ +[ ${BUILD_DB} -gt 0 ] && \ + echo "MAN_OBJS = \$(MANDOC_OBJS) \$(APROPOS_OBJS)" + echo "Makefile.local: written" 1>&2 echo "Makefile.local: written" 1>&3 diff --git a/main.c b/main.c index 32ed232c..623c9810 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.178 2014/08/10 23:54:41 schwarze Exp $ */ +/* $Id: main.c,v 1.179 2014/08/16 23:04:25 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze @@ -68,6 +68,10 @@ struct curparse { char outopts[BUFSIZ]; /* buf of output opts */ }; +#if HAVE_SQLITE3 +int apropos(int, char**); +#endif + static int moptions(int *, char *); static void mmsg(enum mandocerr, enum mandoclevel, const char *, int, int, const char *); @@ -96,6 +100,12 @@ main(int argc, char *argv[]) else ++progname; +#if HAVE_SQLITE3 + if (0 == strncmp(progname, "apropos", 7) || + 0 == strncmp(progname, "whatis", 6)) + return(apropos(argc, argv)); +#endif + memset(&curp, 0, sizeof(struct curparse)); options = MPARSE_SO; -- cgit v1.2.3-56-ge451