Update Makefile for shared library

This commit is contained in:
Thibaud Gasser 2018-05-23 02:40:38 +02:00
parent b5b56d759c
commit 2feb735f5b

View File

@ -1,10 +1,13 @@
TARGET = spnav TARGET = spnav
TARGET_LIB = libspnavhdi.so # target lib TARGET_LIB = libspnavhdi.so # target lib
LIBS = -Llib -lhidapi-libusb
CC = gcc CC = gcc
CFLAGS = -Wall -Wextra -fPIC -pedantic -O2 # C flags for building library CFLAGS = -Wall -Wextra -fPIC -pedantic -O2 # C flags for building library
#CFLAGS = -Wall -Wextra -pedantic -g # C flags for developpement #CFLAGS = -Wall -Wextra -pedantic -g # C flags for developpement
LDFLAGS = $(LIBS) -shared # linking flags
LDFLAGS = -Wall -Wextra -O2
LIBS = -Llib -lhidapi-libusb
RM = rm -f # rm command RM = rm -f # rm command
.PHONY: all default .PHONY: all default
@ -21,10 +24,11 @@ HEADERS = $(wildcard *.h)
.PRECIOUS: $(TARGET) $(OBJECTS) .PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@ $(CC) $(OBJECTS) -Wall -o $@ $(LIBS)
# Shared Libs
$(TARGET_LIB): $(OBJECTS) $(TARGET_LIB): $(OBJECTS)
$(CC) ${LDFLAGS} -o $@ $^ $(CC) $(LDFLAGS) -shared -fpic -Wl,--no-undefined -o $@ $^ $(LIBS)
.PHONY: clean .PHONY: clean
clean: clean: