-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
41 lines (30 loc) · 818 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
#project name
target := algoMusic
#directories
buildDir := ./build
sourceDir := ./src
#compiler stuff
CC := clang
CFLAGS := -Wall -g
libFlags := -lm -lportaudio
#make file instructions ahead, generaly don't touch
#file finding stuffs
cFiles := $(wildcard $(sourceDir)/*/*.c) $(wildcard $(sourceDir)/*.c) $(wildcard $(sourceDir)/*/*/*.c)
OBJ := $(patsubst $(sourceDir)/%.c, $(buildDir)/%.o, $(cFiles))
#make obj files in build from c files in src
$(buildDir)/%.o: ./$(sourceDir)/%.c ./$(sourceDir)/%.h
mkdir -p $(@D)
$(CC) -c -o $@ $< $(CFLAGS)
#build the main program out of the obj files in build
$(target): ${OBJ}
$(CC) -o $(target) $(OBJ) $(CFLAGS) $(libFlags)
#usefull stuffs
.PHONY: all run clean test
test:
echo $(OBJ)
all: $(target)
run: all
./$(target)
clean:
rm -rf $(buildDir)
rm $(target)