<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Menlo;
panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Thanks Barry,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It makes much more sense! And thanks for clarifying what “P” indicates. I like this explicit approach over implicit because I am bad with makefile syntax. However, share/petsc/Makefile.user looks much cleaner, but I need to learn how pkg-config
works to understand it. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you,<o:p></o:p></p>
<p class="MsoNormal">Alex.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Barry Smith <bsmith@petsc.dev><br>
<b>Date: </b>Tuesday, December 15, 2020 at 7:41 PM<br>
<b>To: </b>Alex Koshkarov <okoshkarov@tae.com><br>
<b>Cc: </b>petsc-users <petsc-users@mcs.anl.gov><br>
<b>Subject: </b>Re: [petsc-users] Petsc makefile and PETSC_COMPILE variable<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"> Alex, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"> Since you are explicitly defining your rules you might as well just do it completely, so use something like<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">objects/%.o: src/%.c $(DEP)<br>
${PCC} -c $< -o $@ <span style="font-size:10.5pt;font-family:Menlo">${PCC_FLAGS} ${PFLAGS} ${CCPPFLAGS}</span><o:p></o:p></p>
</blockquote>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">The P indicates either C and C flags or C++ compiler and its flags if configure was run with --with-clanguage=c++ (not recommended).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">So if your code is C you can use <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">${CC} -c $< -o $@ <span style="font-size:10.5pt;font-family:Menlo">${CC_FLAGS} ${CPP_FLAGS}</span><o:p></o:p></p>
</blockquote>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">if C++ use<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">${CXX} -c $< -o $@ <span style="font-size:10.5pt;font-family:Menlo">${CXXPP_FLAGS} ${CXX_FLAGS}</span><o:p></o:p></p>
</blockquote>
</blockquote>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">With this you don't need the COMPILE macros that are really internal for PETSc's use.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"> Barry<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> We have not been completely successful at getting share/petsc/Makefile.user to be bullet proof yet, but if you can get it to work in your case great.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Dec 15, 2020, at 11:46 AM, Alex Koshkarov <<a href="mailto:okoshkarov@tae.com">okoshkarov@tae.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Thank you! <br>
<br>
It makes sense to use share/petsc/Makefile.user - I will try to understand it. However, can you please tell me what is the meaning of "_SINGLE" in "PETSC_COMPILE_SINGLE"? Does it mean compile only one source file?<br>
<br>
Best regards,<br>
Alex Koshkarov.<br>
<br>
On 12/15/20, 9:25 AM, "Satish Balay" <<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>> wrote:<br>
<br>
On Tue, 15 Dec 2020, Alex Koshkarov wrote:<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi All,<br>
<br>
I have been using trivial makefile (see below) for the code which uses petsc. The makefile relies on variable PETSC_COMPILE which disappeared in new petsc version (absent in 3.14.2, but present in 3.13.4). What would be the right way to fix the makefile? (should
I use something like PETSC_COMPILE_SINGLE ?).<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
Yes - this change was a bugfix.<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Is it a very bad practice to use such makefile?<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
For most use cases the default targets work. However this usage [where sources and obj files are in different dirs] is not covered by them.<br>
<br>
So - I think using such targets is appropriate.<br>
<br>
There is also share/petsc/Makefile.user - which attempts to provide a portable way to create user makefiles [that don't rely on internals like PETSC_COMPILE_SINGLE] - but requires gnumake and pkgconfig<br>
<br>
Satish<br>
<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
p.s. sorry if this is a duplicate message, I believe I sent the first one to the wrong address.<br>
<br>
Thank you very much,<br>
Alex Koshkarov.<br>
<br>
<br>
Example of makefile, it assumes sources in “src” and creats objects in “objects”:<br>
<br>
CPP := $(wildcard src/*.c)<br>
DEP := $(wildcard src/*.h)<br>
OBJ := $(addprefix objects/,$(notdir $(CPP:.c=.o)))<br>
<br>
include ${PETSC_DIR}/lib/petsc/conf/variables<br>
include ${PETSC_DIR}/lib/petsc/conf/rules<br>
<br>
driver: $(OBJ)<br>
-${CLINKER} -o $@ $^ ${PETSC_LIB} ${EXTRALIBS} ${CFLAGS}<br>
<br>
objects/%.o: src/%.c $(DEP)<br>
${PETSC_COMPILE} -c $< -o $@<br>
<br>
<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>