Skip to content

Commit

Permalink
add possibility to build shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
marcom committed Sep 22, 2022
1 parent 7547185 commit cb69a3b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean
.PHONY: all lib clean

CC = gcc
CFLAGS = -std=c99 -I.
Expand All @@ -22,10 +22,16 @@ OBJS_CTOOLS = ctools/dary.o ctools/libctools.o ctools/num_utils.o ctools/random.
OBJS_MD = md/md.o
ALLOBJS = $(OBJS_COMMON) $(OBJS_OPT) $(OBJS_CTOOLS) $(OBJS_MD)

LIB_FILE_EXT = so
LIBDSSOPT = libdssopt.$(LIB_FILE_EXT)
ALLOBJS_SRC := $(subst .o,.c, $(ALLOBJS))

all: $(ALLPROGS)

lib: $(LIBDSSOPT)

clean:
rm -f $(ALLPROGS) $(ALLOBJS)
rm -f $(ALLPROGS) $(ALLOBJS) $(LIBDSSOPT)

$(PROGS_MISC): %: main-%.c $(OBJS_COMMON)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
Expand All @@ -35,3 +41,6 @@ $(PROGS_OPT): %: main-%.c $(OBJS_COMMON) $(OBJS_OPT)

$(PROGS_GSL): %: main-%.c $(OBJS_COMMON) $(OBJS_OPT)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS_GSL)

$(LIBDSSOPT): $(ALLOBJS_SRC)
$(CC) -shared -fPIC $(CFLAGS) $^ -o $@ $(LDFLAGS)

0 comments on commit cb69a3b

Please sign in to comment.