-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 1.36 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
55
56
57
58
59
60
61
62
63
# Compiler
CC = gcc
# Compiler flags
CPPFLAGS += -Ihtslib/ -Iinclude/
CFLAGS = -g -Wall -O2 -std=c99
LDFLAGS += $(LIBS) -lz -lm -lpthread
# Source files
SRCS = src/error.c src/main.c src/misc_p.c src/misc.c src/mod.c src/thread.c src/minimod.c src/ref.c src/server.c
# Object files directory
BUILD_DIR = build
# Object files
OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(SRCS:.c=.o)))
# Executable name
BINARY = realfreq
# Phony targets
.PHONY: all clean
# Default target
all: $(BINARY)
# Address sanitizer
ifdef asan
CFLAGS += -fsanitize=address -fno-omit-frame-pointer
LDFLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
# Compile source files into object files
$(BUILD_DIR)/%.o: src/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Link object files into the executable
$(BINARY): $(OBJS) htslib/libhts.a
$(CC) $(CFLAGS) $(OBJS) htslib/libhts.a $(LDFLAGS) -o $@
# Check if htslib is installed
htslib/libhts.a:
@if test -e $(BUILD_DIR)/lib/libhts.a; then \
echo "htslib found at htslib/libhts.a"; \
else \
echo "htslib not found at htslib/libhts.a"; \
echo "Please run 'scripts/install-hts.sh' first"; \
exit 1; \
fi
# Clean up intermediate and executable files
clean:
rm -f $(OBJS) $(BINARY)
# Run tests
test: $(BINARY)
./test/test.sh
memtest: $(BINARY)
./test/test.sh mem
# Create build directory if it doesn't exist
$(shell mkdir -p $(BUILD_DIR))