[petsc-dev] user makefile

Mark Adams mfadams at lbl.gov
Fri Jan 14 11:33:49 CST 2022


Thanks,
This came up because a Chombo user, who has a makefile system that is
working on other platforms, failed on Spock because it did not find a
library. My make of an example worked and I had that lib and a -L path to a
directory with that lib.
So I wanted to double check the recommended lib variable. I think he has
PETSC_KSP_LIB, but I am waiting to hear back from him.

On Fri, Jan 14, 2022 at 10:46 AM Barry Smith <bsmith at petsc.dev> wrote:

>
>   I'll take a stab at fixing up the description of possible makefile
> approaches in the user's manual documentation and put it in an MR. I agree
> with Mark it is weak.
>
>   Barry
>
>
> > On Jan 14, 2022, at 10:41 AM, Jed Brown <jed at jedbrown.org> wrote:
> >
> > Makefile.user is meant to be the example that doesn't import a zillion
> variables and in which you can readily add other packages that provide
> pkg-config. (Just add them to one line.) If you already use pkg-config for
> other dependencies, it also makes clear how to add PETSc. This is
> symmetric, where as including PETSc makefiles is fundamentally nonsymmetric
> (they're full of rules and non-namespaced variables likely to conflict with
> other packages).
> >
> > While we could create a makefile that defines only namespaced variables
> and does not define rules, that would actually require more effort per
> package because you'd be needing CPPFLAGS = $(PETSC_CPPFLAGS) $(X_CPPFLAGS)
> $(Y_CPPFLAGS). In Makefile.user, you can add additional packages with one
> line.
> >
> > PACKAGES := $(petsc.pc) $(x.pc) $(y.pc)
> >
> > where the x.pc variable can either be the plain package name (to look
> for it in default locations) or a path to the x.pc file.
> >
> > Mark Adams <mfadams at lbl.gov> writes:
> >
> >> I want an example that I can clone for an existing makefile. I don't
> even
> >> see PETSC_LIB in Makefile.user
> >>
> >> Makefile.user is where you start if 0) you are starting from scratch and
> >> are all-in on PETSc.
> >>
> >> I think the vast majority of our users either 1) have a makefile and
> want
> >> to add PETSc or 2) want to keep more control than this turn-key method.
> >>
> >> I think something like Victor's material is useful even if it goes out
> of
> >> date (
> >>
> https://pages.tacc.utexas.edu/~eijkhout/taccnotes/petsclinking/petsclinking.html
> >> ).
> >>
> >> Barry's "Writing Application Codes with PETSc" addresses (0) and then
> jumps
> >> to 3) no makefile just cut and paste (nice, not what I'm looking for,
> but
> >> cleaner than making an example).
> >>
> >> (I have literally never done any of the methods, shown in the PETSc
> docs,
> >> before. I have alway owned the makefile with my targets, and all of my
> >> current users do this now.)
> >>
> >> The first thing I googled was "petsc user makefile" and found and
> >> interesting stackoverflow post (
> >>
> https://stackoverflow.com/questions/21338718/using-petsc-on-makefile-within-my-user-defined-makefile
> >> )
> >>
> >> Maybe just a FAQ "Adding PETSc to a user Makefile" and you could just
> have
> >> a link to Victor's page (and have him update the include path line)
> >>
> >>
> >> On Thu, Jan 13, 2022 at 11:15 PM Jed Brown <jed at jedbrown.org> wrote:
> >>
> >>> No makefile is needed to build foo from foo.c.
> >>>
> >>> $ make -f $PETSC_DIR/share/petsc/Makefile.user foo
> >>>
> >>>
> >>> In the example below, you don't have to write the recipe (the
> ${CLINKER}
> >>> line). It's enough to write
> >>>
> >>> foo: foo.o baz.o
> >>>
> >>> Matthew Knepley <knepley at gmail.com> writes:
> >>>
> >>>> foo: foo .o
> >>>>      ${CLINKER} -o $@ $^ ${PETSC_LIB}
> >>>>
> >>>>   Matt
> >>>>
> >>>> On Thu, Jan 13, 2022 at 9:54 PM Jacob Faibussowitsch <
> >>> jacob.fai at gmail.com>
> >>>> wrote:
> >>>>
> >>>>> Is share/petsc/Makefile.user what you are looking for?
> >>>>>
> >>>>> Best regards,
> >>>>>
> >>>>> Jacob Faibussowitsch
> >>>>> (Jacob Fai - booss - oh - vitch)
> >>>>>
> >>>>> On Jan 13, 2022, at 21:49, Barry Smith <bsmith at petsc.dev> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>
> https://petsc.org/release/docs/manual/getting_started/?highlight=user%20makefile
> >>>>>
> >>>>> Search for Writing Application Codes with PETSc
> >>>>>
> >>>>> Perhaps this needs to clearer or have links to it from the FAQ.
> >>>>>
> >>>>>
> >>>>>
> >>>>> On Jan 13, 2022, at 9:38 PM, Mark Adams <mfadams at lbl.gov> wrote:
> >>>>>
> >>>>> I am finding it pretty hard to find an example of a makefile target
> to
> >>>>> build an app with PETSc.
> >>>>>
> >>>>> I can not find it on the docs page.
> >>>>>
> >>>>> With Google:
> >>>>>
> >>>>> Victor has a little example that looks fine ($PETSC_LIB). (sort of,
> see
> >>>>> below)
> >>>>>
> >>>>> Another one is bigger and has this at the end:
> >>>>>
> >>>>>    -${CLINKER} $< -o bin.x $(OBJ_FILES) ${PETSC_KSP_LIB}
> >>>>> -I$(PETSC_DIR)/include
> >>>>>
> >>>>> I recall using PETSC_KSP_LIB the last time I wrote a makefile 20
> years
> >>> ago.
> >>>>>
> >>>>> Maybe there should be a FAQ that a search would find like "Example of
> >>> user
> >>>>> makefile" with something like Victor's (dropping v2 and updating it,
> >>> this
> >>>>> looks wrong):
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> *PETSc linkingThe easiest way to link PETSc to your code is to have
> this
> >>>>> line in your makefile:include ${PETSC_DIR}/conf/baseThis will
> >>> automatically
> >>>>> give you the compilation rules. For linking you then do:${CLINKER} -o
> >>> ex1
> >>>>> ex1.o ${PETSC_LIB}(or FLINKER for fortran)You can also use this
> include
> >>>>> line:include ${PETSC_DIR}/conf/variablesand then you have to give the
> >>>>> compile rules yourself. In this case, dosomething like${CC} -c ex1.c
> >>>>> ${PETSC_INCLUDE}to compile. (This is for petsc version 3, for
> version 2
> >>>>> useinclude ${PETSC_DIR}/bmake/common/baseand replace base by
> variables
> >>> to
> >>>>> omit petsc’s make rules.)If you insist on having all the libraries
> and
> >>>>> includes explicitly, usemake getlinklibsmake getincludedirs*
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> --
> >>>> What most experimenters take for granted before they begin their
> >>>> experiments is infinitely more interesting than any results to which
> >>> their
> >>>> experiments lead.
> >>>> -- Norbert Wiener
> >>>>
> >>>> https://www.cse.buffalo.edu/~knepley/ <
> >>> http://www.cse.buffalo.edu/~knepley/>
> >>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220114/9183945a/attachment.html>


More information about the petsc-dev mailing list