automake: xpp: man-pages and perl-scripts
authorOron Peled <oron.peled@xorcom.com>
Mon, 18 May 2015 15:25:03 +0000 (15:25 +0000)
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>
Tue, 19 May 2015 16:52:15 +0000 (19:52 +0300)
* Now man-pages and perl-script are handled by xpp/Makefile.am
* Removed from xpp/Makefile.legacy
* Detect perl and set perllibdir in configure.ac
* Handle modules in their own xpp/perl_modules/Makefile.am
* Enclose perl-related stuff in conditional
* Updates for "make dist"

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

.gitignore
build_tools/make_dist
configure.ac
xpp/Makefile.am
xpp/Makefile.legacy
xpp/perl_modules/Makefile.am [new file with mode: 0644]

index 1249c51..87d854e 100644 (file)
@@ -51,6 +51,7 @@ timertest
 tonezone.lo
 tonezones.txt
 version.c
+xpp/*.check
 xpp/.depend
 xpp/.octasic.depend
 xpp/.perlcheck
index 8261c24..e1e580c 100755 (executable)
@@ -28,10 +28,12 @@ extra_dist='
        Makefile
        xpp/Makefile
        xpp/oct612x/Makefile
+       xpp/perl_modules/Makefile
        ppp/Makefile.in
        Makefile.in
        xpp/Makefile.in
        xpp/oct612x/Makefile.in
+       xpp/perl_modules/Makefile.in
        auxdir/compile
        auxdir/config.guess
        auxdir/config.sub
index cc935dd..1557888 100644 (file)
@@ -86,6 +86,16 @@ AC_SUBST(DOWNLOAD)
 
 AC_LANG(C)
 
+AC_PATH_PROG([PERL], [perl])
+if test "$PERL" = ''; then
+             AC_MSG_ERROR(perl is mandatory)
+fi
+AC_MSG_CHECKING(for perl libdir)
+eval `"$PERL" -V:sitelib`
+AC_SUBST([perllibdir], [`echo "$sitelib"`])
+AC_MSG_RESULT([$perllibdir])
+AM_CONDITIONAL([PERL], [test "$perllibdir" != ''])
+
 AC_ARG_ENABLE(dev-mode,
        [  --enable-dev-mode    Turn on developer mode],
        [case "${enableval}" in
@@ -247,6 +257,7 @@ AC_CONFIG_FILES([
        ppp/Makefile
        xpp/Makefile
        xpp/oct612x/Makefile
+       xpp/perl_modules/Makefile
        ])
 AC_OUTPUT
 
index c456fad..7d060d5 100644 (file)
@@ -4,7 +4,7 @@ LEGACY_MAKE     = \
                top_srcdir=$(top_srcdir) \
                srcdir=$(srcdir)
 
-all-local:
+all-local: $(perl_checks)
        $(LEGACY_MAKE)  all
 
 clean-local:
@@ -21,6 +21,44 @@ SUBDIRS              =
 
 GLOBAL_CFLAGS  = -I$(srcdir) -I$(srcdir)/xtalk
 
+if PERL
+SUBDIRS                += perl_modules
+
+%.8: %
+       @if file "$^" | cut -d: -f2 | grep -q perl; then \
+               if pod2man --section 8 $^ > $@; then \
+                       echo "  GEN      $@"; \
+               else \
+                       rm -f "$@"; \
+               fi \
+       fi
+
+%.check: %
+       @echo "  CHECK    $^"; \
+       if ! perl -I./perl_modules -c $^ 2>/dev/null; then \
+               perl -I./perl_modules -c $^; \
+       fi
+       @touch $@
+
+perl_scripts   =       \
+               dahdi_registration      \
+               xpp_sync        \
+               lsdahdi         \
+               xpp_blink       \
+               dahdi_genconf   \
+               dahdi_hardware  \
+               twinstar        \
+               #
+
+perl_checks    = $(perl_scripts:%=%.check)
+perl_mans      = $(perl_scripts:%=%.8)
+
+endif
+
+dist_sbin_SCRIPTS      = $(perl_scripts)
+man_MANS               = $(perl_mans)
+CLEANFILES             = $(perl_checks) $(perl_mans)
+
 if     PBX_USB
 
 SUBDIRS                += oct612x
@@ -65,9 +103,11 @@ astribank_allow_CFLAGS              = $(GLOBAL_CFLAGS)
 astribank_allow_LDFLAGS                = $(USB_LIB)
 astribank_allow_LDADD          = libastribank.la
 
-man_MANS       = \
+man_pages      = \
                astribank_tool.8 \
                astribank_hexload.8 \
                astribank_allow.8 \
                astribank_is_starting.8
+
+man_MANS       += $(man_pages)
 endif
index 9f37f0b..3d49b09 100644 (file)
@@ -19,75 +19,25 @@ INSTALL_DATA        = $(INSTALL) -m 644
 # In 1.4 those are provided by autoconf through makeopts
 prefix         ?= /usr
 datadir                ?= $(prefix)/share
-mandir         ?= $(datadir)/man
 sysconfdir     ?= $(prefix)/etc
 udevrulesdir   ?= $(sysconfdir)/udev/rules.d
 INSTALL                ?= install
 
 INSTALL_DATA   = $(INSTALL) -m 644
 
-SBINDIR                = $(prefix)/sbin
 DATADIR                = $(datadir)/dahdi
-MANDIR         = $(mandir)/man8
-PERLLIBDIR     := $(shell eval `perl -V:sitelib`; echo "$$sitelib")
-PERL_DIRS      := $(shell cd perl_modules; find * -name '[A-Z]*' -type d| xargs)
-PERL_MODS_PAT  := *.pm $(PERL_DIRS:%=%/*.pm)
-PERL_MODS      := $(shell cd perl_modules; echo $(PERL_MODS_PAT))
 
 # Variables that should be defined above, but need sane defaults:
 # FIXME: Are those values really sane?
 HOSTCC         ?= $(CC)
 
-%.8: %
-       pod2man --section 8 $^ > $@ || $(RM) $@
-PERL_SCRIPTS   =       \
-               dahdi_registration      \
-               xpp_sync        \
-               lsdahdi         \
-               xpp_blink       \
-               dahdi_genconf   \
-               dahdi_hardware  \
-               twinstar        \
-               #
-
-PERL_MANS      = $(PERL_SCRIPTS:%=%.8)
-
-TARGETS        = .perlcheck
-
-ifneq  (,$(PERLLIBDIR))
-PROG_INSTALL   += $(PERL_SCRIPTS)
-TARGETS                += $(PERL_MANS)
-endif
-
-all: $(TARGETS)
-
-docs: $(PERL_MANS)
+all:
 
 install: all
-       $(INSTALL) -d $(DESTDIR)$(SBINDIR)
-       $(INSTALL) $(PROG_INSTALL) $(DESTDIR)$(SBINDIR)/
        $(INSTALL) -d $(DESTDIR)$(DATADIR)
        $(INSTALL) xpp_fxloader astribank_hook $(DESTDIR)$(DATADIR)/
        $(INSTALL) waitfor_xpds $(DESTDIR)$(DATADIR)/
        $(INSTALL) -d $(DESTDIR)$(udevrulesdir)
        $(INSTALL_DATA) xpp.rules $(DESTDIR)$(udevrulesdir)/
-       $(INSTALL) -d $(DESTDIR)$(MANDIR)
-       $(INSTALL_DATA) $(PERL_MANS) $(DESTDIR)$(MANDIR)/
-ifneq  (,$(PERLLIBDIR))
-       $(INSTALL) -d $(DESTDIR)$(PERLLIBDIR)
-       for i in $(PERL_DIRS); \
-       do \
-               $(INSTALL) -d "$(DESTDIR)$(PERLLIBDIR)/$$i"; \
-       done
-       for i in $(PERL_MODS); \
-       do \
-               $(INSTALL_DATA) "perl_modules/$$i" "$(DESTDIR)$(PERLLIBDIR)/$$i"; \
-       done
-endif
-
-.perlcheck: $(PERL_SCRIPTS)
-       for i in $^; do perl -I./perl_modules -c $$i || exit 1; done
-       touch $@
 
 clean:
-       $(RM) $(TARGETS)
diff --git a/xpp/perl_modules/Makefile.am b/xpp/perl_modules/Makefile.am
new file mode 100644 (file)
index 0000000..b9a0520
--- /dev/null
@@ -0,0 +1,24 @@
+nobase_perllib_DATA    = \
+       Dahdi.pm \
+       Dahdi/Hardware.pm \
+       Dahdi/Xpp/Line.pm \
+       Dahdi/Xpp/Xbus.pm \
+       Dahdi/Xpp/Xpd.pm \
+       Dahdi/Xpp/Mpp.pm \
+       Dahdi/Span.pm \
+       Dahdi/Utils.pm \
+       Dahdi/Chans.pm \
+       Dahdi/Xpp.pm \
+       Dahdi/Config/Params.pm \
+       Dahdi/Config/Gen/Xpporder.pm \
+       Dahdi/Config/Gen/Spantypes.pm \
+       Dahdi/Config/Gen/Modules.pm \
+       Dahdi/Config/Gen/Users.pm \
+       Dahdi/Config/Gen/Freepbxdb.pm \
+       Dahdi/Config/Gen/Unicall.pm \
+       Dahdi/Config/Gen/Chandahdi.pm \
+       Dahdi/Config/Gen/Assignedspans.pm \
+       Dahdi/Config/Gen/System.pm \
+       Dahdi/Config/Gen.pm \
+       Dahdi/Hardware/USB.pm \
+       Dahdi/Hardware/PCI.pm