<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Pass Variables to Makefile in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164142#M90784</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;You did not specify if you are using &lt;BR /&gt;GNU make or standard HP-UX.&lt;BR /&gt;&lt;BR /&gt;Several possibilities:&lt;BR /&gt;&lt;BR /&gt;a) For example, in a properly written&lt;BR /&gt;Makefile, the variable CFLAGS is included&lt;BR /&gt;in each command that runs the C compiler,&lt;BR /&gt;so a file myfile.c would be compiled as:&lt;BR /&gt;&lt;BR /&gt;# cc -c $(CFLAGS) myfile.c&lt;BR /&gt;&lt;BR /&gt;Whatever value is set for CFLAGS, it affects&lt;BR /&gt;each compilation.&lt;BR /&gt;&lt;BR /&gt;When you run make, you can override it.&lt;BR /&gt;&lt;BR /&gt;For example&lt;BR /&gt;&lt;BR /&gt;# make CFLAGS='-g -O'&lt;BR /&gt;&lt;BR /&gt;b) In HP-UX, there is make(1) flag "-e":&lt;BR /&gt;&lt;BR /&gt;Environment variables override assignments &lt;BR /&gt;within Makefiles&lt;BR /&gt;&lt;BR /&gt;c) HP-UX make(1) supports ifdef&lt;BR /&gt;test in Makefile. An example:&lt;BR /&gt;&lt;BR /&gt;ifdef UNAME&lt;BR /&gt;   SYSTEM = $(UNAME)&lt;BR /&gt;else&lt;BR /&gt;   SYSTEM = "UNSUPPORTED"&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
    <pubDate>Wed, 19 Mar 2008 09:06:01 GMT</pubDate>
    <dc:creator>VK2COT</dc:creator>
    <dc:date>2008-03-19T09:06:01Z</dc:date>
    <item>
      <title>How to Pass Variables to Makefile</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164141#M90783</link>
      <description>Hi, I want to know how to pass a variable to makefile from the command prompt. And inside the makefile i want to check this variable and do conditional compilation.&lt;BR /&gt;In the command prompt when i just call make i starts executing blindly and no variables i passing for this make. But i need an option like to conditionally compile upon users choice.Please tell me how to establish this.</description>
      <pubDate>Wed, 19 Mar 2008 06:41:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164141#M90783</guid>
      <dc:creator>Chakkarapani</dc:creator>
      <dc:date>2008-03-19T06:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass Variables to Makefile</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164142#M90784</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;You did not specify if you are using &lt;BR /&gt;GNU make or standard HP-UX.&lt;BR /&gt;&lt;BR /&gt;Several possibilities:&lt;BR /&gt;&lt;BR /&gt;a) For example, in a properly written&lt;BR /&gt;Makefile, the variable CFLAGS is included&lt;BR /&gt;in each command that runs the C compiler,&lt;BR /&gt;so a file myfile.c would be compiled as:&lt;BR /&gt;&lt;BR /&gt;# cc -c $(CFLAGS) myfile.c&lt;BR /&gt;&lt;BR /&gt;Whatever value is set for CFLAGS, it affects&lt;BR /&gt;each compilation.&lt;BR /&gt;&lt;BR /&gt;When you run make, you can override it.&lt;BR /&gt;&lt;BR /&gt;For example&lt;BR /&gt;&lt;BR /&gt;# make CFLAGS='-g -O'&lt;BR /&gt;&lt;BR /&gt;b) In HP-UX, there is make(1) flag "-e":&lt;BR /&gt;&lt;BR /&gt;Environment variables override assignments &lt;BR /&gt;within Makefiles&lt;BR /&gt;&lt;BR /&gt;c) HP-UX make(1) supports ifdef&lt;BR /&gt;test in Makefile. An example:&lt;BR /&gt;&lt;BR /&gt;ifdef UNAME&lt;BR /&gt;   SYSTEM = $(UNAME)&lt;BR /&gt;else&lt;BR /&gt;   SYSTEM = "UNSUPPORTED"&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Wed, 19 Mar 2008 09:06:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164142#M90784</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2008-03-19T09:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass Variables to Makefile</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164143#M90785</link>
      <description>&amp;gt;And inside the makefile i want to check this variable and do conditional compilation.&lt;BR /&gt;&lt;BR /&gt;As VK2COT alluded, you can't do this with HP's make, you must use gmake.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;But i need an option like to conditionally compile upon users choice.&lt;BR /&gt;&lt;BR /&gt;You might be able to do this by explicitly mentioning a target.  This allows you to build only parts of the makefile.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;VK2COT: c) HP-UX make(1) supports ifdef&lt;BR /&gt;test in Makefile.&lt;BR /&gt;&lt;BR /&gt;I'm not sure where you got this but it isn't in the man page.&lt;BR /&gt;&lt;BR /&gt;The only new feature I see is "conditional macro definition" but this probably won't help.</description>
      <pubDate>Wed, 19 Mar 2008 17:02:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164143#M90785</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-03-19T17:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass Variables to Makefile</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164144#M90786</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I'm not sure where you got this but it&lt;BR /&gt;&amp;gt; isn't in the man page.&lt;BR /&gt;&lt;BR /&gt;Nor, apparently, in reality:&lt;BR /&gt;&lt;BR /&gt;dyi # cat makefile&lt;BR /&gt;ifdef UNAME&lt;BR /&gt;SYSTEM = $(UNAME)&lt;BR /&gt;else&lt;BR /&gt;SYSTEM = "UNSUPPORTED"&lt;BR /&gt;endif&lt;BR /&gt;&lt;BR /&gt;dyi # make&lt;BR /&gt;Make: Must be a separator on rules line 2.  Stop.&lt;BR /&gt;&lt;BR /&gt;dyi # gmake&lt;BR /&gt;gmake: *** No targets.  Stop.&lt;BR /&gt;&lt;BR /&gt;dyi # uname -a&lt;BR /&gt;HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license</description>
      <pubDate>Wed, 19 Mar 2008 18:09:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164144#M90786</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-03-19T18:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pass Variables to Makefile</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164145#M90787</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Ahh, wrong statement by me (option c) in previous post).&lt;BR /&gt;&lt;BR /&gt;GNU make supports two types of If test, ifdef&lt;BR /&gt;and ifeq (and the negative versions ifndef,&lt;BR /&gt;ifneq), not the HP-UX native one!&lt;BR /&gt;&lt;BR /&gt;gmake != HP-UX make&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Wed, 19 Mar 2008 21:04:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-pass-variables-to-makefile/m-p/4164145#M90787</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2008-03-19T21:04:56Z</dc:date>
    </item>
  </channel>
</rss>

