?? makefile
字號(hào):
# Makefile### Copyright (c) Altera Corporation 2002.# All rights reserved.## Author: IS## This is the Makefile for the gnu directory of the hello_world example# for Excalibur-ARM. The Makefile provides an alternative mechanism for # building the software using the gnu tools. The intention is that this # Makefile should follow the same build processes as that performed by # the Quartus software project provided in this directory.## Targets# -------## The following targets are supported:## debug - build a debug version of the hello_world application# release - build a release version of the hello_world application# clean - delete all generated files## The default target is 'debug'.## Environment Variables# ---------------------## In order to locate the makeprogfile utility and the boot library, either# QUARTUS_ROOTDIR or QUTILITIES_ROOTDIR must be defined. These variables# point to the installation directory of Quartus (QUARTUS_ROOTDIR), or # the Quartus utilities (QUTILITIES_ROOTDIR). On Windows these variables# are set automatically when the tools are installed. One or other # should be set manually on unix.## The following environment variables are required to locate the gnu# newlib libraries and object files. ## ALTERA_ARM9GP_ROOT - The installation directory of the gnu tools, e.g. # c:\Redhat.# ALTERA_ARM9GP_VER - The version of the tools being used, e.g. arm9-020404.# ALTERA_ARM9GP_HOST - The host platform being used, e.g. H-i686-pc-cygwin.## In addition it is assumed that the directory that contains the gnu # utilities are on you path. ################################################################### The name of the project being built. This is used to create the names# of the generated files.PROJECT := interrupt# The names of the directories which will be used to hold the intermediate# files.DEBUG_DIR := DebugRELEASE_DIR := Release# The source files to be built. Note that the paths to locate the source files# should be defined using the VPATH variable.ASM_FILES := crt0.SC_FILES := main.c epxa10.c exceptions.c irq.c uartcomm.c timer.c# Search path used to locate the source code. VPATH := software ../common ../hardware # the SBI file to useSBI := ../hardware/arm_top.sbi# The environment variables QUARTUS_ROOTDIR and QUTILITIES_ROOTDIR are # used to locate utilities and libraries privided by Altera. By default# the tools provided by a full installation of Quartus are used (as# defined through the QUARTUS_ROOTDIR environment variable). ## If QUARTUS_ROOTDIR is not defined, then the utilities installed by# the utilities and resources CD are used (as defined by the # QUTILITIES_ROOTDIR). ifndef QUARTUS_ROOTDIRQUARTUS_ROOTDIR := $(QUTILITIES_ROOTDIR)endif# Additional object files which should be linked into the application.EXTRA_OBJ_FILES := $(ALTERA_ARM9GP_ROOT)/$(ALTERA_ARM9GP_VER)/$(ALTERA_ARM9GP_HOST)/lib/gcc-lib/arm-elf/2.96-$(ALTERA_ARM9GP_VER)/crtbegin.o \ $(ALTERA_ARM9GP_ROOT)/$(ALTERA_ARM9GP_VER)/$(ALTERA_ARM9GP_HOST)/lib/gcc-lib/arm-elf/2.96-$(ALTERA_ARM9GP_VER)/crtend.o # The name of bootable image that is to be generated. This is created# in Intel Hex format, so that it can be programmed into flash using # the Altera flash programmer.BOOT_FILE := $(PROJECT)_flash.hex# The tools that will be used to build the application.MAKEPROGFILE := $(QUARTUS_ROOTDIR)/bin/makeprogfileCC := arm-elf-gccOBJCOPY := arm-elf-objcopy LD := arm-elf-ld ASM := arm-elf-gcc -x assembler-with-cpp# The path to search for include files when compiling the source.INCLUDE_PATH := -I. -I../common -I../hardware# Flags passed to the assembler.ASM_FLAGS := -WaEL -marm920tASM_DEBUG_FLAGS := -Wagdwarf2 -WaL ASM_RELEASE_FLAGS := # Flags passed to the C compiler.C_FLAGS := -mlittle-endian -mcpu=arm920t C_DEBUG_FLAGS := -gC_RELEASE_FLAGS := -O3# Flags passed to the linker.LD_PATH := -L $(ALTERA_ARM9GP_ROOT)/$(ALTERA_ARM9GP_VER)/$(ALTERA_ARM9GP_HOST)/lib/gcc-lib/arm-elf/2.96-$(ALTERA_ARM9GP_VER) \ -L $(ALTERA_ARM9GP_ROOT)/$(ALTERA_ARM9GP_VER)/$(ALTERA_ARM9GP_HOST)/arm-elf/lib LD_FLAGS := -EL -T software/armelf.xLD_LIBS := -lc -lgcc -lc# Flags passed to the linker when linking the output of makeprogfile# with the Altera boot library. Note that the -p flag is required, since# the boot library has been generated using the ADS tools. LD_BOOT_PATH := -L $(QUARTUS_ROOTDIR)/libraries/software/bootLD_BOOT_FLAGS := -p -entry=___altera_entry LD_BOOT_LIBS := -lboot_xa_ads# Flags passed to the utility used to convert the elf format application# to Intel Hex.OBJCOPY_FLAGS := -O ihex# Flags passed to the utility used to convert the elf format application# to Intel Hex.OBJCOPY_BOOT_FLAGS := -O ihex --change-address=-0x8000# flags passed to the makeprogfile utility.MAKEPROG_FLAGS := -m memory -q# These variables are used internally to generate dependancies. It is not expected that# these will need to be modifiedOBJ_FILES_ASM_DEBUG := $(foreach file, $(ASM_FILES:.S=.o), $(DEBUG_DIR)/$(file))OBJ_FILES_ASM_RELEASE := $(foreach file, $(ASM_FILES:.S=.o), $(RELEASE_DIR)/$(file))OBJ_FILES_C_DEBUG := $(foreach file, $(C_FILES:.c=.o), $(DEBUG_DIR)/$(file))OBJ_FILES_C_RELEASE := $(foreach file, $(C_FILES:.c=.o), $(RELEASE_DIR)/$(file))################################################################### rules## Below are the rules used to construct the supported targets. 'debug' is the # default target.# In the case of cygwin Make on the PC, we have to make sure# that we're using the win32 mode.ifneq (, $(findstring Windows, $(OS)))ifeq (, $(findstring --win32, $(MAKEFLAGS)))debug release clean: @$(MAKE) --win32 $@ DEFER_MAKE := true endifendif ifndef DEFER_MAKE# generate a debug version of the bootable image.debug: $(DEBUG_DIR)/$(BOOT_FILE)# generate a release version of the bootable image.release: $(RELEASE_DIR)/$(BOOT_FILE)# Delete all generated files.## Since rm doesn't exist on windows machines# del has to be used instead. The environment variable OS is used to# discover the machine architecture. I hope that is defined by default# for all Windows hosts...clean:ifneq (,$(findstring Windows, $(OS))) -del /Q $(DEBUG_DIR)\* $(RELEASE_DIR)\* -del /Q $(BOOT_FILE)else -rm -f $(DEBUG_DIR)/* $(RELEASE_DIR)/* -rm -f $(BOOT_FILE)endif# compile assembly files for debug.$(OBJ_FILES_ASM_DEBUG): $(DEBUG_DIR)/%.o: %.S Makefile $(ASM) -c $(INCLUDE_PATH) $(ASM_FLAGS) $(ASM_DEBUG_FLAGS) -o $@ $<# compile assembly files for release.$(OBJ_FILES_ASM_RELEASE): $(RELEASE_DIR)/%.o: %.S Makefile $(ASM) -c $(INCLUDE_PATH) $(ASM_FLAGS) $(ASM_RELEASE_FLAGS) -o $@ $<# compile c files for debug$(OBJ_FILES_C_DEBUG): $(DEBUG_DIR)/%.o: %.c Makefile $(CC) -c $(INCLUDE_PATH) $(C_FLAGS) $(C_DEBUG_FLAGS) -o $@ $<# compile c files for release.$(OBJ_FILES_C_RELEASE): $(RELEASE_DIR)/%.o: %.c Makefile $(CC) -c $(INCLUDE_PATH) $(C_FLAGS) $(C_RELEASE_FLAGS) -o $@ $<# link all debug versions of the application object files$(DEBUG_DIR)/$(PROJECT).elf: $(OBJ_FILES_ASM_DEBUG) $(OBJ_FILES_C_DEBUG) $(EXTRA_OBJ_FILES) $(LD) $(LD_PATH) $(LD_FLAGS) -o $@ $^ $(LD_LIBS)# link all release versions of the application object files$(RELEASE_DIR)/$(PROJECT).elf: $(OBJ_FILES_ASM_RELEASE) $(OBJ_FILES_C_RELEASE) $(EXTRA_OBJ_FILES) $(LD) $(LD_PATH) $(LD_FLAGS) -o $@ $^ $(LD_LIBS) # create an Intel hex file from the elf version of the application %/$(PROJECT).hex: %/$(PROJECT).elf $(OBJCOPY) $(OBJCOPY_FLAGS) $< $@# create the bootdata used by the boot library to configure the device and # load the application%/$(PROJECT)_bootdata.o: $(PROJECT).sbd $(SBI) %/$(PROJECT).hex $(MAKEPROGFILE) $(MAKEPROG_FLAGS) -b $@ $^# link the bootdata with the boot library%/$(PROJECT)_flash.elf: %/$(PROJECT)_bootdata.o $(LD) $(LD_BOOT_PATH) $(LD_BOOT_FLAGS) -o $@ $< $(LD_BOOT_LIBS) # Convert the bootable executable into Intel hex format. As a side effect of this rule,# a copy of the hex file is stored in the current directory. This is done in order to emulate# the action of the Quartus project.%/$(PROJECT)_flash.hex: %/$(PROJECT)_flash.elf $(OBJCOPY) $(OBJCOPY_BOOT_FLAGS) $< $@ $(OBJCOPY) $(OBJCOPY_BOOT_FLAGS) $< $(BOOT_FILE)# These intermediates are retained since they're useful for system debug..PRECIOUS: %/$(PROJECT)_bootdata.o %/$(PROJECT).hex %/$(PROJECT)_flash.elf# Remove any generated files, if there's an error in making them.DELETE_ON_ERROR: # These rules are used to generate the automatic dependacy files. The method used here is # a little unorthodox. The motivation for this is to provide a solution that will work# equally well on windows and unix systems. The regular method described in the gnu make # manual uses sed, which we don't necessarily have available on windows.$(foreach dep,$(ASM_FILES:.S=.d),$(DEBUG_DIR)/$(dep)): $(DEBUG_DIR)/%.d: %.S @ echo building dependacy file $@ @ echo $@ $(@:.d=.o) \> $@ @ $(ASM) -M $(INCLUDE_PATH) $< >> $@ $(foreach dep,$(ASM_FILES:.S=.d),$(RELEASE_DIR)/$(dep)): $(RELEASE_DIR)/%.d: %.S @ echo building dependacy file $@ @ echo $@ $(@:.d=.o) \> $@ @ $(ASM) -M $(INCLUDE_PATH) $< >> $@ $(foreach dep,$(C_FILES:.c=.d),$(DEBUG_DIR)/$(dep)): $(DEBUG_DIR)/%.d: %.c @ echo building dependacy file $@ @ echo $@ $(@:.d=.o) \> $@ @ $(CC) -M $(INCLUDE_PATH) $< >> $@ $(foreach dep,$(C_FILES:.c=.d),$(RELEASE_DIR)/$(dep)): $(RELEASE_DIR)/%.d: %.c @ echo building dependacy file $@ @ echo $@ $(@:.d=.o) \> $@ @ $(CC) -M $(INCLUDE_PATH) $< >> $@ # Include the dependancy files-include $(foreach dep,$(ASM_FILES:.S=.d),$(DEBUG_DIR)/$(dep))-include $(foreach dep,$(ASM_FILES:.S=.d),$(RELEASE_DIR)/$(dep))-include $(foreach dep,$(C_FILES:.c=.d),$(DEBUG_DIR)/$(dep))-include $(foreach dep,$(C_FILES:.c=.d),$(RELEASE_DIR)/$(dep))endif# Declare these targets as phony to ensure that their associated rules will always run, even# if a directory is created with these names..PHONY: debug release clean
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -