Build a shared library instead of a static library

This commit is contained in:
Les De Ridder 2017-10-30 02:22:24 +01:00
parent 840ee49c5b
commit 3cdd941748
2 changed files with 10 additions and 19 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*.swp *.swp
*.o *.o
*.a *.a
*.so
busexmp busexmp
loopback loopback

View File

@ -1,26 +1,16 @@
TARGET := busexmp loopback CC = clang
LIBOBJS := buse.o CFLAGS = -fPIC -Wall -Wextra -O
OBJS := $(TARGET:=.o) $(LIBOBJS) LDFLAGS = -shared
STATIC_LIB := libbuse.a
CC := /usr/bin/gcc
CFLAGS := -g -pedantic -Wall -Wextra -std=c99
LDFLAGS := -L. -lbuse
.PHONY: all clean .PHONY: all clean
all: $(TARGET)
$(TARGET): %: %.o $(STATIC_LIB) all: libbuse.so
$(CC) -o $@ $< $(LDFLAGS)
$(TARGET:=.o): %.o: %.c buse.h libbuse.so: buse.o
$(CC) $(CFLAGS) -o $@ -c $< $(CC) ${LDFLAGS} -o $@ $^
$(STATIC_LIB): $(LIBOBJS) buse.o: buse.c
ar rcu $(STATIC_LIB) $(LIBOBJS) $(CC) $(CFLAGS) -c -o $@ $^
$(LIBOBJS): %.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
clean: clean:
rm -f $(TARGET) $(OBJS) $(STATIC_LIB) rm -f buse.o libbuse.so