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
*.o
*.a
*.so
busexmp
loopback

View File

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