title: Makefile for program running on different machines
body: <p>I have a C++ program that will run on several machines that use a Network File System. For each of the C++ libraries that my program uses, I installed a version for each machine, under ~/program_files/machinename/libraryname.</p>
  <p>&quot;machinename&quot; is obtained via bash command &quot;hostname&quot;. On the machines I am using, &quot;hostname&quot; outputs something like &quot;io21.aaa.bbb.edu&quot; and I take only &quot;io21&quot; as &quot;machinename&quot; for the path to the libraries. In bash, I learned that</p>
  <blockquote>
  <p>$ HOST=<code>hostname</code> # now the value of HOST is &quot;io21.aaa.bbb.edu&quot;</p>
  <p>$ HOST=${HOST%%.*} # extract &quot;io21&quot; from &quot;io21.aaa.bbb.edu&quot;</p>
  <p>$ echo ${HOST}</p>
  <p>io21</p>
  </blockquote>
  <p>In the Makefile of my program, I want to call these bash commands to specify the path to the library according to the current machine:</p>
  <blockquote>
  <p>HOST := $(shell hostname)</p>
  <p>HOST := $(shell ${HOST%%.*})</p>
  <p>LDFLAGS=-L${HOME}/program_files/${HOST}/libraryname/lib</p>
  <p>CXXFLAGS=-Wall -I${HOME}/program_files/${HOST}/libraryname/include</p>
  </blockquote>
  <p>The first line is working i.e. HOST is &quot;io21.aaa.bbb.edu&quot;, but the second line which extracts &quot;io21&quot; doesn't work and HOST is still &quot;io21.aaa.bbb.edu&quot;.</p>
  <p>I am wondering how I should solve this problem?</p>
  <p>Thanks and regards!</p>