?? makefile
字號:
# Makefile### Copyright (c) Altera Corporation 2002.# All rights reserved.## Author: IS## This is the Makefile for the ads directory of the hello_world example# for Excalibur-ARM. The Makefile provides an alternative mechanism for # building the software using the ADS 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## 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.## On Windows the ARM tools by default install into the directory # C:\Program Files\ARM. The white space in the file name can give make problems. # The solution is to define the environment variable ARMINC so that it does not # contain whitespace. For most users the following transformation should be # sufficent:## Program Files => Progra~1## This makefile makes this transformationby default, so this problem should not# concern most Windows users. However if you do have trouble resolving include# paths on Windows, an incorrect defenition of ARMINC is likely to be the cause# of the problem.## In addition it is assumed that the directory that contains the ADS # 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 := armc_startup.sC_FILES := main.c irq.c exceptions.c uartcomm.c retarget.c timer.c# Search path used to locate the source code. VPATH := software ../common ../hardware # on Unix systems, we have to add some extra escape characters to make # sure the commands make it through the shell unmolested.ifeq (,$(findstring Windows, $(OS)))BRA := \(KET := \)elseBRA := (KET := )endif# Additional object files which should be linked into the application.EXTRA_OBJ_FILES := # the SBI file to useSBI := ../hardware/arm_top.sbi# 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 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# The tools that will be used to build the application.MAKEPROGFILE := $(QUARTUS_ROOTDIR)/bin/makeprogfileCC := armccFROMELF := fromelf LINK := armlink ASM := armasm# 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 := -liASM_DEBUG_FLAGS := -g -keep ASM_RELEASE_FLAGS := # Flags passed to the C compiler.C_FLAGS := -li C_DEBUG_FLAGS := -g -O0C_RELEASE_FLAGS := -O2# Flags passed to the linker.LINK_PATH :=LINK_FLAGS := -first armc_startup.o$(BRA)init$(KET) -entry 0 -ro 0 -rw 0x20000LINK_LIBS := # Flags passed to the linker when linking the output of makeprogfile# with the Altera boot library. LINK_BOOT_PATH := LINK_BOOT_FLAGS := -ro 0 LINK_BOOT_LIBS := $(QUARTUS_ROOTDIR)/libraries/software/boot/libboot_xa_ads.a# Flags passed to the utility used to convert the elf format application# to Intel Hex.FROMELF_FLAGS := -i32# Flags passed to the utility used to convert the elf format bootable# image to Intel Hex.FROMELF_BOOT_FLAGS := -i32# flags passed to the makeprogfile utility.MAKEPROG_FLAGS := -m memory -q# On Windows the ARM tools by default install into the directory C:\Program Files\ARM.# The white space in the file name can give make problems. The solution is to define the # environment variable ARMINC so that it does not contain whitespace. For most users# the following transformation should be sufficent.ARMINC := $(subst Program Files,Progra~1,$(ARMINC))# 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 /Q $(BOOT_FILE)endif# compile assembly files for debug.$(OBJ_FILES_ASM_DEBUG): $(DEBUG_DIR)/%.o: %.s Makefile $(ASM) $(INCLUDE_PATH) $(ASM_FLAGS) $(ASM_DEBUG_FLAGS) -o $@ $<# compile assembly files for release.$(OBJ_FILES_ASM_RELEASE): $(RELEASE_DIR)/%.o: %.s Makefile $(ASM) $(INCLUDE_PATH) $(ASM_FLAGS) $(ASM_RELEASE_FLAGS) -o $@ $<# compile c files for debug$(OBJ_FILES_C_DEBUG): $(DEBUG_DIR)/%.o: %.c $(DEBUG_DIR)/%.d Makefile $(CC) -c $(INCLUDE_PATH) $(C_FLAGS) $(C_DEBUG_FLAGS) -o $@ $<# compile c files for release$(OBJ_FILES_C_RELEASE): $(RELEASE_DIR)/%.o: %.c $(RELEASE_DIR)/%.d 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) $(LINK) $(LINK_PATH) $(LINK_FLAGS) -o $@ $^ $(LINK_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) $(LINK) $(LINK_PATH) $(LINK_FLAGS) -o $@ $^ $(LINK_LIBS) # create an Intel hex file from the elf version of the application %/$(PROJECT).hex: %/$(PROJECT).elf $(FROMELF) $(FROMELF_FLAGS) $< -o $@# 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 $(LINK) $(LINK_BOOT_PATH) $(LINK_BOOT_FLAGS) -o $@ $< $(LINK_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 $(FROMELF) $(FROMELF_BOOT_FLAGS) $< -o $@ $(FROMELF) $(FROMELF_BOOT_FLAGS) $< -o $(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 $@ @ $(ASM) -M $(INCLUDE_PATH) -o $(@:.d=.o) $< > $@ $(foreach dep,$(ASM_FILES:.s=.d),$(RELEASE_DIR)/$(dep)): $(RELEASE_DIR)/%.d: %.s @ echo building dependacy file $@ @ $(ASM) -M $(INCLUDE_PATH) -o $(@:.d=.o) $< > $@ $(foreach dep,$(C_FILES:.c=.d),$(DEBUG_DIR)/$(dep)): $(DEBUG_DIR)/%.d: %.c @ echo building dependacy file $@ @ $(CC) -M $(INCLUDE_PATH) -o $(DEBUG_DIR)_$(basename $(notdir $@)) $< > $(@:.d=.c) @ $(CC) -E -D$(DEBUG_DIR)_$(basename $(notdir $@))=$@ -o $@ $(@:.d=.c)$(foreach dep,$(C_FILES:.c=.d),$(RELEASE_DIR)/$(dep)): $(RELEASE_DIR)/%.d: %.c @ echo building dependacy file $@ @ $(CC) -M $(INCLUDE_PATH) -o $(RELEASE_DIR)_$(basename $(notdir $@)) $< > $(@:.d=.c) @ $(CC) -E -D$(RELEASE_DIR)_$(basename $(notdir $@))=$@ -o $@ $(@:.d=.c)# Include the automatic dependacy 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 new directory is created with these names..PHONY: debug release clean
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -