integration of perl with automake

View: New views
9 Messages — Rating Filter:   Alert me  

integration of perl with automake

by Andreas Otto-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

  to build a perl extension it's best to use the perl build-system based on

        perl Makefile.PL

   the command create a Makefile in the same directory of Makefile.PL self
   and in the toplefel-position "perlmsgque/Makefile".
   I can use this makefile in an automake build environment using

        SUBDIRS += perlmsgque

   from the toplevel

  now the problem. a "make clean" clean the file perlmsgque/Makefile. this
  is coded in the "Makefile.PL" create Makefile

  1.   I need automake code to check if "perlmsgque/Makefile" is avilable
        and build this makefile again if missing (after make clean) or extend
        the toplevel Makefile to do a
                (cd perlmsgque;perl Makefile.PL)
        after all "make clean" was done

  2. related to this problem Is the initial build of the "perlmsgque/Makefile"
        currently I use the autoconf to do the "perl Makefile.PL" but I thing
        it should be better done on need in the toplevel makefile.


I hope this is not to complicated

-> thanks for help


mfg

  aotto1968
 





Re: integration of perl with automake

by Bob Friesenhahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 15 Oct 2009, Andreas Otto wrote:

>  to build a perl extension it's best to use the perl build-system based on
>
> perl Makefile.PL

I have been dealing with this situation for many (11?) years (first in
ImageMagick, and then in GraphicsMagick).  It is really difficult to
integrate Automake with Perl's Make::Maker because Perl's Make::Maker
does not observe any normal conventions and has a mind of its own
based on whatever options were used way back when perl itself was
built with some other compiler.  Nightmare is an understatement.
Regardless, I suggest to take a look at ImageMagick or GraphicsMagick
Automake makefiles to see how it may be done.

See the hunk of junk at

http://cvs.graphicsmagick.org/cgi-bin/cvsweb.cgi/GraphicsMagick/PerlMagick/Makefile.am

Bob
--
Bob Friesenhahn
bfriesen@..., http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/



Re: integration of perl with automake

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andreas,

beside the advice already give to you:

* Andreas Otto wrote on Thu, Oct 15, 2009 at 12:59:39PM CEST:
>   to build a perl extension it's best to use the perl build-system based on
>
> perl Makefile.PL
>
>    the command create a Makefile in the same directory of Makefile.PL self
>    and in the toplefel-position "perlmsgque/Makefile".
[...]

Generally, you have more than one possibility when integrating
non-Automake makefiles in your build system.  E.g., you can either
amend the makefile to have the needed targets, or rewrite it from
scratch, or put adjustment rules in the Makefile.am one level above
(and then call the subdir makefile manually, without listing it in
SUBDIRS).

  info Automake "Third-Party Makefiles"

has some more hints and suggestions.

>   1.   I need automake code to check if "perlmsgque/Makefile" is avilable
> and build this makefile again if missing (after make clean) or extend
> the toplevel Makefile to do a
> (cd perlmsgque;perl Makefile.PL)
> after all "make clean" was done

It doesn't seem sensible to do this at the end of a "make clean".  It
should be done before the subdir is entered for any other recursive
target.

You can try out something like this:

  PERL = perl
  $(RECURSIVE_TARGETS): make-perl-makefile
  make-perl-makefile:
        cd perlmsgque && $(PERL) Makefile.PL

Note that it is likely that the perl-generated makefile is missing other
targets that automake adds automatically.  You could add them manually
after the above, e.g., continue the rule with
        echo 'distdir: ; cp foo bar $$(distdir)' >> perlmsgque/Makefile

and whatever else might need adding.  You can try 'make distcheck' to
find several things you'll need.

Please note that this relies on the undocumented $(RECURSIVE_TARGETS)
variable, so there is a small chance it could break with a future
Automake release.

>   2. related to this problem Is the initial build of the "perlmsgque/Makefile"
> currently I use the autoconf to do the "perl Makefile.PL" but I thing
> it should be better done on need in the toplevel makefile.

That should be fixed by any of the above as well.

Cheers,
Ralf



Re: integration of perl with automake

by Andreas Otto-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

  this is my solution:
  I have coosen a Makefile.am wrapper and the perl-extension is in
  a subdirectory of the wrapper. I changed the extension-name to
  Net::Msgque (as requested by the perl community)
  the automake configuration is complete (as of my needs) including
  a VPATH build and including the "distclean" check.
  PERL - MakeMaker does not support a VPATH build but a work-
  around is possible to copy the perl extension directory into the
  build directory. This have to be cleaned-up in distclean-local.

  now the Makefile:
  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if USE_PERL

PERLMAKEFILE  = Net-Msgque/Makefile
PERLDEPEND    = Net-Msgque/Makefile.PL Net-Msgque/typemap Net-
Msgque/lib/Net/Msgque.pm
PERLCONFIG    =   PREFIX=$(prefix) \
                  INC="-Wall -I. -I../$(top_srcdir)/src" \
                  OBJECT="\$$(O_FILES) ../$(top_builddir)/src/.libs/*.o"

if DEBUG
PERLCONFIG    += OPTIMIZE=-g
endif

$(PERLMAKEFILE): $(PERLDEPEND) Makefile.am
        -test ! -d Net-Msgque && cp -pr $(srcdir)/Net-Msgque . && chmod -R u+w
Net-Msgque && touch Net-Msgque/.distclean
        cd Net-Msgque && @PERL@ Makefile.PL $(PERLCONFIG)

all-local: $(PERLMAKEFILE)
        cd Net-Msgque && $(MAKE) $(AM_MAKEFLAGS)

clean-local: $(PERLMAKEFILE)
        cd Net-Msgque && $(MAKE) $(AM_MAKEFLAGS) clean

install-exec-local:
        cd Net-Msgque && $(MAKE) $(AM_MAKEFLAGS) DESTDIR=$(DESTDIR) install

uninstall-local:
        rm -f $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/Net/Msgque.pm
        rm -f
$(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/Msgque.so
        rm -f
$(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/Msgque.bs
        rm -f
$(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/autosplit.ix
        rm -f
$(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/.packlist
        rm -f $(DESTDIR)/$(prefix)/lib/*/*/*/perllocal.pod
        rm -f $(DESTDIR)/$(prefix)/share/man/man3/Net::Msgque.3

distclean-local:
        test -f Net-Msgque/.distclean && rm -fr Net-Msgque

endif

EXTRA_DIST = \
        Net-Msgque/ppport.h \
        Net-Msgque/Msgque.xs \
        Net-Msgque/lib/Net/Msgque.pm \
        Net-Msgque/Makefile.PL \
        Net-Msgque/README \
        Net-Msgque/t/Net-Msgque.t \
        Net-Msgque/Changes \
        Net-Msgque/MANIFEST \
        Net-Msgque/typemap
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


mfg

  Andreas Otto


Re: integration of perl with automake

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andreas,

thanks for sharing your solution.  A couple of comments:

* Andreas Otto wrote on Mon, Oct 19, 2009 at 12:20:26PM CEST:
> if USE_PERL
>
> PERLMAKEFILE  = Net-Msgque/Makefile
> PERLDEPEND    = Net-Msgque/Makefile.PL Net-Msgque/typemap Net-
> Msgque/lib/Net/Msgque.pm
> PERLCONFIG    =   PREFIX=$(prefix) \

It would be prudent to quote $(prefix), too.

>                   INC="-Wall -I. -I../$(top_srcdir)/src" \
>                   OBJECT="\$$(O_FILES) ../$(top_builddir)/src/.libs/*.o"

> install-exec-local:
>         cd Net-Msgque && $(MAKE) $(AM_MAKEFLAGS) DESTDIR=$(DESTDIR) install

Likewise, I'd quote $(DESTDIR) here, or even better, omit
DESTDIR=$(DESTDIR) unless Net-Msgque/Makefile initializes it.

> uninstall-local:
>         rm -f $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/Net/Msgque.pm

Please remove the slash between $(DESTDIR) and $(prefix) here and in
following lines.  Otherwise you risk breaking the installation on w32
with --prefix=C:/foo and empty DESTDIR.  Also, again it would be prudent
to quote the $(DESTDIR)$(prefix) part of the strings.

>         rm -f
> $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/Msgque.so
>         rm -f
> $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/Msgque.bs
>         rm -f
> $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/autosplit.ix
>         rm -f
> $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/.packlist
>         rm -f $(DESTDIR)/$(prefix)/lib/*/*/*/perllocal.pod
>         rm -f $(DESTDIR)/$(prefix)/share/man/man3/Net::Msgque.3
>
> distclean-local:
>         test -f Net-Msgque/.distclean && rm -fr Net-Msgque

Won't that also remove files from your package iff source and build tree
coincide?

Cheers,
Ralf



Re: integration of perl with automake

by Andreas Otto-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Dienstag 20 Oktober 2009 08:27:01 schrieb Ralf Wildenhues:

> Hello Andreas,
>
> thanks for sharing your solution.  A couple of comments:
>
> * Andreas Otto wrote on Mon, Oct 19, 2009 at 12:20:26PM CEST:
> > if USE_PERL
> >
> > PERLMAKEFILE  = Net-Msgque/Makefile
> > PERLDEPEND    = Net-Msgque/Makefile.PL Net-Msgque/typemap Net-
> > Msgque/lib/Net/Msgque.pm
> > PERLCONFIG    =   PREFIX=$(prefix) \
>
> It would be prudent to quote $(prefix), too.
>
> >                   INC="-Wall -I. -I../$(top_srcdir)/src" \
> >                   OBJECT="\$$(O_FILES) ../$(top_builddir)/src/.libs/*.o"
> >
> > install-exec-local:
> >         cd Net-Msgque && $(MAKE) $(AM_MAKEFLAGS) DESTDIR=$(DESTDIR)
> > install
>
> Likewise, I'd quote $(DESTDIR) here, or even better, omit
> DESTDIR=$(DESTDIR) unless Net-Msgque/Makefile initializes it.
>
> > uninstall-local:
> >         rm -f $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/Net/Msgque.pm
>
> Please remove the slash between $(DESTDIR) and $(prefix) here and in
> following lines.  Otherwise you risk breaking the installation on w32
> with --prefix=C:/foo and empty DESTDIR.  Also, again it would be prudent
> to quote the $(DESTDIR)$(prefix) part of the strings.
>
> >         rm -f
> > $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/Msgque.so
> >         rm -f
> > $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/Msgque.bs
> >         rm -f
> > $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/autosplit.ix
> >         rm -f
> > $(DESTDIR)/$(prefix)/lib/*/site_perl/*/*/auto/Net/Msgque/.packlist
> >         rm -f $(DESTDIR)/$(prefix)/lib/*/*/*/perllocal.pod
> >         rm -f $(DESTDIR)/$(prefix)/share/man/man3/Net::Msgque.3
> >
> > distclean-local:
> >         test -f Net-Msgque/.distclean && rm -fr Net-Msgque
>
> Won't that also remove files from your package iff source and build tree
> coincide?

Hi,

  I add your suggestions ...

I use the flag file "Net-Msgque/.distclean" to distinguish the VPATH build
from the non VPATH build. this flag is only set in the directory I copied
from the source into the build tree and clean act on this flag


mfg

  Andreas Otto



Re: integration of perl with automake

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Andreas Otto wrote on Tue, Oct 20, 2009 at 08:53:14AM CEST:
> Am Dienstag 20 Oktober 2009 08:27:01 schrieb Ralf Wildenhues:
> > >
> > > distclean-local:
> > >         test -f Net-Msgque/.distclean && rm -fr Net-Msgque
> >
> > Won't that also remove files from your package iff source and build tree
> > coincide?

> I use the flag file "Net-Msgque/.distclean" to distinguish the VPATH build
> from the non VPATH build. this flag is only set in the directory I copied
> from the source into the build tree and clean act on this flag

OK, but then 'make distclean' wouldn't remove the files it should
remove, if source and build tree coincide, no?

Cheers,
Ralf



Re: integration of perl with automake

by Andreas Otto-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Dienstag 20 Oktober 2009 21:07:35 schrieb Ralf Wildenhues:

> * Andreas Otto wrote on Tue, Oct 20, 2009 at 08:53:14AM CEST:
> > Am Dienstag 20 Oktober 2009 08:27:01 schrieb Ralf Wildenhues:
> > > > distclean-local:
> > > >         test -f Net-Msgque/.distclean && rm -fr Net-Msgque
> > >
> > > Won't that also remove files from your package iff source and build
> > > tree coincide?
> >
> > I use the flag file "Net-Msgque/.distclean" to distinguish the VPATH
> > build from the non VPATH build. this flag is only set in the directory I
> > copied from the source into the build tree and clean act on this flag
>
> OK, but then 'make distclean' wouldn't remove the files it should
> remove, if source and build tree coincide, no?
>
> Cheers,
> Ralf


Hi,


$(PERLMAKEFILE): $(PERLDEPEND) Makefile.am
        -test ! -d Net-Msgque && cp -pr $(srcdir)/Net-Msgque . && \
                chmod -R u+w Net-Msgque && touch Net-Msgque/.distclean
        cd Net-Msgque && @PERL@ Makefile.PL $(PERLCONFIG)

  non VPATH -> build-tree == source-tree
    => no copy and no flag "Net-Msgque.distclean"
    => no distclean remove

  VPATH -> build-tree != source-tree
   => copy from Net-Msgque done and flag "Net-Msgque/.distclean" set
   => distclean remove performed

is this does not explain your problem
than I don't understand what you mean


mfg

  Andreas Otto

Re: integration of perl with automake

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Andreas Otto wrote on Wed, Oct 21, 2009 at 08:04:15AM CEST:
> Am Dienstag 20 Oktober 2009 21:07:35 schrieb Ralf Wildenhues:
> > * Andreas Otto wrote on Tue, Oct 20, 2009 at 08:53:14AM CEST:
> > > I use the flag file "Net-Msgque/.distclean" to distinguish the VPATH
> > > build from the non VPATH build. this flag is only set in the directory I
> > > copied from the source into the build tree and clean act on this flag
> >
> > OK, but then 'make distclean' wouldn't remove the files it should
> > remove, if source and build tree coincide, no?

> $(PERLMAKEFILE): $(PERLDEPEND) Makefile.am
>         -test ! -d Net-Msgque && cp -pr $(srcdir)/Net-Msgque . && \
> chmod -R u+w Net-Msgque && touch Net-Msgque/.distclean
>         cd Net-Msgque && @PERL@ Makefile.PL $(PERLCONFIG)
>
>   non VPATH -> build-tree == source-tree
>     => no copy and no flag "Net-Msgque.distclean"
>     => no distclean remove
>
>   VPATH -> build-tree != source-tree
>    => copy from Net-Msgque done and flag "Net-Msgque/.distclean" set
>    => distclean remove performed
>
> is this does not explain your problem
> than I don't understand what you mean

Ah, ok, I didn't realize that you weren't copying those files in the
non-VPATH case.  That looks good then.

Cheers,
Ralf