<div dir="ltr"><div>I want an example that I can clone for an existing makefile. I don't even see PETSC_LIB in Makefile.user</div><div><br></div><div>Makefile.user is where you start if 0) you are starting from scratch and are all-in on PETSc.</div><div><br></div><div>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.</div><div><br></div><div>I think something like Victor's material is useful even if it goes out of date (<a href="https://pages.tacc.utexas.edu/~eijkhout/taccnotes/petsclinking/petsclinking.html" target="_blank">https://pages.tacc.utexas.edu/~eijkhout/taccnotes/petsclinking/petsclinking.html</a>).</div><div><br></div><div>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).</div><div><br></div><div>(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.)</div><div><br></div><div>The first thing I googled was "petsc user makefile" and found and interesting stackoverflow post (<a href="https://stackoverflow.com/questions/21338718/using-petsc-on-makefile-within-my-user-defined-makefile">https://stackoverflow.com/questions/21338718/using-petsc-on-makefile-within-my-user-defined-makefile</a>)</div><div><br></div><div>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)</div><div><br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 13, 2022 at 11:15 PM Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">No makefile is needed to build foo from foo.c.<br>
<br>
$ make -f $PETSC_DIR/share/petsc/Makefile.user foo<br>
<br>
<br>
In the example below, you don't have to write the recipe (the ${CLINKER} line). It's enough to write<br>
<br>
foo: foo.o baz.o<br>
<br>
Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> writes:<br>
<br>
> foo: foo .o<br>
> ${CLINKER} -o $@ $^ ${PETSC_LIB}<br>
><br>
> Matt<br>
><br>
> On Thu, Jan 13, 2022 at 9:54 PM Jacob Faibussowitsch <<a href="mailto:jacob.fai@gmail.com" target="_blank">jacob.fai@gmail.com</a>><br>
> wrote:<br>
><br>
>> Is share/petsc/Makefile.user what you are looking for?<br>
>><br>
>> Best regards,<br>
>><br>
>> Jacob Faibussowitsch<br>
>> (Jacob Fai - booss - oh - vitch)<br>
>><br>
>> On Jan 13, 2022, at 21:49, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br>
>><br>
>><br>
>><br>
>> <a href="https://petsc.org/release/docs/manual/getting_started/?highlight=user%20makefile" rel="noreferrer" target="_blank">https://petsc.org/release/docs/manual/getting_started/?highlight=user%20makefile</a><br>
>><br>
>> Search for Writing Application Codes with PETSc<br>
>><br>
>> Perhaps this needs to clearer or have links to it from the FAQ.<br>
>><br>
>><br>
>><br>
>> On Jan 13, 2022, at 9:38 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br>
>><br>
>> I am finding it pretty hard to find an example of a makefile target to<br>
>> build an app with PETSc.<br>
>><br>
>> I can not find it on the docs page.<br>
>><br>
>> With Google:<br>
>><br>
>> Victor has a little example that looks fine ($PETSC_LIB). (sort of, see<br>
>> below)<br>
>><br>
>> Another one is bigger and has this at the end:<br>
>><br>
>> -${CLINKER} $< -o bin.x $(OBJ_FILES) ${PETSC_KSP_LIB}<br>
>> -I$(PETSC_DIR)/include<br>
>><br>
>> I recall using PETSC_KSP_LIB the last time I wrote a makefile 20 years ago.<br>
>><br>
>> Maybe there should be a FAQ that a search would find like "Example of user<br>
>> makefile" with something like Victor's (dropping v2 and updating it, this<br>
>> looks wrong):<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> *PETSc linkingThe easiest way to link PETSc to your code is to have this<br>
>> line in your makefile:include ${PETSC_DIR}/conf/baseThis will automatically<br>
>> give you the compilation rules. For linking you then do:${CLINKER} -o ex1<br>
>> ex1.o ${PETSC_LIB}(or FLINKER for fortran)You can also use this include<br>
>> line:include ${PETSC_DIR}/conf/variablesand then you have to give the<br>
>> compile rules yourself. In this case, dosomething like${CC} -c ex1.c<br>
>> ${PETSC_INCLUDE}to compile. (This is for petsc version 3, for version 2<br>
>> useinclude ${PETSC_DIR}/bmake/common/baseand replace base by variables to<br>
>> omit petsc’s make rules.)If you insist on having all the libraries and<br>
>> includes explicitly, usemake getlinklibsmake getincludedirs*<br>
>><br>
>><br>
>><br>
>><br>
>><br>
><br>
> -- <br>
> What most experimenters take for granted before they begin their<br>
> experiments is infinitely more interesting than any results to which their<br>
> experiments lead.<br>
> -- Norbert Wiener<br>
><br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
</blockquote></div></div>