-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·140 lines (111 loc) · 3.85 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#----------------------------------------------------------------------------
#
# Target file name (without extension).
TARGET = spiromorph
# List C source files here. (C dependencies are automatically generated.)
# To exclude certain files in a folder remove the $(wildcard) and
# list them seperated by spaces, ie src/main.c src/util.c
SRC = $(wildcard *.c)
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.
EXTRAINCDIRS = .
# Object and list files directory
# To put .o and .lst files alongside .c files use a dot (.), do NOT make
# this an empty or blank macro!
# If source files are in sub directories, matching subdirectories must exist under this folder for the .o files
# This is a pain, if you can fix this, please do and share.
OBJLSTDIR = obj
# Compiler flag to set the C Standard level.
# c89 = "ANSI" C
# gnu89 = c89 plus GCC extensions
# c99 = ISO C99 standard (not yet fully implemented)
# gnu99 = c99 plus GCC extensions
CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
CDEFS = -DPLATFORM_PC
#---------------- Compiler Options C ----------------
# -g debug information
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
CFLAGS += $(CDEFS)
CFLAGS += -Wall
CFLAGS += -Wno-unused-function
CFLAGS += -Wno-unused-but-set-variable
CFLAGS += -Wno-switch
CFLAGS += $(CSTANDARD)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += `sdl2-config --cflags`
# List any extra directories to look for libraries here.
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.
EXTRALIBDIRS = .
EXTRALIBS = `sdl2-config --libs` -lm
#---------------- Linker Options ----------------
LDFLAGS = $(patsubst %,-L%,$(EXTRALIBDIRS))
LDFLAGS += $(EXTRALIBS)
#============================================================================
# Define programs and commands.
SHELL = sh
CC = gcc
REMOVE = rm -f
REMOVEDIR = rm -rf
COPY = cp
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_LINKING = Linking:
MSG_COMPILING = Compiling C:
MSG_CLEANING = Cleaning project:
# Define all object files.
OBJ = $(SRC:%.c=$(OBJLSTDIR)/%.o)
# Compiler flags to generate dependency files.
GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -I. $(CFLAGS) $(GENDEPFLAGS)
# Default target.
all: begin gccversion build end
build: tgt
tgt: $(TARGET)
# Eye candy.
# the following magic strings to be generated by the compile job.
begin:
@echo
@echo $(MSG_BEGIN)
end:
@echo $(MSG_END)
@echo
# Display compiler version information.
gccversion :
@$(CC) --version
# Link: create output file from object files.
.SECONDARY : $(TARGET)
.PRECIOUS : $(OBJ)
$(TARGET): $(OBJ)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
# Compile: create object files from C source files.
$(OBJLSTDIR)/%.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(ALL_CFLAGS) $< -o $@
# Target: clean project.
clean: begin clean_list end
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(SRC:%.c=$(OBJLSTDIR)/%.o)
$(REMOVE) $(SRC:%.c=$(OBJLSTDIR)/%.lst)
$(REMOVEDIR) .dep
# Create object files directory
$(shell mkdir $(OBJLSTDIR) 2>/dev/null)
# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# Listing of phony targets.
.PHONY : all begin end gccversion build tgt clean clean_list