Split Makefile-SIM out from Makefile-AVR.
Also, some makefile cleanup: - Remove obsolete 'depend' target. - Move AVR-specific targets to AVR makefile. - Add TARGET variable to identify target to make and to clean. - Tidy up dependency make.
This commit is contained in:
parent
18ea439788
commit
d8f61faaac
39
Makefile-AVR
39
Makefile-AVR
|
|
@ -101,6 +101,9 @@ UPLOADER_FLAGS += -P /dev/ttyUSB0
|
|||
|
||||
PROGRAM = teacup
|
||||
|
||||
# The thing we build by default, and also the thing we clean.
|
||||
TARGET = $(PROGRAM).hex
|
||||
|
||||
# Arduino IDE takes the "compile everything available"-approach, so we have
|
||||
# to keep this working and can take a shortcut:
|
||||
SOURCES = $(wildcard *.c)
|
||||
|
|
@ -128,12 +131,16 @@ LDFLAGS += -Wl,--gc-sections
|
|||
|
||||
LIBS = -lm
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
||||
|
||||
-include Makefile-common
|
||||
|
||||
# Architecture specific targets
|
||||
|
||||
.PHONY: program size
|
||||
|
||||
all: $(PROGRAM).hex $(BUILDDIR)/$(PROGRAM).lst $(BUILDDIR)/$(PROGRAM).sym size
|
||||
|
||||
program: $(PROGRAM).hex config.h
|
||||
$(UPLOADER) $(UPLOADER_FLAGS) -U flash:w:$(PROGRAM).hex
|
||||
|
||||
|
|
@ -142,35 +149,3 @@ size: $(BUILDDIR)/$(PROGRAM).elf
|
|||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(text)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " FLASH : %5d bytes %3d%% %3d%% %3d%% %3d%%\n", $$a, ceil($$a * 100 / (14 * 1024)), ceil($$a * 100 / (30 * 1024)),ceil($$a * 100 / (62 * 1024)), ceil($$a * 100 / (126 * 1024)) }'
|
||||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(data|bss)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " RAM : %5d bytes %3d%% %3d%% %3d%% %3d%%\n", $$a, ceil($$a * 100 / (1 * 1024)), ceil($$a * 100 / (2 * 1024)),ceil($$a * 100 / (4 * 1024)), ceil($$a * 100 / (8 * 1024)) }'
|
||||
@$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(eeprom)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " EEPROM: %5d bytes %3d%% %3d%% %3d%% %3d%%\n", $$a, ceil($$a * 100 / (1 * 1024)), ceil($$a * 100 / (2 * 1024)), ceil($$a * 100 / (2 * 1024)), ceil($$a * 100 / (4 * 1024)) }'
|
||||
|
||||
|
||||
##############################################################################
|
||||
# #
|
||||
# Simulator #
|
||||
# #
|
||||
##############################################################################
|
||||
|
||||
SIM_PATH = simulator
|
||||
SIM_SOURCES := $(subst $(SIM_PATH)/,,$(wildcard $(SIM_PATH)/*.c))
|
||||
SIM_SOURCES += $(filter-out $(subst _sim.c,.c,$(SIM_SOURCES)),$(SOURCES))
|
||||
SIM_HEADERS = config.h serial.h dda.h timer.h clock.h temp.h sermsg.h
|
||||
SIM_HEADERS += dda_queue.h debug.h sersendf.h heater.h analog.h delay.h
|
||||
SIM_HEADERS += simulator.h
|
||||
|
||||
SIM_OBJ = $(patsubst %.c,$(BUILDDIR)/%.sim.o,$(SIM_SOURCES))
|
||||
SIM_CFLAGS = -g -Wall -Wstrict-prototypes -Wno-format -Os $(DEFS) -std=gnu99
|
||||
SIM_CFLAGS += -funsigned-char -funsigned-bitfields -fshort-enums -I.. -I.
|
||||
|
||||
# Satisfy all current config chip targets
|
||||
SIM_CFLAGS += -DSIMULATOR -D__AVR_ATmega644P__ -D__AVR_ATmega1280__
|
||||
SIM_CFLAGS +=-D__AVR_ATmega2560__ -D__AVR_ATmega32U4__ -D__AVR_AT90USB1286__
|
||||
|
||||
$(BUILDDIR)/%.sim.o: %.c $(SIM_HEADERS)
|
||||
@echo " CC $@"
|
||||
@cc -DDEBUG -c $(SIM_CFLAGS) -o $@ $<
|
||||
|
||||
sim: $(SIM_OBJ)
|
||||
@echo " LINK $@"
|
||||
@cc $(SIM_CFLAGS) -o $@ $^
|
||||
|
||||
vpath %.c $(SIM_PATH)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
##############################################################################
|
||||
# #
|
||||
# Teacup - Lean and efficient firmware for RepRap printers #
|
||||
# #
|
||||
# by Triffid Hunter, Traumflug, jakepoz, Markus Hitter, many others #
|
||||
# #
|
||||
# This firmware is Copyright (c) ... #
|
||||
# 2009 - 2010 Michael Moon aka Triffid_Hunter #
|
||||
# 2010 - 2013 Markus "Traumflug" Hitter <mah@jump-ing.de> #
|
||||
# #
|
||||
# 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 2 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
|
||||
# #
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# #
|
||||
# Makefile for PC-Based simulator #
|
||||
# #
|
||||
# make -f Makefile-SIM #
|
||||
# #
|
||||
##############################################################################
|
||||
|
||||
TARGET = sim
|
||||
|
||||
SIM_PATH = simulator
|
||||
|
||||
# Arduino IDE takes the "compile everything available"-approach, so we have
|
||||
# to keep this working and can take a shortcut:
|
||||
SOURCES = $(wildcard *.c)
|
||||
|
||||
SIM_SOURCES = $(subst $(SIM_PATH)/,,$(wildcard $(SIM_PATH)/*.c))
|
||||
SOURCES := $(filter-out $(subst _sim.c,.c,$(SIM_SOURCES)),$(SOURCES)) $(SIM_SOURCES)
|
||||
HEADERS = config.h serial.h dda.h timer.h clock.h temp.h sermsg.h
|
||||
HEADERS += dda_queue.h debug.h sersendf.h heater.h analog.h delay.h
|
||||
HEADERS += simulator.h
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.sim.o,$(SOURCES))
|
||||
CFLAGS = -g -Wall -Wstrict-prototypes -Wno-format -Os $(DEFS) -std=gnu99
|
||||
CFLAGS += -funsigned-char -funsigned-bitfields -fshort-enums -I.. -I.
|
||||
CFLAGS += -DSIMULATOR
|
||||
|
||||
# Satisfy all current config chip targets
|
||||
CFLAGS += -D__AVR_ATmega644__ -D__AVR_ATmega644A__ -D__AVR_ATmega644P__
|
||||
CFLAGS += -D__AVR_ATmega2560__ -D__AVR_ATmega32U4__ -D__AVR_AT90USB1286__
|
||||
CFLAGS += -D__AVR_ATmega1280__
|
||||
|
||||
include Makefile-common
|
||||
|
||||
$(BUILDDIR)/%.sim.o: %.c $(HEADERS)
|
||||
@echo " CC $@"
|
||||
@cc -c $(CFLAGS) -o $@ $<
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
@echo " LINK $@"
|
||||
@cc $(CFLAGS) -o $@ $^
|
||||
|
||||
vpath %.c $(SIM_PATH)
|
||||
|
|
@ -36,21 +36,18 @@ DEPEND = $(BUILDDIR)/depend
|
|||
|
||||
CFLAGS += -save-temps=obj
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
||||
|
||||
CC = $(TOOLCHAIN)gcc
|
||||
OBJDUMP = $(TOOLCHAIN)objdump
|
||||
OBJCOPY = $(TOOLCHAIN)objcopy
|
||||
|
||||
|
||||
.PHONY: all clean doc functionsbysize depend
|
||||
.PHONY: all clean doc functionsbysize
|
||||
.PRECIOUS: %.o %.elf
|
||||
|
||||
all: config.h $(BUILDDIR)
|
||||
all: $(PROGRAM).hex $(BUILDDIR)/$(PROGRAM).lst $(BUILDDIR)/$(PROGRAM).sym size
|
||||
all: config.h $(BUILDDIR) $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR) *.hex *~
|
||||
rm -rf $(BUILDDIR) $(TARGET) *~
|
||||
|
||||
config.h: config.default.h
|
||||
@echo "config.default.h is more recent than config.h. You likely want to"
|
||||
|
|
@ -69,9 +66,10 @@ $(BUILDDIR):
|
|||
mkdir $(BUILDDIR)
|
||||
|
||||
$(DEPEND): $(SOURCES)
|
||||
rm -f $(DEPEND)
|
||||
mkdir -p $(BUILDDIR)
|
||||
$(CC) $(CFLAGS) -MM $^ > $(DEPEND)
|
||||
@echo " DEP $@"
|
||||
@rm -f $(DEPEND)
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) $(CFLAGS) -MM $^ > $@
|
||||
|
||||
# pull in dependency info
|
||||
-include $(DEPEND)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
To compile the simulation code, use
|
||||
|
||||
$ make -f Makefile-AVR sim
|
||||
$ make -f Makefile-SIM
|
||||
|
||||
The simulator will open a serial port for communication. If you don't want to
|
||||
connect a null modem cable, you can use 'socat' to connect two serial ports:
|
||||
|
|
|
|||
Loading…
Reference in New Issue