I need to compile my program with or without some libraries depending on which of the two hosts it is running. I don't know what to use at the right side of HOST=
in my makefile to make this work as I want it to:
ifeq(${HOST},${ADDITIONAL_LIBS_HOST})
ADD_LIBS= ...
${ADDITIONAL_LIBS_HOST}
is the name of host as gotten from
echo ${HOSTNAME}
A few thoughts:
This is the sort of situation GNU autoconf was designed to address. Run ./configure
, figure out what libraries are available, and generate an appropriate Makefile.
You could get the current hostname by doing something like:
HOST=$(shell hostname)
You could then use this in your conditional.
You could instead have your Makefile do something like:
include Makefile.local
And then have different Makefile.local files on each host.
Re: your comment, given a Makefile like this:
HOST=$(shell hostname)
all:
@echo $(HOST)
Will generate the following output:
$ make all
fafnir.local
(Assuming your local host is "fafnir.local". Which mine is.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With