-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
36 lines (26 loc) · 935 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
# Define compiler
CC = gcc
# Compiler flags
CFLAGS = -Wall -Iinclude
# Define the source directory, object directory inside build, and target binary directory
SRCDIR = src
BUILDDIR = build
OBJDIR = $(BUILDDIR)/object
# Define the C source files (wildcard picks all .c files in the directory)
SOURCES = $(wildcard $(SRCDIR)/*.c)
# Define the C object files (placing them in the OBJDIR directory)
OBJECTS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SOURCES))
# Define the executable file name, reflecting the repo name
TARGET = $(BUILDDIR)/processes-n-pipes
all: build $(TARGET)
# Rule for making the necessary directories
build:
@mkdir -p $(BUILDDIR) $(OBJDIR)
# Rule for linking the program
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^
# Rule for compiling the source files to object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJDIR)/*.o $(TARGET)