From b5b56d759c465509810ad35ae5a6ee4bf9e08197 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Wed, 23 May 2018 01:50:41 +0200 Subject: [PATCH] Add rule to build shared library in Makefile Add rule in Makefile to build libspnavhdi.so --- .gitignore | 2 ++ Makefile | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a3062be..5c79bb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .vscode/* + +*.o diff --git a/Makefile b/Makefile index 780cbc4..f4d9aba 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,13 @@ TARGET = spnav +TARGET_LIB = libspnavhdi.so # target lib LIBS = -Llib -lhidapi-libusb CC = gcc -CFLAGS = -Wall -Wextra -pedantic +CFLAGS = -Wall -Wextra -fPIC -pedantic -O2 # C flags for building library +#CFLAGS = -Wall -Wextra -pedantic -g # C flags for developpement +LDFLAGS = $(LIBS) -shared # linking flags +RM = rm -f # rm command -.PHONY: mrproper all default +.PHONY: all default default: $(TARGET) all: default @@ -19,8 +23,10 @@ HEADERS = $(wildcard *.h) $(TARGET): $(OBJECTS) $(CC) $(OBJECTS) -Wall $(LIBS) -o $@ -clean: - -rm -f *.o +$(TARGET_LIB): $(OBJECTS) + $(CC) ${LDFLAGS} -o $@ $^ -mrproper: clean - -rm -f $(TARGET) \ No newline at end of file +.PHONY: clean +clean: + -${RM} ${TARGET} + -${RM} ${TARGET_LIB} ${OBJECTS} $(SRCS:.c=.d)