2008-12-03 13:22:20 +00:00
|
|
|
TARGET := image
|
|
|
|
TARGET_SIM := borgsim
|
2014-03-18 06:00:13 +00:00
|
|
|
TOPDIR = src
|
|
|
|
MAKETOPDIR = .
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
SRC = \
|
2014-03-18 06:00:13 +00:00
|
|
|
$(TOPDIR)/main.c \
|
|
|
|
$(TOPDIR)/display_loop.c \
|
|
|
|
$(TOPDIR)/eeprom_reserve.c \
|
|
|
|
$(TOPDIR)/pixel.c \
|
|
|
|
$(TOPDIR)/util.c \
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
SRC_SIM = \
|
2014-03-18 06:00:13 +00:00
|
|
|
$(TOPDIR)/display_loop.c \
|
|
|
|
$(TOPDIR)/pixel.c \
|
2008-12-04 03:34:55 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
LAUNCH_BOOTLOADER = launch-bootloader
|
2011-10-28 20:20:55 +00:00
|
|
|
#SERIAL = /dev/ttyUSB0
|
2009-02-19 00:46:02 +00:00
|
|
|
SERIAL = COM6
|
2008-12-03 05:40:16 +00:00
|
|
|
export TOPDIR
|
|
|
|
##############################################################################
|
2008-12-04 03:34:55 +00:00
|
|
|
|
|
|
|
all: compile-$(TARGET)
|
|
|
|
@echo "==============================="
|
|
|
|
@echo "$(TARGET) compiled for: $(MCU)"
|
|
|
|
@echo "size is: "
|
2014-03-18 06:00:13 +00:00
|
|
|
@$(CONFIG_SHELL) scripts/size $(TARGET)
|
2008-12-04 03:34:55 +00:00
|
|
|
@echo "==============================="
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
# generic fluff
|
2014-03-18 06:00:13 +00:00
|
|
|
include $(MAKETOPDIR)/defaults.mk
|
|
|
|
#include $(MAKETOPDIR)/rules.mk
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# generate SUBDIRS variable
|
|
|
|
#
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
.subdirs: $(TOPDIR)/autoconf.h
|
2008-12-03 06:10:03 +00:00
|
|
|
@ echo "checking in which subdirs to build"
|
|
|
|
@ $(RM) -f $@
|
2014-03-18 06:00:13 +00:00
|
|
|
@ echo "SUBDIRS += $(TOPDIR)/animations" >> $@
|
|
|
|
@ echo "SUBDIRS += $(TOPDIR)/animations/bitmapscroller" >> $@
|
|
|
|
@ echo "SUBDIRS += $(TOPDIR)/smallani" >> $@
|
|
|
|
@ (for subdir in `grep -e "^#define .*_SUPPORT" $(TOPDIR)/autoconf.h \
|
|
|
|
| sed -e "s/^#define /$(TOPDIR)\//" -e "s/_SUPPORT.*//" \
|
2008-12-03 05:40:16 +00:00
|
|
|
| tr "[A-Z]\\n" "[a-z] " `; do \
|
|
|
|
test -d $$subdir && echo "SUBDIRS += $$subdir" ; \
|
|
|
|
done) | sort -u >> $@
|
|
|
|
|
|
|
|
ifneq ($(no_deps),t)
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
ifneq ($(MAKECMDGOALS),mrproper)
|
|
|
|
ifneq ($(MAKECMDGOALS),menuconfig)
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
include $(MAKETOPDIR)/.subdirs
|
|
|
|
include $(MAKETOPDIR)/.config
|
2009-01-02 02:18:20 +00:00
|
|
|
include $(TOPDIR)/games/games.mk
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
endif # MAKECMDGOALS!=menuconfig
|
|
|
|
endif # MAKECMDGOALS!=mrproper
|
|
|
|
endif # MAKECMDGOALS!=clean
|
|
|
|
endif # no_deps!=t
|
|
|
|
|
2009-01-02 02:18:20 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
SUBDIRS_AVR = $(TOPDIR)/borg_hw
|
2008-12-04 03:34:55 +00:00
|
|
|
SUBDIRS_AVR += $(SUBDIRS)
|
2008-12-03 13:22:20 +00:00
|
|
|
|
|
|
|
.PHONY: compile-subdirs_avr
|
|
|
|
compile-subdirs_avr:
|
2012-12-27 16:55:13 +00:00
|
|
|
@ for dir in $(SUBDIRS_AVR); do $(MAKE) -C $$dir objects_avr || exit 5; done
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
.PHONY: compile-$(TARGET)
|
2008-12-03 13:22:20 +00:00
|
|
|
compile-$(TARGET): compile-subdirs_avr $(TARGET).hex $(TARGET).bin $(TARGET).lst
|
2011-05-12 20:16:14 +00:00
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
OBJECTS += $(patsubst $(TOPDIR)/%.c,$(TOPDIR)/obj_avr/%.o,${SRC})
|
2008-12-05 14:17:04 +00:00
|
|
|
SUBDIROBJECTS = $(foreach subdir,$(SUBDIRS_AVR),$(foreach object,$(shell cat $(subdir)/obj_avr/.objects 2>/dev/null),$(subdir)/$(object)))
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2008-12-03 06:10:03 +00:00
|
|
|
$(TARGET): $(OBJECTS) $(SUBDIROBJECTS)
|
2011-03-14 10:33:49 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(SUBDIROBJECTS) $(LIBS)
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
2008-12-03 13:22:20 +00:00
|
|
|
#generic rules for AVR-Build
|
2014-03-18 06:00:13 +00:00
|
|
|
$(TOPDIR)/obj_avr/%.o: $(TOPDIR)/%.c
|
|
|
|
@ if [ ! -d $(TOPDIR)/obj_avr ]; then mkdir $(TOPDIR)/obj_avr ; fi
|
2008-12-03 06:10:03 +00:00
|
|
|
@ echo "compiling $<"
|
|
|
|
@ $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c $<
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
%.hex: %
|
|
|
|
$(OBJCOPY) -O ihex -R .eeprom $< $@
|
|
|
|
|
2008-12-03 06:10:03 +00:00
|
|
|
%.bin: %
|
2008-12-03 05:40:16 +00:00
|
|
|
$(OBJCOPY) -O binary -R .eeprom $< $@
|
|
|
|
|
|
|
|
%.eep.hex: %
|
|
|
|
$(OBJCOPY) --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex -j .eeprom $< $@
|
|
|
|
|
|
|
|
%.lst: %
|
|
|
|
$(OBJDUMP) -h -S $< > $@
|
|
|
|
|
|
|
|
%-size: %.hex
|
|
|
|
$(SIZE) $<
|
|
|
|
|
2008-12-03 13:22:20 +00:00
|
|
|
##############################################################################
|
|
|
|
#Rules for simulator build
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
SUBDIRS_SIM = $(TOPDIR)/simulator
|
2008-12-04 03:34:55 +00:00
|
|
|
SUBDIRS_SIM += $(SUBDIRS)
|
|
|
|
|
2008-12-03 13:22:20 +00:00
|
|
|
.PHONY: compile-subdirs_sim
|
|
|
|
compile-subdirs_sim:
|
2012-12-27 16:55:13 +00:00
|
|
|
@ for dir in $(SUBDIRS_SIM); do $(MAKE) -C $$dir objects_sim || exit 5; done
|
2014-03-18 06:00:13 +00:00
|
|
|
@ $(MAKE) -C $(TOPDIR)/simulator/ objects_sim || exit 5;
|
2008-12-03 13:22:20 +00:00
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
simulator: $(TOPDIR)/autoconf.h .config .subdirs compile-subdirs_sim $(TARGET_SIM)
|
2008-12-03 13:22:20 +00:00
|
|
|
|
2008-12-05 14:17:04 +00:00
|
|
|
SUBDIROBJECTS_SIM = $(foreach subdir,$(SUBDIRS_SIM),$(foreach object,$(shell cat $(subdir)/obj_sim/.objects 2>/dev/null),$(subdir)/$(object)))
|
2008-12-04 03:34:55 +00:00
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
OBJECTS_SIM = $(patsubst $(TOPDIR)/%.c,$(TOPDIR)/obj_sim/%.o,${SRC_SIM})
|
2008-12-03 13:22:20 +00:00
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
$(TARGET_SIM): $(OBJECTS_SIM) $(SUBDIROBJECTS_SIM)
|
2008-12-05 02:10:34 +00:00
|
|
|
$(HOSTCC) $(LDFLAGS_SIM) -o $@ $(OBJECTS_SIM) $(SUBDIROBJECTS_SIM) $(LIBS_SIM)
|
2008-12-03 13:22:20 +00:00
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
$(TOPDIR)/obj_sim/%.o: $(TOPDIR)/%.c
|
|
|
|
@ if [ ! -d $(TOPDIR)/obj_sim ]; then mkdir $(TOPDIR)/obj_sim ; fi
|
2008-12-04 03:34:55 +00:00
|
|
|
@ echo "compiling $<"
|
|
|
|
@ $(HOSTCC) -o $@ $(CFLAGS_SIM) -c $<
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
2013-01-06 00:25:19 +00:00
|
|
|
else if [ -x $$(which bash) ]; then echo $$(which bash); \
|
2008-12-03 05:40:16 +00:00
|
|
|
else echo sh; fi ; fi)
|
|
|
|
|
|
|
|
menuconfig:
|
2012-12-27 16:55:13 +00:00
|
|
|
@echo $(CONFIG_SHELL)
|
2008-12-03 05:40:16 +00:00
|
|
|
$(MAKE) -C scripts/lxdialog all
|
|
|
|
$(CONFIG_SHELL) scripts/Menuconfig config.in
|
|
|
|
test -e .config
|
|
|
|
@echo ""
|
|
|
|
@echo "Next, you can: "
|
|
|
|
@echo " * 'make' to compile your borgware"
|
|
|
|
|
2013-09-22 12:40:31 +00:00
|
|
|
test:
|
|
|
|
@echo $(CONFIG_SHELL)
|
|
|
|
@echo
|
|
|
|
@echo "========== Testing borg-16 ========== "
|
|
|
|
$(MAKE) -C scripts/lxdialog all
|
|
|
|
$(CONFIG_SHELL) scripts/Menuconfig config.in profiles/borg-16
|
|
|
|
$(MAKE)
|
|
|
|
$(MAKE) clean
|
|
|
|
@echo
|
|
|
|
@echo "========== Testing borg-ls ========== "
|
|
|
|
$(MAKE) -C scripts/lxdialog all
|
|
|
|
$(CONFIG_SHELL) scripts/Menuconfig config.in profiles/borg-ls
|
|
|
|
$(MAKE)
|
|
|
|
$(MAKE) clean
|
|
|
|
|
2008-12-03 06:10:03 +00:00
|
|
|
#%/menuconfig:
|
|
|
|
# $(SH) "$(@D)/configure"
|
|
|
|
# @$(MAKE) what-now-msg
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
clean:
|
|
|
|
$(MAKE) -f rules.mk no_deps=t clean-common
|
2014-03-20 00:23:36 +00:00
|
|
|
$(RM) -f $(TARGET) $(TARGET).bin $(TARGET).hex $(TARGET).lst .subdirs
|
|
|
|
$(RM) -f $(TARGET).map
|
2008-12-03 06:10:03 +00:00
|
|
|
for subdir in `find . -type d` ; do \
|
2008-12-03 05:40:16 +00:00
|
|
|
test "x$$subdir" != "x." \
|
|
|
|
&& test -e $$subdir/Makefile \
|
2012-12-27 16:55:13 +00:00
|
|
|
&& $(MAKE) no_deps=t -C $$subdir clean ; done ; true
|
2014-03-20 00:23:36 +00:00
|
|
|
$(RM) -fr $(TOPDIR)/obj_avr $(TOPDIR)/obj_sim
|
|
|
|
$(RM) -f $(TARGET_SIM) $(TARGET_SIM).exe
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
mrproper:
|
|
|
|
$(MAKE) clean
|
2014-03-18 06:00:13 +00:00
|
|
|
$(RM) -f $(TOPDIR)/autoconf.h .config config.mk .menuconfig.log .config.old
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2014-03-20 00:23:36 +00:00
|
|
|
#sflash: $(TARGET).hex
|
2009-01-01 17:06:38 +00:00
|
|
|
# $(LAUNCH_BOOTLOADER) $(SERIAL) 115200
|
2014-03-20 00:23:36 +00:00
|
|
|
# avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$< -F
|
|
|
|
# echo X > $(SERIAL)
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2014-03-20 00:23:36 +00:00
|
|
|
#uflash: $(TARGET).hex
|
|
|
|
# avrdude -c usbasp -p atmega32 -V -U f:w:$< -F
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2009-02-18 22:26:46 +00:00
|
|
|
.PHONY: clean mrproper sflash uflash
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
# configure ethersex
|
|
|
|
#
|
2014-03-18 06:00:13 +00:00
|
|
|
show-config: $(TOPDIR)/autoconf.h
|
2008-12-03 05:40:16 +00:00
|
|
|
@echo
|
|
|
|
@echo "These modules are currently enabled: "
|
|
|
|
@echo "======================================"
|
2014-03-18 06:00:13 +00:00
|
|
|
@grep -e "^#define .*_SUPPORT" $(TOPDIR)/autoconf.h | sed -e "s/^#define / * /" -e "s/_SUPPORT.*//"
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
.PHONY: show-config
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
$(TOPDIR)/autoconf.h .config:
|
2008-12-03 05:40:16 +00:00
|
|
|
@echo make\'s goal: $(MAKECMDGOALS)
|
|
|
|
ifneq ($(MAKECMDGOALS),menuconfig)
|
|
|
|
# make sure menuconfig isn't called twice, on `make menuconfig'
|
2014-03-18 06:00:13 +00:00
|
|
|
#test -s $(TOPDIR)/autoconf.h -a -s .config || $(MAKE) no_deps=t menuconfig
|
2008-12-03 05:40:16 +00:00
|
|
|
# test the target file, test fails if it doesn't exist
|
|
|
|
# and will keep make from looping menuconfig.
|
2014-03-18 06:00:13 +00:00
|
|
|
#test -s $(TOPDIR)/autoconf.h -a -s .config
|
|
|
|
touch $(TOPDIR)/autoconf.h .config
|
2008-12-03 05:40:16 +00:00
|
|
|
endif
|
|
|
|
|
2014-03-18 06:00:13 +00:00
|
|
|
include $(MAKETOPDIR)/depend.mk
|