c-multihash/Makefile

58 lines
955 B
Makefile
Raw Normal View History

2016-07-25 10:51:54 +00:00
CC = gcc
RM = rm -f
CFLAGS = -fPIC -g -O2 -std=c99 \
-Wall -Wextra -pedantic -Werror \
-Wdeclaration-after-statement \
-Wno-format-zero-length \
-Wold-style-definition \
-Woverflow \
-Wpointer-arith \
-Wunused \
-Wvla
2016-07-25 15:18:34 +00:00
LDFLAGS = -g
2016-07-25 10:51:54 +00:00
LDLIBS =
TARGET_LIB = mulithash.so
SRCS = errors.c
2016-07-25 15:18:34 +00:00
OBJS = $(SRCS:.c=.o)
2016-07-25 10:51:54 +00:00
all: ${TARGET_LIB}
$(TARGET_LIB): $(OBJS)
2016-07-25 15:18:34 +00:00
$(CC) -g -shared -o $@ $^
2016-07-25 10:51:54 +00:00
2016-07-25 15:18:34 +00:00
# Tests
2016-07-25 10:51:54 +00:00
2016-07-25 15:18:34 +00:00
TEST_SRCS = $(wildcard test/test_*.c)
TEST_OBJS = $(TEST_SRCS:.c=.o)
TEST_BINS = $(TEST_OBJS:.o=.out)
PHONY += tests
tests: $(TEST_BINS)
@for t in $^; do \
echo; \
echo '***' "$$t" '***'; \
LD_LIBRARY_PATH=. "./$$t"; \
echo; \
done
test/test_%.out: test/test_%.o $(TARGET_LIB)
$(CC) $(LDFLAGS) $(TARGET_LIB) $^ -o $@
# Utils
PHONY += clean dist-clean
2016-07-25 10:51:54 +00:00
clean:
$(RM) $(OBJS)
2016-07-25 15:18:34 +00:00
$(RM) $(TEST_OBJS)
$(RM) $(TEST_BINS)
2016-07-25 10:51:54 +00:00
$(RM) $(TARGET_LIB)
dist-clean: clean
2016-07-25 15:18:34 +00:00
.PHONY: $(PHONY)