📄 makedefs
字号:
#*****************************************************************************## MAKEDEFS - Common definitions for all makefiles.## Copyright (c) 2001 Cirrus Logic, Inc.##*****************************************************************************#*****************************************************************************## The default rule.##*****************************************************************************.PHONY: allifdef DIRSall: $(DIRS)endifall: default#*****************************************************************************## Generate make.inc from config.h and hwport.h.##*****************************************************************************$(ROOT)/make.inc: $(ROOT)/config.h $(ROOT)/hwport.h @awk -f $(ROOT)/getdefs.awk $(ROOT)/config.h $(ROOT)/hwport.h > \ $(ROOT)/make.inc @if [ "x`grep CROSSTOOLS $(ROOT)/make.inc`" = x ]; \ then \ echo CROSSTOOLS must be defined in config.h!; \ rm $(ROOT)/make.inc; \ exit 1; \ fi @if [ "x`grep NATIVETOOLS $(ROOT)/make.inc`" = x ]; \ then \ echo NATIVETOOLS must be defined in config.h!; \ rm $(ROOT)/make.inc; \ exit 1; \ fi @if [ "x`grep BOARD $(ROOT)/make.inc`" = x ]; \ then \ echo BOARD must be defined in config.h!; \ rm $(ROOT)/make.inc; \ exit 1; \ fi#*****************************************************************************## The following defines are for using GCC to cross compile ARM code.##*****************************************************************************ifeq ($(CROSSTOOLS), gcc)## The names of the various tools.#CC = arm-gccAR = arm-arLD = arm-ldNM = arm-nmOBJCOPY = arm-objcopy## The extension used for executables.#EXEEXT = elf## The extension used for libraries.#LIBEXT = a## The default set of flags for the assembler, compiler, and linker.#AFLAGS = -MD -Wa,-marm7tdmi -DgccCFLAGS = -MD -Wall -pedantic -fno-common -fshort-enums -mcpu=arm7tdmi \ -fno-builtin -mapcsLFLAGS =## Augment the compiler flags based on whether or not a DEBUG version is being# built.#ifdef DEBUGAFLAGS += -Wa,--gdwarf2CFLAGS += -gelseCFLAGS += -O2endif## Augment the assembler and compiler flags based on the set of pre-defined# values.#ifdef DEFINESAFLAGS += $(patsubst %,-D%,$(DEFINES))CFLAGS += $(patsubst %,-D%,$(DEFINES))endif## Augment the linker flags based on the read-only and read-write base, if# specified.#ifdef ROBASELFLAGS += --defsym ROBASE=$(ROBASE)endififdef RWBASELFLAGS += --defsym RWBASE=$(RWBASE)endif## A rule to link the object files together into an executable file.#$(TARGET).$(EXEEXT): $(OBJS) $(LIBS) $(CC) $(LFLAGS) -o $@ $(OBJS) $(LIBS)## A rule to create a ROM image from the object files.#$(TARGET).rom: $(OBJS) $(LIBS) $(TARGET).lds $(LD) $(LFLAGS) -T $(TARGET).lds -o $(TARGET).elf $(OBJS) $(LIBS) $(NM) -n $(TARGET).elf | awk '$$2 != "a" {print}' > $(TARGET).map $(OBJCOPY) -O binary $(TARGET).elf $@## A rule to place the object files into a library.#$(CROSSTOOLS)/$(TARGET).$(LIBEXT): $(OBJS) @if [ ! -d $(CROSSTOOLS) ]; then mkdir $(CROSSTOOLS); fi $(AR) r $@ $(OBJS)## The default rule for generating an object file from an assembly source file.#.S.o: $(CC) $(AFLAGS) -c $<endif#*****************************************************************************## The following defines are for using ARM SDT 2.5.##*****************************************************************************ifeq ($(CROSSTOOLS), sdt25)## The names of the various tools.#AS = armasmCC = armccAR = armlibLD = armlinkFROMELF = fromelf## The extension used for executables.#EXEEXT = axf## The extension used for libraries.#LIBEXT = alf## The default set of flags for the assembler, compiler, and linker.#AFLAGS =CFLAGS = -MD -Wall -fz -Disallow_tentative_statics -zz0LFLAGS = -info size,total -map -noscanlib -remove## Augment the assembler and compiler flags based on whether or not a DEBUG# version is being built.#ifdef DEBUGAFLAGS += -gCFLAGS += -g -zpdebug_inlineselseCFLAGS += -O2 -Otimeendif## Augment the compiler flags based on the set of pre-defined values.#ifdef DEFINESCFLAGS += $(patsubst %,-D%,$(DEFINES))endif## Augment the linker flags based on the read-only base, read-write base, and# first object, if specified.#ifdef ROBASELFLAGS += -ro-base $(ROBASE)endififdef RWBASELFLAGS += -rw-base $(RWBASE)endififdef FIRSTLFLAGS += -first $(FIRST)endif## Convert the names of the libraries from their GCC/Unix (.a) names to the# SDT/Windows (.alf) names.#SDT25LIBS = $(LIBS:.a=.alf)## A rule to link the object files together into an executable file.#$(TARGET).$(EXEEXT): $(OBJS) $(SDT25LIBS)ifneq ($(OBJS), ) @echo $(OBJS) > linker.viaendififneq ($(SDT25LIBS), ) @echo $(SDT25LIBS) >> linker.viaendif $(LD) -remove -o $@ -via linker.via @rm -f linker.via## A rule to extract a ROM image from the executable.#$(TARGET).rom: $(OBJS) $(SDT25LIBS)ifneq ($(OBJS), ) @echo $(OBJS) > linker.viaendififneq ($(SDT25LIBS), ) @echo $(SDT25LIBS) >> linker.viaendif $(LD) $(LFLAGS) -o $(TARGET).$(EXEEXT) -list $(TARGET).map \ -via linker.via @rm -f linker.via $(FROMELF) -nozeropad $(TARGET).$(EXEEXT) -bin $@## A rule to place the object files into a library.#$(CROSSTOOLS)/$(TARGET).$(LIBEXT): $(OBJS) @if [ ! -d $(CROSSTOOLS) ]; then mkdir $(CROSSTOOLS); fi $(AR) -c $@ $(OBJS)## The default rule for generating an object file from an assembly source file.#.S.o: @cp $< $(<:.s=_.c) @$(CC) -Dsdt25 $(CFLAGS) -E $(<:.s=_.c) > __tmp.c @grep -v ^#line __tmp.c > $(<:.s=_.s) $(AS) $(AFLAGS) -o $@ $(<:.s=_.s) @sed s/$(<:.s=_.c)/$</g $(<:.s=_.d) > __tmp.d @sed s/$(<:.s=_.o)/$(<:.s=.o)/g __tmp.d > $(<:.s=.d) @rm -f $(<:.s=_.c) $(<:.s=_.s) $(<:.s=_.d) __tmp.c __tmp.dendif#*****************************************************************************## The following defines are for using ARM ADS 1.0/1.1.##*****************************************************************************ifeq ($(CROSSTOOLS), ads)## The names of the various tools.#AS = armasmCC = armccAR = armarLD = armlinkFROMELF = fromelf## The extension used for executables.#EXEEXT = axf## The extension used for libraries.#LIBEXT = a## The default set of flags for the assembler, compiler, and linker.#AFLAGS =CFLAGS = -MD -WallLFLAGS = -info sizes,totals -map -noscanlib -remove## Augment the assembler and compiler flags based on whether or not a DEBUG# version is being built.#ifdef DEBUGAFLAGS += -gCFLAGS += -gelseCFLAGS += -O2 -Otimeendif## Augment the compiler flags based on the set of pre-defined values.#ifdef DEFINESCFLAGS += $(patsubst %,-D%,$(DEFINES))endif## Augment the linker flags based on the read-only base, read-write base, and# first object, if specified.#ifdef ROBASELFLAGS += -ro-base $(ROBASE)endififdef RWBASELFLAGS += -rw-base $(RWBASE)endififdef FIRSTLFLAGS += -first $(FIRST)endif## A rule to link the object files together into an executable file.#$(TARGET).$(EXEEXT): $(OBJS) $(LIBS)ifneq ($(OBJS), ) @echo $(OBJS) > linker.viaendififneq ($(LIBS), ) @echo $(LIBS) >> linker.viaendif $(LD) -remove -o $@ -via linker.via @rm -f linker.via## A rule to extract a ROM image from the executable.#$(TARGET).rom: $(OBJS) $(LIBS)ifneq ($(OBJS), ) @echo $(OBJS) > linker.viaendififneq ($(LIBS), ) @echo $(LIBS) >> linker.viaendif $(LD) $(LFLAGS) -o $(TARGET).$(EXEEXT) -list $(TARGET).map \ -via linker.via @rm -f linker.via $(FROMELF) -bin -o $@ $(TARGET).$(EXEEXT)## A rule to place the object files into a library.#$(CROSSTOOLS)/$(TARGET).$(LIBEXT): $(OBJS) @if [ ! -d $(CROSSTOOLS) ]; then mkdir $(CROSSTOOLS); fi $(AR) -r $@ $(OBJS)## The default rule for generating an object file from an assembly source file.#.S.o: @cp $< $(<:.s=_.c) @$(CC) -Dads $(CFLAGS) -E $(<:.s=_.c) > __tmp.c @grep -v ^#line __tmp.c > $(<:.s=_.s) $(AS) $(AFLAGS) -o $@ $(<:.s=_.s) @sed s/$(<:.s=_.c)/$</g $(<:.s=_.d) > __tmp.d @sed s/$(<:.s=_.o)/$(<:.s=.o)/g __tmp.d > $(<:.s=.d) @rm -f $(<:.s=_.c) $(<:.s=_.s) $(<:.s=_.d) __tmp.c __tmp.dendif#*****************************************************************************## The following defines are for using GCC to compile native code.##*****************************************************************************ifeq ($(NATIVETOOLS), gcc)## The names of the various tools.#NATIVECC = gcc## The extension used for executables.#PROGEXT =endif#*****************************************************************************## The following defines are for using MSVC to compile native code.##*****************************************************************************ifeq ($(NATIVETOOLS), msvc)## The names of the various tools.#NATIVECC = cl -nologo## The extension used for executables.#PROGEXT = .exeendif#*****************************************************************************## The following are default rules that are used with any tool set.##*****************************************************************************## The default rule for generating an object file from a C source file.#.c.o: $(CC) $(CFLAGS) -c $<## Recursively executes make in each of the subdirectories.#ifdef DIRS.PHONY: $(DIRS)$(DIRS): @$(MAKE) -C $@endif## Clean out the source tree.#.PHONY: cleanclean::ifdef DIRS @for i in $(DIRS); do $(MAKE) -C $$i clean; doneendififdef TARGET @rm -f $(TARGET).$(EXEEXT) $(TARGET).$(LIBEXT) $(TARGET).rom \ $(TARGET).mapendif @rm -f $(wildcard *.o) $(wildcard *.obj) $(wildcard *~) \ $(wildcard *.d) make.inc#*****************************************************************************## The following are default dependencies.##*****************************************************************************## All of the objects depend upon the makefile and the files that it includes.#$(OBJS): makefile $(ROOT)/make.inc $(ROOT)/makedefs## Include the dependencies generated by the build.#-include $(wildcard *.d) __dummy__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -