Here is an interesting problem I've stumbled on. I have an application. We are adding support for a new version of a low level third party library. The previous release required me to link against Linux Streams.
Our new prototype system doesn't need Linux Streams. I don't want to have two Makefile for this single discrepency; but if I try to link to Linux Streams on the new prototype, the applications no longer compiles.
Basically, in make, I'd like to call a script (to determine whether I need Linux Streams), and edit my library listing accordingly. I wrote the script easy enough (for this example named isver.sh), but…
ATTEMPT (A)
So, given:
LIBLIST = -ldxxx -ldti -ldl -lsrl
switch : $(OBJECTS) ./isver.sh DLGCcom 6 || $(eval LIBLIST += -lLiS) gcc $(OBJECTS) $(LIBLIST) -o switch
RESULT: This looked promising by doesn't work since the eval is not in the Makefile context.
ATTEMPT (B)
The closest I could get was:…
RESULT: This gets the job done but is excruciatingly UGLY!
> Q:Does anyone know a better "outside the box" method for accomplishing > something like this?
$ cat Makefile
LIBLIST := -ldxxx -ldti -ldl -lsrl $(shell ./isver.sh || echo "-lLiS")
all: @echo "LIBLIST = $(LIBLIST)"
$ ln -sf /bin/true isver.sh && make LIBLIST = -ldxxx -ldti -ldl -lsrl $ ln -sf /bin/false isver.sh && make LIBLIST = -ldxxx -ldti -ldl -lsrl -lLiS
Or you can make the script itself echo "" or "-lLiS", and simplify the Makefile even more:
LIBLIST := -ldxxx -ldti -ldl -lsrl $(shell ./isver.sh)
Paul Pluzhnikov