wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 1 | # |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 2 | # (C) Copyright 2000-2006 |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | # |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0+ |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 6 | # |
| 7 | |
Masahiro Yamada | d958002 | 2014-02-04 17:24:23 +0900 | [diff] [blame] | 8 | ifdef FTRACE |
| 9 | CFLAGS += -finstrument-functions -DFTRACE |
| 10 | endif |
| 11 | |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 12 | extra-y := hello_world |
| 13 | extra-$(CONFIG_SMC91111) += smc91111_eeprom |
| 14 | extra-$(CONFIG_SMC911X) += smc911x_eeprom |
| 15 | extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2 |
| 16 | extra-$(CONFIG_MPC5xxx) += interrupt |
| 17 | extra-$(CONFIG_8xx) += test_burst timer |
| 18 | extra-$(CONFIG_8260) += mem_to_mem_idma2intr |
| 19 | extra-$(CONFIG_PPC) += sched |
Mike Frysinger | 65f6f07 | 2009-07-23 16:37:03 -0400 | [diff] [blame] | 20 | |
Sanjeev Premi | 604f7ce | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 21 | # |
| 22 | # Some versions of make do not handle trailing white spaces properly; |
| 23 | # leading to build failures. The problem was found with GNU Make 3.80. |
| 24 | # Using 'strip' as a workaround for the problem. |
| 25 | # |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 26 | ELF := $(strip $(extra-y)) |
Sanjeev Premi | 604f7ce | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 27 | |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 28 | extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y)) |
| 29 | clean-files := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-)) |
| 30 | |
wdenk | 931da93 | 2005-05-07 19:06:32 +0000 | [diff] [blame] | 31 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 32 | COBJS := $(ELF:=.o) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 33 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 34 | LIB = $(obj)/libstubs.o |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 35 | |
Masahiro Yamada | e8a8b82 | 2013-11-28 12:09:59 +0900 | [diff] [blame] | 36 | LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o |
| 37 | LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o |
| 38 | LIBAOBJS := $(LIBAOBJS-y) |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 39 | |
| 40 | LIBCOBJS = stubs.o |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 41 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 42 | LIBOBJS = $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS)) |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 43 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 44 | SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 45 | OBJS := $(addprefix $(obj)/,$(COBJS)) |
| 46 | ELF := $(addprefix $(obj)/,$(ELF)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 47 | |
Tom Rini | 8386ca8 | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 48 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 49 | |
Peter Tyser | 620bbba | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 50 | # For PowerPC there's no need to compile standalone applications as a |
| 51 | # relocatable executable. The relocation data is not needed, and |
| 52 | # also causes the entry point of the standalone application to be |
| 53 | # inconsistent. |
| 54 | ifeq ($(ARCH),powerpc) |
| 55 | AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS)) |
| 56 | CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS)) |
| 57 | CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS)) |
| 58 | endif |
| 59 | |
Peter Tyser | c91d456 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 60 | # We don't want gcc reordering functions if possible. This ensures that an |
| 61 | # application's entry point will be the first function in the application's |
| 62 | # source file. |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 63 | CFLAGS += $(call cc-option,-fno-toplevel-reorder) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 64 | |
| 65 | ######################################################################### |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 66 | $(LIB): $(LIBOBJS) |
Sebastien Carlier | 6d8962e | 2010-11-05 15:48:07 +0100 | [diff] [blame] | 67 | $(call cmd_link_o_target, $(LIBOBJS)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 68 | |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 69 | $(ELF): |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 70 | $(obj)/%: $(obj)/%.o $(LIB) |
Marek Vasut | e0e7f3b | 2012-03-06 00:44:22 +0100 | [diff] [blame] | 71 | $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \ |
Mike Frysinger | 0858b83 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 72 | -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \ |
Tom Rini | 8386ca8 | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 73 | -L$(gcclibdir) -lgcc |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 74 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 75 | $(obj)/%.srec: $(obj)/% |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 76 | $(OBJCOPY) -O srec $< $@ 2>/dev/null |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 77 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 78 | $(obj)/%.bin: $(obj)/% |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 79 | $(OBJCOPY) -O binary $< $@ 2>/dev/null |