-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
32 lines (25 loc) · 910 Bytes
/
makefile
File metadata and controls
32 lines (25 loc) · 910 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
# more info on makefiles
# http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
CC := gcc
CFLAGS := -std=gnu99 -Wall -Wextra
# c99 standar, show a lot of warnings
SRCDIR := src
BUILDDIR := build
SRCEXT := c # change to cc or cpp in a c++ project
TARGET := bin/sfs
SOURCES := $(shell find $(SRCDIR) -type f -name *.c)
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.c=.o))
INC := -I $(SRCDIR)
LIB := -pthread -lrt -lz
$(TARGET): $(OBJECTS)
@mkdir -p bin
@echo " Link libraries..."
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB)
# $@ files named on the left side, $< is the first dependency
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
clean:
@echo " Doing some cleanup..."
@echo " rm -r $(BUILDDIR) $(TARGET)"; rm -r $(BUILDDIR) $(TARGET)
.PHONY: clean