forked from nullsub/laser_grbl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (112 loc) · 3.37 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
#####
# Stephen Caudle, Copyright (C) 2010.
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#####
# adjusted by chrisu_de for various projects.
#
#change your device:
# avr
# freertos_lpc17
# stm32l
# simulator
ifeq ($(ARCH),)
#ARCH = stm32l
#ARCH = mbed_lpc17
#ARCH = avr
#ARCH = simulator
ARCH = rx62n
endif
DEVICE_DIR = arch/$(ARCH)
-include $(DEVICE_DIR)/Makefile
# Directory for output files (lst, obj, dep, elf, map, hex, bin etc.)
OUTDIR = build
# Target file name (without extension).
TARGET = grbl-$(ARCH)
# Source files:
SRC += main.c
SRC += gcode.c
SRC += planner.c
SRC += sense_control.c
SRC += print.c
#include device specific files
SRC += $(patsubst %,$(DEVICE_DIR)/%,$(DEV_SRC))
# List any extra directories to look for include files here.
INCDIRS += $(DEVICE_DIR)
INCDIRS += $(patsubst %,$(DEVICE_DIR)/%,$(DEV_INC))
CFLAGS += $(patsubst %,-I%,$(INCDIRS)) -I.
CFLAGS += -std=gnu99
CFLAGS += -Wall
# Define programs and commands.
CC = $(TCHAIN_PREFIX)gcc
AR = $(TCHAIN_PREFIX)ar
OBJCOPY = $(TCHAIN_PREFIX)objcopy
OBJDUMP = $(TCHAIN_PREFIX)objdump
SIZE = $(TCHAIN_PREFIX)size
NM = $(TCHAIN_PREFIX)nm
GDB = $(TCHAIN_PREFIX)gdb
REMOVE = rm -rf
# List of all source files without directory and file-extension.
ALLSRCBASE = $(notdir $(basename $(SRC)))
# Define all object files.
ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
default: all
# Default target.
all: $(OUTDIR)/$(TARGET).elf
# Program the device.
flash: $(OUTDIR)/$(TARGET).elf
@echo "Flashing to device"
$(FLASH_COMMAND)
# Link: create ELF output file from object files.
.SECONDARY : $(OUTDIR)/$(TARGET).elf
.PRECIOUS : $(ALLOBJ)
$(OUTDIR)/$(TARGET).elf: $(ALLOBJ)
@echo
@echo "**** Linking :" $@
@$(LINK_COMMAND)
NO_OP = arch/stm32l/stm32/Libraries/CMSIS/CM3/CoreSupport/core_cm3.c #buggy toolchain breaks if this file is optimized!
# Compile: create object files from C source files.
define COMPILE_C_SOURCE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo
@echo "**** Compiling :" $$< "->" $$@
@if [ "$$<" = $(NO_OP) ]; then echo "No optimization" && $(CC) -c $$(CFLAGS) -O0 $$< -o $$@; else $(CC) -c $$(CFLAGS) $$< -o $$@; fi
endef
$(foreach src, $(SRC), $(eval $(call COMPILE_C_SOURCE, $(src))))
# Target: clean project.
clean:
@echo "cleaned build"
@$(REMOVE) $(OUTDIR)
test:
@echo "STM32:"
@make clean
@make ARCH=stm32l
@echo "Compiling mbed_lpc17"
@make clean
@make ARCH=mbed_lpc17
@echo "Compiling avr:"
@make clean
@make ARCH=avr
@echo "Compiling simulator"
@make clean
@make ARCH=simulator
@echo "Compiling rx62n"
@make clean
@make ARCH=rx62n
# Create output files directory
$(shell mkdir -p $(OUTDIR))
# Listing of phony targets.
.PHONY: all build lss clean program flash