forked from mikehow1984/Arduino_SMB_Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (46 loc) · 1 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# My third makefile
# Name of the project
PROJ_NAME=main
# .c files
C_LIB=$(wildcard ./lib/*.c)
# .h files
H_LIB=$(wildcard ./lib/*.h)
# Object files
OBJ=$(subst .c,.o,$(subst lib,objects,$(C_LIB)))
# Compiler and linker
CC=gcc
# Flags for compiler
CC_FLAGS=-c \
-W \
-Wall \
-ansi \
-pedantic
ifeq ($(OS),Windows_NT)
RM = rd /s /q
else
# Command used at clean target
RM = rm -rf
endif
#
# Compilation and linking
#
all: objFolder $(PROJ_NAME)
$(PROJ_NAME): $(OBJ) ./objects/main.o
@ echo 'Building binary using GCC linker: $@'
$(CC) $^ -o $@
@ echo 'Finished building binary: $@'
@ echo ' '
./objects/%.o: ./lib/%.c ./lib/%.h
@ echo 'Building target using GCC compiler: $<'
$(CC) $< $(CC_FLAGS) -o $@
@ echo ' '
./objects/main.o: ./mario_song.c $(H_LIB)
@ echo 'Building target using GCC compiler: $<'
$(CC) $< $(CC_FLAGS) -o $@
@ echo ' '
objFolder:
@ mkdir -p objects
clean:
@ $(RM) ./objects/*.o
@ rmdir ./objects
.PHONY: all clean