-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
42 lines (33 loc) · 1.1 KB
/
Copy pathmakefile
File metadata and controls
42 lines (33 loc) · 1.1 KB
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
# Main makefile
CC := gcc
SRCDIR := src
BUILDDIR := build
TESTDIR := test
TARGET := convert
TEST_TARGET := convert_tests
SOURCES := $(shell find $(SRCDIR) -type f -name *.c)
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.c=.o))
TEST_SOURCES := $(shell find $(TESTDIR) -type f -name *.c)
TEST_OBJECTS := $(patsubst $(TESTDIR)/%,$(BUILDDIR)/%,$(TEST_SOURCES:.c=.o))
TEST_OBJECTS += $(OBJECTS)
TEST_OBJECTS := $(filter-out build/main.o, $(TEST_OBJECTS))
CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wstrict-overflow\
-fstack-protector -O2
LIBS := -lcheck -lm -lsubunit -lrt -lpthread
INC := -I include
all: convert tests
convert: $(TARGET)
tests: $(TEST_TARGET)
$(TARGET): $(OBJECTS)
$(CC) $^ -o $(TARGET) $(INC) $(CFLAGS) $(LIBS)
$(TEST_TARGET): $(TEST_OBJECTS)
$(CC) $^ -o $(TEST_TARGET) $(INC) $(CFLAGS) $(LIBS)
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
mkdir -p $(BUILDDIR)
$(CC) -c -o $@ $< $(INC) $(CFLAGS) $(LIBS)
$(BUILDDIR)/%.o: $(TESTDIR)/%.c
mkdir -p $(BUILDDIR)
$(CC) -c -o $@ $< $(INC) $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
-@rm -rf $(BUILDDIR) $(TEST_TARGET) $(TARGET)