-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
47 lines (35 loc) · 915 Bytes
/
makefile
File metadata and controls
47 lines (35 loc) · 915 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
36
37
38
39
40
41
42
43
44
45
46
47
# Name of the project
PROJ_NAME=MySearch
# .c files
C_SOURCE=$(wildcard ./source/*.c)
# .h files
H_SOURCE=$(wildcard ./source/*.h)
# .o files
OBJ=$(subst .c,.o,$(subst source,objects,$(C_SOURCE)))
# Compiler and Linker
CC = gcc
# Flags for compiler
CC_FLAGS = -c -Wall
# Compilation and Linking
all: objFolder $(PROJ_NAME)
$(PROJ_NAME): $(OBJ)
@ echo -ne 'Building binary using GCC linker: $@...'
@ $(CC) $^ -o $@
@ echo ' Done!'
@ echo ' '
./objects/%.o: ./source/%.c ./source/%.h
@ echo -ne 'Building target using GCC compiler: $<...'
@ $(CC) $< $(CC_FLAGS) -o $@
@ echo ' Done!'
./objects/main.o: ./source/main.c $(H_SOURCE)
@ echo -ne 'Building target using GCC compiler: $<...'
@ $(CC) $< $(CC_FLAGS) -o $@
@ echo ' Done!'
objFolder:
@ mkdir -p objects
clean:
@ echo -ne 'Cleanning project...'
@ rm -rf ./objects/*.o $(PROJ_NAME) *~
@ rmdir objects
@ echo ' Done!'
.PHONY: all clean