How to write make file for dynamic linked libraries
NEEL_DIR
= $(shell pwd)
LIBNAME = libneel
LIB = $(LIBNAME).so
INCLUDE = -I.
all: compile build_lib
mkdir -p $(INSTALL_DIR)/lib
install -m 755 $(LIB)
$(INSTALL_DIR)/lib
CFLAGS += -O0 -g -fno-omit-frame-pointer
-fno-strict-aliasing
CFLAGS += -fPIC
CFLAGS += $(INCLUDE)
SRCS = neel.c
OBJ_TARGETS = $(SRCS:%.c=$(NEEL_DIR)/%.o)
compile: $(OBJ_TARGETS)
$(NEEL_DIR)/%.o : $(NEEL_DIR)/%.c
@echo "Compiling file
$<"
$(CC) -c -g -w $(CFLAGS) -o
$@ $<
build_lib: compile
@echo "Linking"
$(CC) -shared -o $(LIB)
$(OBJ_TARGETS)
clean:
rm -f $(LIB) $(OBJ_TARGETS)