Skip to content
This repository
tree: 5aa653ce19
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 76 lines (58 sloc) 1.92 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
.PHONY: all clean help view

# --
# build the list of target binaries to be documented:
# bin/* and lib/opa/bin/* together with inclusions and exclusions
# --
BLDDIR ?= ../../_build
OCAMLBUILD ?= bld

BINDIR=$(BLDDIR)/bin
EXCLUDE=opa-bin mlstate_platform genproto ocamlbase.top ppdebug-opa ppjs
INCLUDE=opa
BINS=$(INCLUDE) $(filter-out $(EXCLUDE), $(notdir $(wildcard $(BLDDIR)/bin/* $(BLDDIR)/lib/opa/bin/*)))

TARGETDIR=$(BLDDIR)/man/man1
TARGETS=$(addprefix $(TARGETDIR)/, $(addsuffix .1, $(BINS)))

all: $(TARGETS)

# for debugging
help: $(TARGETS:.1=.help)

clean:
rm -f $(TARGETS) $(TARGETS:.1=.help)

view: $(TARGETS)
man $(TARGETS)

# --
# first check if a manpage has been written by hand
# --
$(TARGETDIR)/%.1: %.man
@mkdir -p $(TARGETDIR)
cp $< $@
gzip -f --best $@

# --
# second run specific manpage generation programs
# --
$(BLDDIR)/compiler/opa/gen_opa_manpage.native: ../../compiler/opa/gen_opa_manpage.ml
cd ../..; $(OCAMLBUILD) compiler/opa/gen_opa_manpage.native

$(TARGETDIR)/opa.1: $(BLDDIR)/compiler/opa/gen_opa_manpage.native
@mkdir -p $(TARGETDIR)
$< > $@
gzip -f --best $@

$(BLDDIR)/compiler/opatop/gen_opatop_manpage.native: ../../compiler/opatop/gen_opatop_manpage.ml
cd ../..; $(OCAMLBUILD) compiler/opatop/gen_opatop_manpage.native

$(TARGETDIR)/opatop.1: $(BLDDIR)/compiler/opatop/gen_opatop_manpage.native
@mkdir -p $(TARGETDIR)
$< > $@
gzip -f --best $@

# --
# third run our hackish conversion tool help->manpage
# --
GENMAN=$(BLDDIR)/tools/manpages/genman.native

$(GENMAN): genman.ml
cd ../..; $(OCAMLBUILD) -cflags "-w -14" tools/manpages/genman.native

$(TARGETDIR)/%.help: $(BLDDIR)/bin/%
@mkdir -p $(TARGETDIR)
$< --help >$@ 2>&1 ||true

$(TARGETDIR)/%.help: $(BLDDIR)/lib/opa/bin/%
@mkdir -p $(TARGETDIR)
$< --help >$@ 2>&1 ||true

$(TARGETDIR)/%.1: $(TARGETDIR)/%.help $(GENMAN)
@mkdir -p $(TARGETDIR)
$(GENMAN) $* $(TARGETDIR)/$* > $@
gzip -f --best $@
Something went wrong with that request. Please try again.