-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (26 loc) · 695 Bytes
/
Copy pathMakefile
File metadata and controls
35 lines (26 loc) · 695 Bytes
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
CC := gcc
CFLAGS := -Wall
SRCDIR := src
BUILDDIR := build
INCDIR := include
EXAMPLEDIR := examples
TARGETDIR := build/target
SRC := $(shell find $(SRCDIR) -type f -name *.c)
OBJECTS := $(foreach file, $(SRC:.c=.o), $(subst $(shell echo $(SRCDIR)),$(shell echo $(BUILDDIR)),$(file)))
INC := -I$(INCDIR)
example: $(TARGETDIR)/example
@echo "Example was built"
@echo "./build/target/example"
$(TARGETDIR)/example: $(EXAMPLEDIR)/main.c $(OBJECTS)
$(CC) $(CFLAGS) $(INC) -o $@ $^
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
.PHONY: $(BUILDDIR)
$(BUILDDIR):
mkdir $@
.PHONY: $(TARGETDIR)
$(TARGETDIR):
mkdir -p $@
.PHONY: clean
clean:
$(RM) -r build