Skip to content

Commit

Permalink
[~] compiling the lib to both shared object and archive files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ximaz committed Mar 28, 2024
1 parent bde15d3 commit ef7b00f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
##

CC := gcc
NAME := liblist.so
CPPFLAGS := -Iinclude/

SRCS := $(shell find src -name '*.c')
Expand All @@ -30,11 +29,15 @@ RM := rm -rf
tests/%.o: tests/%.c
$(CC) $(TESTS_CFLAGS) $(CPPFLAGS) -o $@ -c $<

all: $(NAME)
all: liblist.so liblist.a

$(NAME): CFLAGS = -Wall -Wextra -Werror -pedantic -ansi -fPIC
$(NAME): clean $(OBJS)
$(CC) -shared -fPIC $(OBJS) -o $(NAME)
liblist.so: CFLAGS = -Wall -Wextra -Werror -pedantic -ansi -fPIC
liblist.so: clean $(OBJS)
$(CC) -shared -fPIC $(OBJS) -o $@

liblist.a: CFLAGS = -Wall -Wextra -Werror -pedantic -ansi -fPIC
liblist.a: clean $(OBJS)
ar -rcs $@ $(OBJS)

tests_run: CFLAGS = -g -Wall -Wextra -Werror -pedantic -ansi --coverage
tests_run: clean $(OBJS) $(TESTS_OBJS)
Expand All @@ -52,7 +55,7 @@ clean:
$(RM) $(shell find . -type f -name '*.gcda')

fclean: clean
$(RM) $(NAME)
$(RM) liblist.so liblist.a
$(RM) unit_tests

re: fclean all

0 comments on commit ef7b00f

Please sign in to comment.