-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (28 loc) · 724 Bytes
/
Copy pathMakefile
File metadata and controls
35 lines (28 loc) · 724 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
#Program path configuration
OUTDIR := bin
SRCDIR := src
INCDIR := include
OBJDIR := obj
OUTBIN := $(OUTDIR)/server
#Compiler path configuration
CC := gcc
#Compiler flags
includes = -I$(INCDIR) -I$(SRCDIR)
flags = $(includes)
cflags = $(flags) -O3
lflags = $(flags)
#Files to compile from/to
c_files = $(wildcard $(SRCDIR)/*.c)
#Target object files to link
o_files = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(notdir $(c_files))))
#Main target, the output executable
$(OUTBIN): $(o_files)
$(CC) $(lflags) $^ -o $@
#Look into src folder for .c files to make corresponding .o files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(cflags) -c $< -o $@
all: $(OUTBIN)
default: all
clean:
rm -f $(OUTBIN)
rm -f $(OBJDIR)/*.o