Try:
export LD_LIBRARY_PATH := /usr/local/lib:$(LD_LIBRARY_PATH)
install:
#Do Install actions
See Section 5.3 of the Make manual for an explanation of Bruce's correct assumption on subshells, whivh leads us to this Answer at StackOverflow, which states that all commands should be executed as a one liner.
Update
Since the one liner did not work, use the following, as an example (I'm including the files below so that the final makefile will Work):
Filelist:
hellomacke.c
#include
int main() {
// call a function in another file
myPrintHelloMake();
return(0);
}
hellofunc.c
#include
#include
void myPrintHelloMake(void) {
printf("Hello makefiles!\n");
return;
}
hellomake.h
/*
example include file
*/
void myPrintHelloMake(void);
End Filelist
Makefile
IDIR =../include
CC=gcc
CFLAGS=-I$(IDIR)
ODIR=obj
LDIR =../lib
LIBS=-lm
_DEPS = hellomake.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = hellomake.o hellofunc.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
hellomake: $(OBJ)
gcc -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
The above makefile uses Macros and String Expansion to properly set the include and libraries directories without the need of the export
command. In your case, passing /usr/local/libs
to LDIR
and then compiling should get you started.
References
Colby College, Maine, Computer Science Department - Makefile Tutorial
The M4 Macro Processor - Paste Substitution