-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (40 loc) · 1.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CC=gcc
CFLAGS=-Wall -Wno-implicit-fallthrough -Wextra -Werror -std=c11 -O3
PREFIX ?= /usr/local
SRC=src/siphash.c src/map.c src/hashmap.c
OBJS=siphash.o map.o hashmap.o
TARGET=libhashmap.a
TEST_SRC=test/test_siphash.c test/test_random.c test/test_map.c test/test_hashmap.c test/test_main.c
TEST_OBJS=test_siphash.o test_random.o test_map.o test_hashmap.o test_main.o
TEST_TARGET=hashmap_test
.PHONY:all clean test install uninstall help
all: $(TARGET) clean
$(OBJS): $(SRC)
$(CC) $(CFLAGS) -c -Isrc/ -Iinclude/ $(SRC)
$(TEST_OBJS): $(TEST_SRC)
$(CC) $(CFLAGS) -c -Isrc/ -Iinclude/ $(TEST_SRC)
$(TEST_TARGET): $(OBJS) $(TEST_OBJS)
$(CC) -o $(TEST_TARGET) $(OBJS) $(TEST_OBJS)
$(TARGET): $(OBJS)
ar rcs $(TARGET) $(OBJS)
test: $(TEST_TARGET) clean
./$(TEST_TARGET)
install: $(TARGET)
install -d $(PREFIX)/lib/
install $(TARGET) $(PREFIX)/lib/
install -d $(PREFIX)/include/hashmap/
install include/hashmap.h $(PREFIX)/include/hashmap/
rm -f $(OBJS) $(TARGET)
uninstall:
rm -f $(PREFIX)/lib/$(TARGET)
rm -rf $(PREFIX)/include/hashmap/
clean:
rm -f $(OBJS) $(TEST_OBJS)
help:
@echo "Available targets:\n"
@echo "all - Build the library"
@echo "test - Build and run tests"
@echo "install - Install the library and header files to system directories specified by PREFIX"
@echo "uninstall - Remove files installed by the 'install' target"
@echo "clean - Remove all object files"
@echo "help - Display this help message"