summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-08-16 23:04:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-08-16 23:04:25 +0000
commite787f86b365b1779d9ea4b2c1b4b35617a18d0ba (patch)
tree99794137b11a26bbda78403db11f7d76c5634afb
parent793fa839780278ce837bbf49d61586b868ac4eb4 (diff)
downloadmandoc-e787f86b365b1779d9ea4b2c1b4b35617a18d0ba.tar.gz
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.
-rw-r--r--Makefile18
-rw-r--r--apropos.c2
-rwxr-xr-xconfigure4
-rw-r--r--main.c10
4 files changed, 23 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index abf29fff..0a699c62 100644
--- a/Makefile
+++ b/Makefile
@@ -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 e76760b6..66a83733 100644
--- a/apropos.c
+++ b/apropos.c
@@ -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 fe520ad2..de1f33f4 100644
--- a/main.c
+++ b/main.c
@@ -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;