-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (31 loc) · 1015 Bytes
/
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
CC := gcc
CFLAGS := -O3 -pedantic-errors -std=c17
CFLAGS_DEBUG := -Og -g -fsanitize=address -std=c17 -pedantic-errors -Wall
DEPS := main huffman bitHandler
BUILDDIR := build/
SRCDIR := src/
BINDIR := /usr/local/bin/
TARGET := huffman
TARGET_DEBUG := $(TARGET)
OBJS := $(addprefix $(BUILDDIR), $(addsuffix .o, $(DEPS)))
OBJS_DEBUG := $(addprefix $(BUILDDIR)DEBUG_, $(addsuffix .o, $(DEPS)))
SOURCE := $(addprefix $(SRCDIR), $(addsuffix .c, $(DEPS)))
default: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET)
# Debug is noticeably slower
debug: $(OBJS_DEBUG)
$(CC) $(CFLAGS_DEBUG) $(OBJS_DEBUG) -o $(TARGET_DEBUG)
clean:
rm -rf $(BUILDDIR) $(TARGET_DEBUG)
# Most likely needs admin rights
install: default
install -m 755 $(TARGET) $(BINDIR)$(TARGET)
uninstall:
rm -f $(BINDIR)$(TARGET)
$(BUILDDIR)%.o: $(SRCDIR)%.c
@mkdir -p $(BUILDDIR)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)DEBUG_%.o: $(SRCDIR)%.c
@mkdir -p $(BUILDDIR)
$(CC) $(CFLAGS_DEBUG) -c $< -o $@
.PHONY: default debug clean install uninstall