2008-12-03 13:22:20 +00:00
|
|
|
TARGET := image
|
|
|
|
TARGET_SIM := borgsim
|
2008-12-03 05:40:16 +00:00
|
|
|
TOPDIR = .
|
|
|
|
|
|
|
|
SRC = \
|
|
|
|
main.c \
|
2008-12-04 03:34:55 +00:00
|
|
|
display_loop.c \
|
2008-12-03 05:40:16 +00:00
|
|
|
eeprom_reserve.c \
|
|
|
|
pixel.c \
|
|
|
|
util.c \
|
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
SRC_SIM = \
|
|
|
|
display_loop.c \
|
|
|
|
pixel.c \
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
LAUNCH_BOOTLOADER = launch-bootloader
|
|
|
|
SERIAL = /dev/ttyUSB0
|
|
|
|
|
|
|
|
export TOPDIR
|
|
|
|
##############################################################################
|
2008-12-04 03:34:55 +00:00
|
|
|
|
|
|
|
all: compile-$(TARGET)
|
|
|
|
@echo "==============================="
|
|
|
|
@echo "$(TARGET) compiled for: $(MCU)"
|
|
|
|
@echo "size is: "
|
|
|
|
@${TOPDIR}/scripts/size $(TARGET)
|
|
|
|
@echo "==============================="
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
# generic fluff
|
|
|
|
include defaults.mk
|
|
|
|
#include $(TOPDIR)/rules.mk
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# generate SUBDIRS variable
|
|
|
|
#
|
|
|
|
|
|
|
|
.subdirs: autoconf.h
|
2008-12-03 06:10:03 +00:00
|
|
|
@ echo "checking in which subdirs to build"
|
|
|
|
@ $(RM) -f $@
|
|
|
|
@ echo "SUBDIRS += animations" >> $@
|
|
|
|
@ (for subdir in `grep -e "^#define .*_SUPPORT" autoconf.h \
|
2008-12-03 05:40:16 +00:00
|
|
|
| sed -e "s/^#define //" -e "s/_SUPPORT.*//" \
|
|
|
|
| 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)
|
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
include $(TOPDIR)/.subdirs
|
2008-12-03 06:10:03 +00:00
|
|
|
-include $(TOPDIR)/.config
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
endif # MAKECMDGOALS!=menuconfig
|
|
|
|
endif # MAKECMDGOALS!=mrproper
|
|
|
|
endif # MAKECMDGOALS!=clean
|
|
|
|
endif # no_deps!=t
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
SUBDIRS_AVR = borg_hw
|
|
|
|
SUBDIRS_AVR += $(SUBDIRS)
|
2008-12-03 13:22:20 +00:00
|
|
|
|
|
|
|
.PHONY: compile-subdirs_avr
|
|
|
|
compile-subdirs_avr:
|
2008-12-04 03:34:55 +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
|
2008-12-04 03:34:55 +00:00
|
|
|
@ echo "foobar"
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2008-12-03 06:10:03 +00:00
|
|
|
OBJECTS += $(patsubst %.c,./obj_avr/%.o,${SRC})
|
2008-12-04 03:34:55 +00:00
|
|
|
SUBDIROBJECTS = $(foreach subdir,$(SUBDIRS_AVR),$(foreach object,$(shell cat $(subdir)/obj_avr/.objects),$(subdir)/$(object)))
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2008-12-03 06:10:03 +00:00
|
|
|
$(TARGET): $(OBJECTS) $(SUBDIROBJECTS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(SUBDIROBJECTS)
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
2008-12-03 13:22:20 +00:00
|
|
|
#generic rules for AVR-Build
|
2008-12-03 06:10:03 +00:00
|
|
|
./obj_avr/%.o: %.c
|
|
|
|
@ if [ ! -d obj_avr ]; then mkdir obj_avr ; fi
|
|
|
|
@ 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
|
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
SUBDIRS_SIM = simulator
|
|
|
|
SUBDIRS_SIM += $(SUBDIRS)
|
|
|
|
|
2008-12-03 13:22:20 +00:00
|
|
|
.PHONY: compile-subdirs_sim
|
|
|
|
compile-subdirs_sim:
|
2008-12-04 03:34:55 +00:00
|
|
|
@ for dir in $(SUBDIRS_SIM); do make -C $$dir objects_sim || exit 5; done
|
2008-12-03 13:22:20 +00:00
|
|
|
@ make -C ./simulator/ objects_sim || exit 5;
|
|
|
|
|
|
|
|
simulator: autoconf.h .config .subdirs compile-subdirs_sim $(TARGET_SIM)
|
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
SUBDIROBJECTS_SIM = $(foreach subdir,$(SUBDIRS_SIM),$(foreach object,$(shell cat $(subdir)/obj_sim/.objects),$(subdir)/$(object)))
|
|
|
|
|
|
|
|
OBJECTS_SIM = $(patsubst %.c,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-03 13:22:20 +00:00
|
|
|
$(HOSTCC) $(LDFLAGS_SIM) $(LIBS_SIM) -o $@ $(SUBDIROBJECTS_SIM)
|
|
|
|
|
2008-12-04 03:34:55 +00:00
|
|
|
./obj_sim/%.o: %.c
|
|
|
|
@ if [ ! -d obj_sim ]; then mkdir obj_sim ; fi
|
|
|
|
@ echo "compiling $<"
|
|
|
|
@ $(HOSTCC) -o $@ $(CFLAGS_SIM) -c $<
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
##############################################################################
|
|
|
|
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
|
|
|
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
|
|
|
else echo sh; fi ; fi)
|
|
|
|
|
|
|
|
menuconfig:
|
|
|
|
$(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"
|
2008-12-03 06:10:03 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
|
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
|
2008-12-03 06:10:03 +00:00
|
|
|
$(RM) $(TARGET) $(TARGET).bin $(TARGET).hex $(TARGET).lst .subdirs
|
|
|
|
for subdir in `find . -type d` ; do \
|
2008-12-03 05:40:16 +00:00
|
|
|
test "x$$subdir" != "x." \
|
|
|
|
&& test -e $$subdir/Makefile \
|
2008-12-03 06:10:03 +00:00
|
|
|
&& make no_deps=t -C $$subdir clean ; done ; true
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
mrproper:
|
|
|
|
$(MAKE) clean
|
|
|
|
$(RM) -f autoconf.h .config config.mk .menuconfig.log .config.old
|
|
|
|
|
|
|
|
sflash: $(TARGET).hex
|
|
|
|
$(LAUNCH_BOOTLOADER) $(SERIAL) 115200
|
|
|
|
avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$< -F
|
|
|
|
echo X > $(SERIAL)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean mrproper sflash
|
|
|
|
##############################################################################
|
|
|
|
# configure ethersex
|
|
|
|
#
|
|
|
|
show-config: autoconf.h
|
|
|
|
@echo
|
|
|
|
@echo "These modules are currently enabled: "
|
|
|
|
@echo "======================================"
|
|
|
|
@grep -e "^#define .*_SUPPORT" autoconf.h | sed -e "s/^#define / * /" -e "s/_SUPPORT.*//"
|
|
|
|
|
|
|
|
.PHONY: show-config
|
|
|
|
|
|
|
|
autoconf.h .config:
|
|
|
|
@echo make\'s goal: $(MAKECMDGOALS)
|
|
|
|
ifneq ($(MAKECMDGOALS),menuconfig)
|
|
|
|
# make sure menuconfig isn't called twice, on `make menuconfig'
|
|
|
|
test -s autoconf.h -a -s .config || $(MAKE) no_deps=t menuconfig
|
|
|
|
# test the target file, test fails if it doesn't exist
|
|
|
|
# and will keep make from looping menuconfig.
|
|
|
|
test -s autoconf.h -a -s .config
|
|
|
|
endif
|
|
|
|
|
|
|
|
include depend.mk
|