From b66067f50e720c8a69d5df9c0aa558634888e9af Mon Sep 17 00:00:00 2001 From: tixiv Date: Wed, 3 Dec 2008 13:22:20 +0000 Subject: [PATCH] continued integrating simulator --- Makefile | 43 ++++++++++++++++++++++++++++--------------- borg_hw/Makefile | 2 ++ defaults.mk | 7 +++++++ rules.mk | 39 +++++++++++++++++++++++++++++++-------- 4 files changed, 68 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index f28b336..e003322 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ -TARGET := image +TARGET := image +TARGET_SIM := borgsim TOPDIR = . SRC = \ @@ -13,16 +14,6 @@ SERIAL = /dev/ttyUSB0 export TOPDIR ############################################################################## -all: compile-$(TARGET) - @echo "===============================" - @echo "$(TARGET) compiled for: $(MCU)" - @echo "size is: " - @${TOPDIR}/scripts/size $(TARGET) - @echo "===============================" - -simulator: autoconf.h .config .subdirs - $(MAKE) -f Makefile.simulator - ############################################################################## # generic fluff include defaults.mk @@ -57,13 +48,20 @@ endif # MAKECMDGOALS!=clean endif # no_deps!=t ############################################################################## +all: compile-$(TARGET) + @echo "===============================" + @echo "$(TARGET) compiled for: $(MCU)" + @echo "size is: " + @${TOPDIR}/scripts/size $(TARGET) + @echo "===============================" -.PHONY: compile-subdirs -compile-subdirs: + +.PHONY: compile-subdirs_avr +compile-subdirs_avr: @ for dir in $(SUBDIRS); do make -C $$dir objects_avr || exit 5; done .PHONY: compile-$(TARGET) -compile-$(TARGET): compile-subdirs $(TARGET).hex $(TARGET).bin $(TARGET).lst +compile-$(TARGET): compile-subdirs_avr $(TARGET).hex $(TARGET).bin $(TARGET).lst OBJECTS += $(patsubst %.c,./obj_avr/%.o,${SRC}) SUBDIROBJECTS = $(foreach subdir,$(SUBDIRS),$(foreach object,$(shell cat $(subdir)/obj_avr/.objects),$(subdir)/$(object))) @@ -73,7 +71,7 @@ $(TARGET): $(OBJECTS) $(SUBDIROBJECTS) ############################################################################## - +#generic rules for AVR-Build ./obj_avr/%.o: %.c @ if [ ! -d obj_avr ]; then mkdir obj_avr ; fi @ echo "compiling $<" @@ -94,6 +92,21 @@ $(TARGET): $(OBJECTS) $(SUBDIROBJECTS) %-size: %.hex $(SIZE) $< +############################################################################## +#Rules for simulator build + +.PHONY: compile-subdirs_sim +compile-subdirs_sim: + @ for dir in $(SUBDIRS); do make -C $$dir objects_sim || exit 5; done + @ make -C ./simulator/ objects_sim || exit 5; + +simulator: autoconf.h .config .subdirs compile-subdirs_sim $(TARGET_SIM) + +SUBDIROBJECTS_SIM = $(foreach subdir,$(SUBDIRS),$(foreach object,$(shell cat $(subdir)/obj_sim/.objects),$(subdir)/$(object))) + +$(TARGET_SIM): $(SUBDIROBJECTS_SIM) + $(HOSTCC) $(LDFLAGS_SIM) $(LIBS_SIM) -o $@ $(SUBDIROBJECTS_SIM) + ############################################################################## CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ diff --git a/borg_hw/Makefile b/borg_hw/Makefile index 5c2f863..2820bbd 100644 --- a/borg_hw/Makefile +++ b/borg_hw/Makefile @@ -1,6 +1,8 @@ TARGET = libborg_hw.a TOPDIR = .. +SRC_SIM := + include $(TOPDIR)/defaults.mk diff --git a/defaults.mk b/defaults.mk index f7fe105..6a530e2 100644 --- a/defaults.mk +++ b/defaults.mk @@ -25,6 +25,13 @@ CFLAGS += -g -Os -std=gnu99 -fgnu89-inline LDFLAGS += -mmcu=$(MCU) +############################################################################# +#Settings for Simulator build +CFLAGS_SIM = -g -Wall -pedantic -std=c99 -O2 +LDFLAGS_SIM = -Wl +LIBS_SIM = LIBS = -lglut -lpthread -lGL -lGLU + + ############################################################################## # the default target $(TARGET): diff --git a/rules.mk b/rules.mk index fa79f2b..63be84b 100644 --- a/rules.mk +++ b/rules.mk @@ -1,11 +1,11 @@ + +############################################################################## +# rules for buildung AVR objects + OBJECTS += $(patsubst %.c,obj_avr/%.o,${SRC}) OBJECTS += $(patsubst %.S,obj_avr/%.o,${ASRC}) -#./obj_avr/%.a: $(OBJECTS) -# $(AR) qcv $@ $^ -# $(STRIP) --strip-unneeded $@ - ./obj_avr/%.o: %.S @ if [ ! -d obj_avr ]; then mkdir obj_avr ; fi @ echo "assembling $<" @@ -16,18 +16,41 @@ OBJECTS += $(patsubst %.S,obj_avr/%.o,${ASRC}) @ echo "compiling $<" @ $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c $< +objects_avr: $(OBJECTS) + @ echo "writing object ineventory" + @ echo $(OBJECTS) > obj_avr/.objects + + +############################################################################## +# rules for buildung simulator objects + +SRC_SIM = $(SRC) +OBJECTS_SIM += $(patsubst %.c,obj_sim/%.o,${SRC_SIM}) + +./obj_sim/%.o: %.c + @ if [ ! -d obj_sim ]; then mkdir obj_sim ; fi + @ echo "compiling $<" + @ $(HOSTCC) -o $@ $(CFLAGS_SIM) -c $< + +objects_sim: $(OBJECTS_SIM) + @ echo "writing object ineventory" + @ echo $(OBJECTS) > obj_sim/.objects + + + + + + + clean-common: $(RM) $(TARGET) *.[odasE] *.d.new *~ $(RM) -r ./obj_avr + $(RM) -r ./obj_sim clean: clean-common all: make -C $(TOPDIR) all -objects_avr: $(OBJECTS) - @ echo "writing object ineventory" - @ echo $(OBJECTS) > obj_avr/.objects - include $(TOPDIR)/depend.mk