build: fix usage of sed and drop build-aux/genman

"sed -i" is a GNU specific extention.

Replace with more portable version and drop completely genman
in favour of a make rule.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
Fabio M. Di Nitto 2012-08-27 16:56:57 +02:00
parent 9240c8d565
commit 3a64fc4382
4 changed files with 13 additions and 62 deletions

View File

@ -37,7 +37,6 @@ EXTRA_DIST = autogen.sh $(SPEC).in \
build-aux/git-version-gen \
build-aux/gitlog-to-changelog \
build-aux/release.mk \
build-aux/genman \
.version
AUTOMAKE_OPTIONS = foreign

View File

@ -1,52 +0,0 @@
#!/bin/bash
set -e
# Set variables
# in - input man page (something_foo.3.in)
# out - output file (something_foo.3)
# common - common ipc error file
in="$1"
out="$2"
common="$3"
# make sure to trap on error and ctrl+c
# so we can cleanup our temporary files
# and provide error back to Makefile
cleanup() {
rm -f "$out"-t "$out"
}
trap "cleanup" ABRT
trap "cleanup" QUIT
trap "cleanup" TERM
trap "cleanup" INT
trap "cleanup" ERR
# Determine build date in man page format YYYY-MM-DD
date="$(LC_ALL=C date "+%F")"
# do the hack.. it looks ugly but it works fine
# remove temporary file
rm -f "$out"-t
# insert the $common ipc error file in the man page
if grep -q @COMMONIPCERRORS@ "$in"; then
awk "{print}(\$1 ~ /@COMMONIPCERRORS@/){exit 0}" "$in" > "$out"-t
cat "$common" >> "$out"-t
awk -v p=0 "(\$1 ~ /@COMMONIPCERRORS@/){p = 1} {if(p==1)print}" "$in" >> "$out"-t
else
cp "$in" "$out"-t
fi
# substitute BUILDDATE with precalculated date
# and remove COMMONIPCERRORS tag from above
sed -i \
-e 's#@BUILDDATE@#'$date'#g' \
-e 's#@COMMONIPCERRORS@##g' \
"$out"-t
# move in place as requested
mv "$out"-t "$out"

View File

@ -47,14 +47,13 @@ initscript_SCRIPTS = corosync corosync-notifyd
%: %.in Makefile
rm -f $@-t $@
cp $< $@-t
sed -i \
cat $< | sed \
-e 's#@''SBINDIR@#$(sbindir)#g' \
-e 's#@''SYSCONFDIR@#$(sysconfdir)#g' \
-e 's#@''INITDDIR@#$(INITDDIR)#g' \
-e 's#@''INITWRAPPERSDIR@#$(INITWRAPPERSDIR)#g' \
-e 's#@''LOCALSTATEDIR@#$(localstatedir)#g' \
$@-t
> $@-t
mv $@-t $@
all-local: $(initscript_SCRIPTS) $(systemdconf_DATA)

View File

@ -140,13 +140,18 @@ endif
HTML_DOCS = $(dist_man_MANS:%=%.html) $(man_MANS:%=%.html)
# developer man page generation
%.3: %.3.in $(autogen_common) $(top_srcdir)/build-aux/genman
%.3: %.3.in $(autogen_common)
@echo Generating $@ man page && \
rm -f $@-t $@ && \
$(top_srcdir)/build-aux/genman \
$(srcdir)/$@.in \
$(builddir)/$@-t \
$(srcdir)/$(autogen_common) && \
rm -f $@-t-t $@-t $@ && \
date="$$(LC_ALL=C date "+%F")" && \
awk "{print}(\$$1 ~ /@COMMONIPCERRORS@/){exit 0}" $@.in > $@-t-t && \
cat $(autogen_common) >> $@-t-t && \
awk -v p=0 "(\$$1 ~ /@COMMONIPCERRORS@/){p = 1} {if(p==1)print}" $@.in >> $@-t-t && \
cat $@-t-t | \
sed -e 's#@BUILDDATE@#'$$date'#g' \
-e 's#@COMMONIPCERRORS@##g' \
> $@-t && \
rm -f $@-t-t && \
mv $@-t $@
clean-local: