-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
52 lines (40 loc) · 863 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
42
43
44
45
46
47
48
49
50
51
52
TARGET = HashCodeTest
CC = gcc
IDIR = deps
ODIR = obj
LDIR = headers
SDIR = src
OUTD = bin
LIBS = -lm
CFLAGS = -pthread -I$(IDIR) -I$(LDIR) -std=iso9899:2018 -Wall -Wextra -Werror -pedantic-errors -m64
ifneq (a,$(shell echo "a"))
RM = del /F /Q
MKDIR_P = mkdir
BAR = \\
EXT = .exe
else
RM = rm -f
MKDIR_P = mkdir -p
BAR = /
EXT =
$(info $(BAR))
endif
.PHONY: clean all default directories
default: $(TARGET)
all: directories default
directories:
$(MKDIR_P) $(ODIR)
$(MKDIR_P) $(OUTD)
_DEPS = $(wildcard $(LDIR)/*.h)
DEPS = $(patsubst %,%,$(_DEPS))
_OBJ = $(wildcard $(SDIR)/*.c)
OBJ = $(patsubst $(SDIR)/%.c, $(ODIR)/%.o,$(_OBJ))
$(ODIR)/%.o: $(SDIR)/%.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJ)
$(CC) -o $(OUTD)/$@$(EXT) $^ $(CFLAGS) $(LIBS)
clean:
$(RM) $(ODIR)$(BAR)*.o
$(RM) $(OUTD)$(BAR)*
run:
$(OUTD)/$(TARGET)$(EXT) $(ARGS)