| # | |
| # (C) Copyright 2004-2006, Texas Instruments, <www.ti.com> | |
| # Jian Zhang <jzhang@ti.com> | |
| # | |
| # (C) Copyright 2000-2010 | |
| # Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
| # | |
| # See file CREDITS for list of people who contributed to this | |
| # project. | |
| # | |
| # This program is free software; you can redistribute it and/or | |
| # modify it under the terms of the GNU General Public License as | |
| # published by the Free Software Foundation; either version 2 of | |
| # the License, or (at your option) any later version. | |
| # | |
| # This program is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| # GNU General Public License for more details. | |
| # | |
| # You should have received a copy of the GNU General Public License | |
| # along with this program; if not, write to the Free Software | |
| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
| # MA 02111-1307 USA | |
| # | |
| VERSION = 1 | |
| PATCHLEVEL = 46 | |
| SUBLEVEL = | |
| EXTRAVERSION = | |
| ifneq "$(SUBLEVEL)" "" | |
| X_LOADER_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) | |
| else | |
| X_LOADER_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION) | |
| endif | |
| TIMESTAMP_FILE = $(obj)include/timestamp_autogenerated.h | |
| VERSION_FILE = $(obj)include/version_autogenerated.h | |
| HOSTARCH := $(shell uname -m | \ | |
| sed -e s/i.86/i386/ \ | |
| -e s/sun4u/sparc64/ \ | |
| -e s/arm.*/arm/ \ | |
| -e s/sa110/arm/ \ | |
| -e s/ppc64/powerpc/ \ | |
| -e s/ppc/powerpc/ \ | |
| -e s/macppc/powerpc/\ | |
| -e s/sh.*/sh/) | |
| HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ | |
| sed -e 's/\(cygwin\).*/cygwin/') | |
| # Set shell to bash if possible, otherwise fall back to sh | |
| SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ | |
| else if [ -x /bin/bash ]; then echo /bin/bash; \ | |
| else echo sh; fi; fi) | |
| export HOSTARCH HOSTOS SHELL | |
| # Deal with colliding definitions from tcsh etc. | |
| VENDOR= | |
| ######################################################################### | |
| # Allow for silent builds | |
| ifeq (,$(findstring s,$(MAKEFLAGS))) | |
| XECHO = echo | |
| else | |
| XECHO = : | |
| endif | |
| ######################################################################### | |
| # | |
| # X-loader build supports producing a object files to the separate external | |
| # directory. Two use cases are supported: | |
| # | |
| # 1) Add O= to the make command line | |
| # 'make O=/tmp/build all' | |
| # | |
| # 2) Set environement variable BUILD_DIR to point to the desired location | |
| # 'export BUILD_DIR=/tmp/build' | |
| # 'make' | |
| # | |
| # The second approach can also be used with a MAKEALL script | |
| # 'export BUILD_DIR=/tmp/build' | |
| # './MAKEALL' | |
| # | |
| # Command line 'O=' setting overrides BUILD_DIR environent variable. | |
| # | |
| # When none of the above methods is used the local build is performed and | |
| # the object files are placed in the source directory. | |
| # | |
| ifdef O | |
| ifeq ("$(origin O)", "command line") | |
| BUILD_DIR := $(O) | |
| endif | |
| endif | |
| ifneq ($(BUILD_DIR),) | |
| saved-output := $(BUILD_DIR) | |
| # Attempt to create a output directory. | |
| $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}) | |
| # Verify if it was successful. | |
| BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) | |
| $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist)) | |
| endif # ifneq ($(BUILD_DIR),) | |
| OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) | |
| SRCTREE := $(CURDIR) | |
| TOPDIR := $(SRCTREE) | |
| LNDIR := $(OBJTREE) | |
| export TOPDIR SRCTREE OBJTREE | |
| MKCONFIG := $(SRCTREE)/mkconfig | |
| export MKCONFIG | |
| ifneq ($(OBJTREE),$(SRCTREE)) | |
| REMOTE_BUILD := 1 | |
| export REMOTE_BUILD | |
| endif | |
| # $(obj) and (src) are defined in config.mk but here in main Makefile | |
| # we also need them before config.mk is included which is the case for | |
| # some targets like unconfig, clean, clobber, distclean, etc. | |
| ifneq ($(OBJTREE),$(SRCTREE)) | |
| obj := $(OBJTREE)/ | |
| src := $(SRCTREE)/ | |
| else | |
| obj := | |
| src := | |
| endif | |
| export obj src | |
| ######################################################################### | |
| # The "tools" are needed early, so put this first | |
| # Don't include stuff already done in $(LIBS) | |
| SUBDIRS = tools | |
| .PHONY : $(SUBDIRS) | |
| ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk)) | |
| # Include autoconf.mk before config.mk so that the config options are available | |
| # to all top level build files. We need the dummy all: target to prevent the | |
| # dependency target in autoconf.mk.dep from being the default. | |
| all: | |
| sinclude $(obj)include/autoconf.mk.dep | |
| sinclude $(obj)include/autoconf.mk | |
| # load ARCH, BOARD, and CPU configuration | |
| include $(obj)include/config.mk | |
| export ARCH CPU BOARD VENDOR SOC | |
| # set default to nothing for native builds | |
| ifeq ($(HOSTARCH),$(ARCH)) | |
| CROSS_COMPILE ?= | |
| endif | |
| # load other configuration | |
| include $(TOPDIR)/config.mk | |
| ######################################################################### | |
| # X-Load objects....order is important (i.e. start must be first) | |
| OBJS = $(CPUDIR)/start.o | |
| OBJS := $(addprefix $(obj),$(OBJS)) | |
| LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \ | |
| "board/$(VENDOR)/common/lib$(VENDOR).a"; fi) | |
| LIBS += $(CPUDIR)/lib$(CPU).a | |
| LIBS += lib/lib$(ARCH).a | |
| LIBS += common/libcommon.a | |
| LIBS += fs/fat/libfat.a | |
| LIBS += disk/libdisk.a | |
| LIBS += drivers/mtd/nand/libnand.a | |
| LIBS += drivers/mtd/onenand/libonenand.a | |
| LIBS += drivers/rtc/librtc.a | |
| LIBS += drivers/serial/libserial.a | |
| LIBS += drivers/usb/libusb.a | |
| LIBS := $(addprefix $(obj),$(LIBS)) | |
| .PHONY : $(LIBS) $(TIMESTAMP_FILE) $(VERSION_FILE) | |
| LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a | |
| LIBBOARD := $(addprefix $(obj),$(LIBBOARD)) | |
| # Add GCC lib | |
| PLATFORM_LIBGCC = -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc | |
| PLATFORM_LIBS += $(PLATFORM_LIBGCC) | |
| export PLATFORM_LIBS | |
| __OBJS := $(subst $(obj),,$(OBJS)) | |
| __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD)) | |
| ######################################################################### | |
| ######################################################################### | |
| # Always append ALL so that arch config.mk's can add custom ones | |
| ALL += $(obj)x-load.srec $(obj)x-load.bin $(obj)x-load.bin.ift $(obj)System.map | |
| all: $(ALL) | |
| $(obj)x-load.hex: $(obj)x-load | |
| $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ | |
| $(obj)x-load.srec: $(obj)x-load | |
| $(OBJCOPY) -O srec $< $@ | |
| $(obj)x-load.bin: $(obj)x-load | |
| $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ | |
| $(obj)x-load.bin.ift: $(obj)x-load.bin | |
| $(obj)tools/signGP $< | |
| $(obj)x-load.dis: $(obj)x-load | |
| $(OBJDUMP) -d $< > $@ | |
| GEN_XLOAD = \ | |
| UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ | |
| sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ | |
| cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ | |
| --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ | |
| -Map x-load.map -o x-load | |
| $(obj)x-load: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)x-load.lds | |
| $(GEN_XLOAD) | |
| $(OBJS): depend | |
| $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@)) | |
| $(LIBS): depend $(SUBDIRS) | |
| $(MAKE) -C $(dir $(subst $(obj),,$@)) | |
| $(LIBBOARD): depend $(LIBS) | |
| $(MAKE) -C $(dir $(subst $(obj),,$@)) | |
| $(SUBDIRS): depend | |
| $(MAKE) -C $@ all | |
| $(LDSCRIPT): depend | |
| $(MAKE) -C $(dir $@) $(notdir $@) | |
| $(obj)x-load.lds: $(LDSCRIPT) | |
| $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ | |
| $(obj)oneboot: $(obj)x-load.bin | |
| scripts/mkoneboot.sh | |
| $(VERSION_FILE): | |
| @( printf '#define X_LOADER_VERSION "Texas Instruments X-Loader %s%s"\n' "$(X_LOADER_VERSION)" \ | |
| '$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ) > $@.tmp | |
| @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ | |
| $(TIMESTAMP_FILE): | |
| @LC_ALL=C date +'#define X_LOADER_DATE "%b %d %C%y"' > $@ | |
| @LC_ALL=C date +'#define X_LOADER_TIME "%T"' >> $@ | |
| # Explicitly make _depend in subdirs containing multiple targets to prevent | |
| # parallel sub-makes creating .depend files simultaneously. | |
| depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) | |
| for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \ | |
| $(MAKE) -C $$dir _depend ; done | |
| TAG_SUBDIRS = $(SUBDIRS) | |
| TAG_SUBDIRS += $(dir $(__LIBS)) | |
| TAG_SUBDIRS += include | |
| tags ctags: | |
| ctags -w -o $(obj)ctags `find $(TAG_SUBDIRS) \ | |
| -name '*.[chS]' -print` | |
| etags: | |
| etags -a -o $(obj)etags `find $(TAG_SUBDIRS) \ | |
| -name '*.[chS]' -print` | |
| cscope: | |
| find $(TAG_SUBDIRS) -name '*.[chS]' -print > cscope.files | |
| cscope -b -q -k | |
| SYSTEM_MAP = \ | |
| $(NM) $1 | \ | |
| grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ | |
| LC_ALL=C sort | |
| $(obj)System.map: $(obj)x-load | |
| @$(call SYSTEM_MAP,$<) > $(obj)System.map | |
| ######################################################################### | |
| else # !config.mk | |
| all $(obj)x-load.hex $(obj)x-load.srec $(obj)x-load.bin \ | |
| $(obj)x-load.dis $(obj)x-load \ | |
| $(obj)oneboot \ | |
| $(filter-out tools,$(SUBDIRS)) $(TIMESTAMP_FILE) $(VERSION_FILE) \ | |
| depend dep tags ctags etags cscope $(obj)System.map: | |
| @echo "System not configured - see README" >&2 | |
| @ exit 1 | |
| tools: | |
| $(MAKE) -C tools | |
| tools-all: | |
| $(MAKE) -C tools HOST_TOOLS_ALL=y | |
| endif # config.mk | |
| ######################################################################### | |
| unconfig: | |
| @rm -f $(obj)include/config.h $(obj)include/config.mk | |
| %_config:: unconfig | |
| @$(MKCONFIG) -A $(@:_config=) | |
| # | |
| # Functions to generate common board directory names | |
| # | |
| lcname = $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/') | |
| ucname = $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/') | |
| #======================================================================== | |
| # ARM | |
| #======================================================================== | |
| ######################################################################### | |
| ## OMAP1 (ARM92xT) Systems | |
| ######################################################################### | |
| omap1710h3_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm arm926ejs omap1710h3 | |
| ######################################################################### | |
| ## OMAP2 (ARM1136) Systems | |
| ######################################################################### | |
| omap2420h4_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm arm1136 omap2420h4 | |
| omap2430sdp_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm arm1136 omap2430sdp | |
| ######################################################################### | |
| ## OMAP3 (ARM-CortexA8) Systems | |
| ######################################################################### | |
| omap3430sdp_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm omap3 omap3430sdp | |
| omap3430labrador_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm omap3 omap3430labrador | |
| omap3evm_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm omap3 omap3evm | |
| am3517evm_config : unconfig | |
| @$(MKCONFIG) $(@:_config=) arm omap3 am3517evm | |
| ######################################################################### | |
| ######################################################################### | |
| clean: | |
| @rm -f $(obj)tools/signGP | |
| @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE) | |
| @find $(OBJTREE) -type f \ | |
| \( -name 'core' -o -name '*.bak' -o -name '*~' \ | |
| -o -name '*.o' -o -name '*.a' -o -name '*.exe' \) -print \ | |
| | xargs rm -f | |
| clobber: clean | |
| @find $(OBJTREE) -type f \( -name .depend \ | |
| -o -name '*.srec' -o -name '*.bin' -o -name '*.bin.ift' \) \ | |
| -print0 \ | |
| | xargs -0 rm -f | |
| @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \ | |
| $(obj)cscope.* $(obj)*.*~ | |
| @rm -f $(obj)x-load $(obj)x-load.map $(obj)x-load.hex $(ALL) | |
| @rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm | |
| ifeq ($(OBJTREE),$(SRCTREE)) | |
| mrproper \ | |
| distclean: clobber unconfig | |
| else | |
| mrproper \ | |
| distclean: clobber unconfig | |
| rm -rf $(obj)* | |
| endif | |
| backup: | |
| F=`basename $(TOPDIR)` ; cd .. ; \ | |
| gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F | |
| ######################################################################### |