-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (40 loc) · 1.38 KB
/
Makefile
File metadata and controls
49 lines (40 loc) · 1.38 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
43
44
45
46
47
48
49
# disable implicit rules
.SUFFIXES:
HDRDIR := include
SRCDIR := src
BLDDIR := build
OBJDIR := $(BLDDIR)/obj
CC := clang
CFLAGS := -Wextra -Wall -pedantic -std=c11
LFLAGS :=
ifeq ($(DEV), 1)
CFLAGS += -O0 -g3 -fstack-protector-all -Wshadow -Wunreachable-code \
-Wstack-protector -W -Werror -pedantic-errors -Wundef \
-Wfatal-errors -Wstrict-prototypes -Wmissing-prototypes \
-Wwrite-strings -Wunknown-pragmas -Wstrict-aliasing \
-Wold-style-definition -Wmissing-field-initializers \
-Wfloat-equal -Wpointer-arith -Wnested-externs \
-Wstrict-overflow=5 -Wswitch-default -Wswitch-enum \
-Wbad-function-cast -Wredundant-decls -Winline \
-fno-omit-frame-pointer -fstrict-aliasing \
-Wincompatible-pointer-types
else
CC := gcc
CFLAGS += -O3
endif
SRCS := $(shell find $(SRCDIR) -name *.c | grep -v "$(SRCDIR)/bin")
OBJS := $(SRCS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
all: blddirs $(BLDDIR)/sandmac
$(BLDDIR)/sandmac: $(SRCDIR)/bin/sandmac.c $(OBJS)
@echo "building"
@$(CC) $(CFLAGS) $(LFLAGS) $^ -I$(HDRDIR) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(HDRDIR)/%.h
@echo "compiling $*"
@$(CC) -c $(CFLAGS) $< -I$(HDRDIR) -o $@
SRCDIRS := $(shell find $(SRCDIR) -type d | grep -v "$(SRCDIR)/bin")
BLDDIRS := $(SRCDIRS:$(SRCDIR)%=$(OBJDIR)%)
blddirs:
mkdir -p $(BLDDIRS)
.PHONY: clean
clean:
rm -rf $(BLDDIR)