#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
#
-# Updates:
+# Updates:
# Arthur Wolf & Adam Green in 2011 - 2012 - Updated to work with mbed.
###############################################################################
# Check for undefined variables.
OUTDIR=../$(DEVICE)
# List of sources to be compiled/assembled
-CSRCS = $(wildcard $(SRC)/*.c $(SRC)/*/*.c $(SRC)/*/*/*.c $(SRC)/*/*/*/*.c $(SRC)/*/*/*/*/*.c)
+CSRCS1 = $(wildcard $(SRC)/*.c $(SRC)/*/*.c $(SRC)/*/*/*.c $(SRC)/*/*/*/*.c $(SRC)/*/*/*/*/*.c $(SRC)/*/*/*/*/*/*.c)
+# Totally exclude network if NONETWORK is defined
+ifeq "$(NONETWORK)" "1"
+CSRCS2 = $(filter-out $(SRC)/libs/Network/%,$(CSRCS1))
+DEFINES += -DNONETWORK
+else
+CSRCS2 = $(CSRCS1)
+endif
+
+# do not compile the src/testframework as that can only be done with rake
+CSRCS = $(filter-out $(SRC)/testframework/%,$(CSRCS2))
+
+ifeq "$(DISABLEMSD)" "1"
+DEFINES += -DDISABLEMSD
+endif
+
ASRCS = $(wildcard $(SRC)/*.S $(SRC)/*/*.S $(SRC)/*/*/*.S $(SRC)/*/*/*/*.S $(SRC)/*/*/*/*/*.S)
ifneq "$(OS)" "Windows_NT"
ASRCS += $(wildcard $(SRC)/*.s $(SRC)/*/*.s $(SRC)/*/*/*.s $(SRC)/*/*/*/*.s $(SRC)/*/*/*/*/*.s)
endif
-CPPSRCS = $(wildcard $(SRC)/*.cpp $(SRC)/*/*.cpp $(SRC)/*/*/*.cpp $(SRC)/*/*/*/*.cpp $(SRC)/*/*/*/*/*.cpp)
+
+CPPSRCS1 = $(wildcard $(SRC)/*.cpp $(SRC)/*/*.cpp $(SRC)/*/*/*.cpp $(SRC)/*/*/*/*.cpp $(SRC)/*/*/*/*/*.cpp $(SRC)/*/*/*/*/*/*.cpp)
+ifeq "$(NONETWORK)" "1"
+ CPPSRCS2 = $(filter-out $(SRC)/libs/Network/%,$(CPPSRCS1))
+else
+ ifneq "$(PLAN9)" "1"
+ DEFINES += -DNOPLAN9
+ CPPSRCS2 = $(filter-out $(SRC)/libs/Network/uip/plan9/%,$(CPPSRCS1))
+ else
+ CPPSRCS2 = $(CPPSRCS1)
+ endif
+endif
+
+# CNC build
+ifeq "$(CNC)" "1"
+ CPPSRCS21 = $(filter-out $(SRC)/modules/utils/panel/screens/3dprinter/%,$(CPPSRCS2))
+ DEFINES += -DCNC
+else
+ CPPSRCS21 = $(filter-out $(SRC)/modules/utils/panel/screens/cnc/%,$(CPPSRCS2))
+endif
+
+# Totally exclude any modules listed in EXCLUDE_MODULES
+# uppercase function
+uc = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
+EXL = $(patsubst %,$(SRC)/modules/%/%,$(EXCLUDED_MODULES))
+CPPSRCS3 = $(filter-out $(EXL),$(CPPSRCS21))
+DEFINES += $(call uc, $(subst /,_,$(patsubst %,-DNO_%,$(EXCLUDED_MODULES))))
+
+# do not compile the src/testframework as that can only be done with rake
+CPPSRCS = $(filter-out $(SRC)/testframework/%,$(CPPSRCS3))
# List of the objects files to be compiled/assembled
OBJECTS = $(patsubst %.c,$(OUTDIR)/%.o,$(CSRCS)) $(patsubst %.s,$(OUTDIR)/%.o,$(patsubst %.S,$(OUTDIR)/%.o,$(ASRCS))) $(patsubst %.cpp,$(OUTDIR)/%.o,$(CPPSRCS))
# Add in the MBED customization stubs which allow hooking in the MRI debug monitor.
OBJECTS += $(OUTDIR)/mbed_custom.o
+OBJECTS += $(OUTDIR)/configdefault.o
+
# List of the header dependency files, one per object file.
DEPFILES = $(patsubst %.o,%.d,$(OBJECTS))
MRI_DIR = $(BUILD_DIR)/../mri
# Include path which points to external library headers and to subdirectories of this project which contain headers.
-SUBDIRS = $(wildcard $(SRC)/* $(SRC)/*/* $(SRC)/*/*/* $(SRC)/*/*/*/* $(SRC)/*/*/*/*/*)
+SUBDIRS = $(wildcard $(SRC)/* $(SRC)/*/* $(SRC)/*/*/* $(SRC)/*/*/*/* $(SRC)/*/*/*/*/* $(SRC)/*/*/*/*/*/*)
PROJINCS = $(sort $(dir $(SUBDIRS)))
INCDIRS += $(SRC) $(PROJINCS) $(MRI_DIR) $(MBED_DIR) $(MBED_DIR)/$(DEVICE)
# DEFINEs to be used when building C/C++ code
DEFINES += -DTARGET_$(DEVICE)
-DEFINES += -DMRI_ENABLE=$(MRI_ENABLE) -DMRI_INIT_PARAMETERS='"$(MRI_INIT_PARAMETERS)"'
+DEFINES += -DMRI_ENABLE=$(MRI_ENABLE) -DMRI_INIT_PARAMETERS='"$(MRI_INIT_PARAMETERS)"'
DEFINES += -DMRI_BREAK_ON_INIT=$(MRI_BREAK_ON_INIT) -DMRI_SEMIHOST_STDIO=$(MRI_SEMIHOST_STDIO)
DEFINES += -DWRITE_BUFFER_DISABLE=$(WRITE_BUFFER_DISABLE) -DSTACK_SIZE=$(STACK_SIZE)
# Libraries to be linked into final binary
MBED_LIBS = $(MBED_DIR)/$(DEVICE)/GCC_ARM/libmbed.a
-SYS_LIBS = -lstdc++_s -lsupc++_s -lm -lgcc -lc_s -lgcc -lc_s -lnosys
-LIBS = $(LIBS_PREFIX)
+#SYS_LIBS = -lstdc++_s -lsupc++_s -lm -lgcc -lc_s -lgcc -lc_s -lnosys
+SYS_LIBS = -specs=nano.specs -lstdc++ -lsupc++ -lm -lgcc -lc -lnosys
+LIBS = $(LIBS_PREFIX)
ifeq "$(MRI_ENABLE)" "1"
LIBS += $(MRI_DIR)/mri.ar
# Compiler flags used to enable creation of header dependencies.
DEPFLAGS = -MMD -MP
-# Setup wraps for newlib read/writes to redirect to MRI debugger.
+# Setup wraps for newlib read/writes to redirect to MRI debugger.
ifeq "$(MRI_ENABLE)" "1"
MRI_WRAPS=,--wrap=_read,--wrap=_write,--wrap=semihost_connected
else
endif
# Setup wraps to memory allocations routines if we want to tag heap allocations.
-HEAP_WRAPS=
ifeq "$(HEAP_TAGS)" "1"
-HEAP_WRAPS=,--wrap=malloc,--wrap=realloc,--wrap=free
DEFINES += -DHEAP_TAGS
endif
# Linker Options.
-LDFLAGS = $(DEVICE_FLAGS) -specs=$(BUILD_DIR)/startfile.spec
-LDFLAGS += -Wl,-Map=$(OUTDIR)/$(PROJECT).map,--cref,--gc-sections,--wrap=_isatty$(MRI_WRAPS)$(HEAP_WRAPS)
+LDFLAGS = $(DEVICE_FLAGS) -specs=$(BUILD_DIR)/startfile.spec
+LDFLAGS += -Wl,-Map=$(OUTDIR)/$(PROJECT).map,--cref,--gc-sections,--wrap=_isatty,--wrap=malloc,--wrap=realloc,--wrap=free$(MRI_WRAPS)
LDFLAGS += -T$(LSCRIPT) -L $(EXTERNAL_DIR)/gcc/LPC1768
ifneq "$(NO_FLOAT_SCANF)" "1"
LDFLAGS += -u _scanf_float
@echo Extracting $@
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(OBJCOPY) -R .stack -O ihex $< $@
-
+
$(OUTDIR)/$(PROJECT).disasm: $(OUTDIR)/$(PROJECT).elf
@echo Extracting disassembly to $@
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(OBJDUMP) -d -f -M reg-names-std --demangle $< >$@
-
+
$(OUTDIR)/$(PROJECT).elf: $(LSCRIPT) $(OBJECTS)
@echo Linking $@
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
clean:
@echo Cleaning up all build generated files
- $(Q) $(REMOVE_DIR) $(OUTDIR) $(QUIET)
+ $(Q) $(REMOVE_DIR) $(call convert-slash,$(OUTDIR)) $(QUIET)
-include $(DEPFILES)
$(Q) $(MKDIR) $(call convert-slash,$(dir $@)) $(QUIET)
$(Q) $(AS) $(AS_FLAGS) -o $@ $<
-#########################################################################
\ No newline at end of file
+$(OUTDIR)/configdefault.o : config.default
+ $(Q) $(OBJCOPY) -I binary -O elf32-littlearm -B arm --readonly-text --rename-section .data=.rodata.configdefault $< $@
+
+#########################################################################