cant find main.o
- Documentation : http://www.gnu.org/software/make/manual/make.html
- Description : Makefile.
SHELL = /bin/bash
- Project specific defines
-
- Debug option (DEBUG, NDEBUG)
DEBUG = DEBUG
- Project structure (source/target paths)
SRC_DIR = ./
OBJ_DIR = ./obj/ # NOT USED
LST_DIR = ./lst/ # NOT USED
DOC_DIR = ./docs/ # NOT USED
DEP_DIR = ./deps/ # NOT USED
- The following directories are cleaned-up by the 'clean' rule
- CLEAN_DIRS = $(OBJ_DIR) $(LST_DIR) $(DOC_DIR)
- Target
TARGET = lxn
- SND_FILE = U203.vox
- SND_FILE = ABBH8.vox
- SND_FILE = NS210X1.vox
- SND_FILE = ns_new_short.vox
SND_FILE = 229090-145-001.vox
- Project C source files
CSRC = $(SRC_DIR)main.c
CSRC += $(SRC_DIR)initialisation.c
- CSRC += $(SRC_DIR)adc.c
CSRC += $(SRC_DIR)tim.c
CSRC += $(SRC_DIR)iir.c
CSRC += $(SRC_DIR)slope.c
CSRC += $(SRC_DIR)usart.c
CSRC += $(SRC_DIR)adpcm.c
CSRC += $(SRC_DIR)dac.c
CSRC += $(SRC_DIR)audio.c
CSRC += $(SRC_DIR)io.c
CSRC += $(SRC_DIR)mic.c
CSRC += $(SRC_DIR)control.c
CSRC += $(SRC_DIR)calc.c
CSRC += $(SRC_DIR)spi.c
CSRC += $(SRC_DIR)cic.c
CSRC += $(SRC_DIR)flash.c
CSRC += $(SRC_DIR)cal.c
CSRC += $(SRC_DIR)crc.c
- Address Sound file
ADDR_FLASH =0x8000000
ADDR_CAL_SECTION =0x801C800
ADDR_OFFSET_SND_FILE =0x1D000
ADDR_SND_SECTION =0x801D000
ADDR_END_SND_FILE =0x2A875
ifeq (DEBUG,$(DEBUG))
- Debug C source files
CSRC += $(SRC_DIR)printf.c
endif
- CSRC += $(SRC_DIR)debug/uart.c
- STM Library C source files
- CSRC += ..
- ASM source files
ASRC = stm/core/startup_stm32f10x_hd.s
- ASRC += .....
- Defines for use in C code (these will be included with -D options)
CDEFS = TARGET=$(TARGET)
CDEFS += STM32F10X_HD
CDEFS += $(DEBUG)
- CDEFS += .....
- Additional libraries (these will be included with -l options)
- LIBS = m
LIBS +=IQmath
- aditional libraries directories (these will be included with -L options
INCS_LIBS =./
INCS_LIBS += lib/
- Additional include directories (these will be included with -I options)
INCS = ./
- INCS += debug/
INCS += stm/
INCS += stm/core/
- INCS += .....
- The linker script
LINK_SCRIPT = link.ld
- Generic defines
-
- Do not output executed commands.
- SILENT = @
- OS dependent variables.
-
- Determine operating system.
OSTYPE := $(shell echo $$OSTYPE)
ifeq (linux,$(findstring linux,$(OSTYPE)))
#
# Linux OS.
#
# Set OS dependent variables.
TMP = /tmp
INSTPATH = /edge1/programs/linux-x86/opt/CodeSourcery/arm-2010q1-188/bin/
else
#
# Windows OS.
#
# Set OS dependent variables.
TEMP ?= C:\\temp
TMP ?= $(TEMP)
INSTPATH = W:/CodeSourcery/arm-2010q1-188/bin/
endif
- Toolchain prefix
CROSS_COMPILE = $(INSTPATH)arm-none-eabi-
- Tools.
RM = rm -rf
- Define memory map, defines and objects.
MEMMAP =
- Define the objects for all source types
AOBJ = $(ASRC:.s=.o)
COBJ = $(CSRC:.c=.o)
OBJS = $(COBJ) $(AOBJ)
LSTS = $(OBJS:.o=.lst)
DEPS = $(CSRC:.c=.dep)
- Define common GCC stuff
-
- Architecture specific flags
ARCHFLAGS = -mcpu=cortex-m3 -mthumb
- Define compiler and compiler options
-
- Compiler
CC = $(CROSS_COMPILE)gcc
- Optional compiler flags (warnings, list files, .....)
CFLAGS = -Wall
CFLAGS += -Wimplicit
CFLAGS += -Wpointer-arith
CFLAGS += -Wswitch-default
CFLAGS += -Wshadow
CFLAGS += #-Wredundant-decls
CFLAGS += -Wundef
CFLAGS += -Wa,-adhlns=$*.lst
CFLAGS += -O3
- Combine all necessary and optional compiler flags
ALL_CFLAGS = $(ARCHFLAGS)
ALL_CFLAGS += $(patsubst %,-D%,$(CDEFS))
ALL_CFLAGS += $(patsubst %,-I%,$(INCS))
ALL_CFLAGS += $(CFLAGS)
- Compiler for generating dependencies and options
GENDEP = $(CROSS_COMPILE)gcc -MM $(ALL_CFLAGS)
- Define Assembler and assembler options
-
- Assembler
AS = $(CROSS_COMPILE)gcc
- Optional assembler flags (list files, .....)
ASFLAGS = -Wa,-adhlns=$*.lst
- Combine all necessary and optional assembler flags
ALL_ASFLAGS = $(ARCHFLAGS)
- ALL_ASFLAGS += -x assembler-with-cpp
ALL_ASFLAGS += $(ASFLAGS)
- Define linker and linker options
-
- Linker
LD = $(CROSS_COMPILE)gcc
- Optional linker flags (map file, ......)
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -Wl,gc-sections,section-start=SND=$(ADDR_SND_SECTION)
LDFLAGS += -Wl,gc-sections,section-start=CAL=$(ADDR_CAL_SECTION)
- Combine all necessary and optional linker flags
ALL_LDFLAGS = $(ARCHFLAGS)
ALL_LDFLAGS += -nostartfiles
ALL_LDFLAGS += $(patsubst %,-L%,$(INCS_LIBS))
ALL_LDFLAGS += $(patsubst %,-l%,$(LIBS))
- ALL_LDFLAGS += -nostdlib
ALL_LDFLAGS += -T$(LINK_SCRIPT)
ALL_LDFLAGS += $(LDFLAGS)
- Other tools
OBJCOPY = $(CROSS_COMPILE)objcopy
HEXFORMAT = srec
BINFORMAT = binary
- Phony targets
-
- Build all.
.PHONY: all
all: $(TARGET).bin
- Check build environment and create directories if needed.
.PHONY: check_build_env
check_build_env:
| mkdir $(OBJ_DIR) | |
| $(SILENT)test -d $(LST_DIR) |
| mkdir $(DEP_DIR) | |
| # Cleanup project | |
| # Note : if the project directory itself is part of CLEAN_DIRS, it is removed | |
| clean: | |
| @echo " RM $(TARGET)" | |
| $(SILENT)$(RM) $(TARGET).bin $(TARGET).map $(TARGET).hex $(TARGET).elf | |
| $(SILENT)$(RM) $(OBJS) | |
| $(SILENT)$(RM) $(DEPS) | |
| $(SILENT)$(RM) $(LSTS) | |
| # Output tool versions | |
| tools: | |
| @echo "********************************* GCC *************************************" | |
| $(SILENT)$(CC) --version | |
| # Documentation. | |
| docs: doxygen latex | |
| doxygen: | |
| @echo " DOXYGEN $(TARGET)" | |
| $(SILENT)doxygen doxygen.conf 2>&1 | grep -i -v -E '\.c:.+warning' |
latex:
@echo " LATEX $(TARGET)"
$(SILENT)make -C docs/latex/ > /dev/null 2>&1
tags: *.c *.h
@echo " CTAGS $(TARGET)"
$(SILENT)ctags *.c *.h
- Dependencies
-
- Include (generated) dependencies
-include $(DEPS)
- Additional dependencies
- ...
- Now give some rules for building the targets
-
- Retrieve version label from version.h.
GET_VERSION_STR = cat version.h |grep "\#define VERSION_STR" |sed "s/\#define[[:blank:]]*VERSION_STR[[:blank:]]*\"//" |sed "s/\"//"
GET_VCS_SOURCE = svn info . |grep URL: |cut -f 2 -d " " |sed "s/\\r//"
GET_VCS_PATH = $(GET_VCS_SOURCE) |sed "s/\/trunk\$$//" |sed "s/\/branches\/.*//"
- Release current version.
release: update specfile svntag version_increment
update:
$(SILENT)svn update
- Create specfile. (used by release)
specfile: $(TARGET).bin
@VERSION=`$(GET_VERSION_STR)`; \
SPECFILE=$(TARGET)-$$VERSION.spec; \
VCS_SOURCE=`$(GET_VCS_SOURCE)`; \
VCS_TAG=`$(GET_VCS_PATH)`/tags/$(TARGET)-$$VERSION; \
echo " SPECFILE $(TARGET)"; \
$(RM) $(TARGET)-*; \
$(RM) $(TARGET)-*.spec; \
- $(CP) $(TARGET).bin $(TARGET)-$$VERSION.bin; \
echo "VersionControl" >$$SPECFILE; \
echo "VCS=\"svn\"" >>$$SPECFILE; \
echo "SOURCE=\"$$VCS_SOURCE\"" >>$$SPECFILE; \
echo "TAG=\"$$VCS_TAG\"" >>$$SPECFILE; \
echo "VERSION=\"$$VERSION\"" >>$$SPECFILE; \
echo "" >>$$SPECFILE; \
echo "Tools" >>$$SPECFILE; \
echo "TOOL=\"$(CC)\"" >>$$SPECFILE; \
echo "TOOLVERSION=\"`$(CC) --version |head -1`\"" >>$$SPECFILE; \
echo "" >>$$SPECFILE; \
echo "BuildInfo" >>$$SPECFILE; \
echo "OUTPUT=\"$(TARGET)\"" >>$$SPECFILE; \
echo "DATE=\"`date`\"" >>$$SPECFILE; \
echo "HOST=\"`uname -n`\"" >>$$SPECFILE; \
echo "HOSTOS=\"`uname -rvs`\"" >>$$SPECFILE; \
echo "USER=\"`whoami`\"" >>$$SPECFILE; \
echo "COMMAND=\"make\"" >>$$SPECFILE; \
echo "" >>$$SPECFILE; \
- Create subversion tag. (used by release)
- Project is tagged as TARGET-VERSION in repository.
svntag:
@VERSION=`$(GET_VERSION_STR)`; \
VCS_SOURCE=`$(GET_VCS_SOURCE)`; \
VCS_TAG=`$(GET_VCS_PATH)`/tags/$(TARGET)-$$VERSION; \
echo " SVNTAG $(TARGET)-$$VERSION"; \
echo ""; \
echo " The created tag will be a copy of the current repository path";\
echo " $$VCS_SOURCE"; \
echo ""; \
echo -n " Is the current repository path up to date? (yes/no) "; \
read -n 1 -s USERINPUT; \
echo ""; \
if %22$$USERINPUT%22 != %22y%22 -a %22$$USERINPUT%22 != %22Y%22; then \
exit 1; \
fi; \
svn cp $$VCS_SOURCE $$VCS_TAG -m "Auto tag by make. target: release"; \
echo ""; \
echo " ***********************************************************"; \
echo " * - PROJECT RELEASED - "; \
echo " ***********************************************************"; \
echo " *"; \
echo " * Project: $(TARGET)"; \
echo " * Version: $$VERSION"; \
echo " *"; \
echo " * CVS tag: $$VCS_TAG"; \
echo " *"; \
echo " ***********************************************************"; \
echo ""
- Increment version. (used by release)
version_increment:
@echo " VERSION $(TARGET)"
$(SILENT)$(CP) version.h version.h.bak
@VERSION=`$(GET_VERSION_STR)`; \
MAJOR=`echo $$VERSION |cut -f 1 -d "-"`; \
MINOR=`echo $$VERSION |cut -f 2 -d "-"`; \
MINOR=$$((10#$$MINOR)); \
let MINOR++; \
MINOR=`printf "%d" $$MINOR`; \
cat version.h.bak |sed "s/\"$$VERSION\"/\"$$MAJOR-$$MINOR\"/" > version.h
$(SILENT)$(RM) version.h.bak
@VERSION=`$(GET_VERSION_STR)`; \
echo " VERSION $$VERSION"
- Declare phony targets.
.PHONY: all clean doxygen latex tags release update specfile svntag version_increment
- Create objects from c source code and update dependencies.
$(COBJ) : %.o : %.c
$(SILENT)set -e; rm -f $*.dep; \
$(GENDEP) -MF $*.dep.$$$$ $ $*.dep; \
rm -f $*.dep.$$$$
@echo " CC $@"
$(SILENT)$(CC) -c $(ALL_CFLAGS) -o $@ $<
- Create objects from assembly source code with dependencies.
$(AOBJ) : %.o : %.s
@echo " AS $@"
$(SILENT)$(AS) -c $(ALL_ASFLAGS) -o $@ $<
- Link objects and create .elf file
$(TARGET).elf : $(OBJS)
@echo " LD $@"
$(SILENT)$(LD) -o $@ $+ $(ALL_LDFLAGS)
- Create final output file (.hex) from ELF output file.
$(TARGET).hex : $(TARGET).elf
@echo " OBJCOPY $@"
- Create final output file (.bin) from ELF output file.
$(TARGET).bin : $(TARGET).elf
@echo " OBJCOPY $@"
$(SILENT)$(OBJCOPY) -O $(BINFORMAT) $< $@
$(SILENT) srec_cat '(' $(SND_FILE) -binary -offset 0x02 ')' -Little_Endian_Exclusive_Length 0x00 2 -output snd.bin -binary
$(SILENT) srec_cat snd.bin -binary -offset $(ADDR_OFFSET_SND_FILE) -output snd.bin -binary
$(SILENT) srec_cat snd.bin -binary -fill 0 -max-address snd.bin -binary $(ADDR_END_SND_FILE) -output snd.bin -binary
$(SILENT) srec_cat $(TARGET).bin -binary -crop 0x00 $(ADDR_OFFSET_SND_FILE) snd.bin -binary -crop $(ADDR_OFFSET_SND_FILE) -max-address snd.bin -binary -output $(TARGET).bin -binary
$(SILENT) rm snd.bin
this is my make fille