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 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 8 | include $(TOPDIR)/config.mk |
| 9 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 10 | ELF-$(ARCH) := |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 11 | ELF-$(CPU) := |
| 12 | ELF-y := hello_world |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 13 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 14 | ELF-$(CONFIG_SMC91111) += smc91111_eeprom |
| 15 | ELF-$(CONFIG_SMC911X) += smc911x_eeprom |
| 16 | ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2 |
| 17 | ELF-i386 += 82559_eeprom |
| 18 | ELF-mpc5xxx += interrupt |
| 19 | ELF-mpc8xx += test_burst timer |
| 20 | ELF-mpc8260 += mem_to_mem_idma2intr |
| 21 | ELF-ppc += sched |
Mike Frysinger | 65f6f07 | 2009-07-23 16:37:03 -0400 | [diff] [blame] | 22 | |
Sanjeev Premi | 604f7ce | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 23 | # |
| 24 | # Some versions of make do not handle trailing white spaces properly; |
| 25 | # leading to build failures. The problem was found with GNU Make 3.80. |
| 26 | # Using 'strip' as a workaround for the problem. |
| 27 | # |
Masahiro Yamada | 13b213b | 2013-11-11 12:45:40 +0900 | [diff] [blame^] | 28 | ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(CPU))) |
Sanjeev Premi | 604f7ce | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 29 | |
Che-liang Chiou | 0da4389 | 2011-02-21 21:07:00 +0000 | [diff] [blame] | 30 | SREC := $(addsuffix .srec,$(ELF)) |
| 31 | BIN := $(addsuffix .bin,$(ELF)) |
wdenk | 931da93 | 2005-05-07 19:06:32 +0000 | [diff] [blame] | 32 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 33 | COBJS := $(ELF:=.o) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 34 | |
Sebastien Carlier | 6d8962e | 2010-11-05 15:48:07 +0100 | [diff] [blame] | 35 | LIB = $(obj)libstubs.o |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 36 | |
| 37 | LIBAOBJS-$(ARCH) := |
| 38 | LIBAOBJS-$(CPU) := |
| 39 | LIBAOBJS-ppc += $(ARCH)_longjmp.o $(ARCH)_setjmp.o |
| 40 | LIBAOBJS-mpc8xx += test_burst_lib.o |
| 41 | LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU)) |
| 42 | |
| 43 | LIBCOBJS = stubs.o |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 44 | |
| 45 | LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS)) |
| 46 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 47 | SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 48 | OBJS := $(addprefix $(obj),$(COBJS)) |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 49 | ELF := $(addprefix $(obj),$(ELF)) |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 50 | BIN := $(addprefix $(obj),$(BIN)) |
| 51 | SREC := $(addprefix $(obj),$(SREC)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 52 | |
Tom Rini | 8386ca8 | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 53 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 54 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 55 | CPPFLAGS += -I.. |
| 56 | |
Peter Tyser | 620bbba | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 57 | # For PowerPC there's no need to compile standalone applications as a |
| 58 | # relocatable executable. The relocation data is not needed, and |
| 59 | # also causes the entry point of the standalone application to be |
| 60 | # inconsistent. |
| 61 | ifeq ($(ARCH),powerpc) |
| 62 | AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS)) |
| 63 | CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS)) |
| 64 | CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS)) |
| 65 | endif |
| 66 | |
Peter Tyser | c91d456 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 67 | # We don't want gcc reordering functions if possible. This ensures that an |
| 68 | # application's entry point will be the first function in the application's |
| 69 | # source file. |
Wolfgang Denk | cca4e4a | 2011-11-01 20:54:02 +0000 | [diff] [blame] | 70 | CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder) |
| 71 | CFLAGS += $(CFLAGS_NTR) |
Peter Tyser | c91d456 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 72 | |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 73 | all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 74 | |
| 75 | ######################################################################### |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 76 | $(LIB): $(obj).depend $(LIBOBJS) |
Sebastien Carlier | 6d8962e | 2010-11-05 15:48:07 +0100 | [diff] [blame] | 77 | $(call cmd_link_o_target, $(LIBOBJS)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 78 | |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 79 | $(ELF): |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 80 | $(obj)%: $(obj)%.o $(LIB) |
Marek Vasut | e0e7f3b | 2012-03-06 00:44:22 +0100 | [diff] [blame] | 81 | $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \ |
Mike Frysinger | 0858b83 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 82 | -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \ |
Tom Rini | 8386ca8 | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 83 | -L$(gcclibdir) -lgcc |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 84 | |
| 85 | $(SREC): |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 86 | $(obj)%.srec: $(obj)% |
| 87 | $(OBJCOPY) -O srec $< $@ 2>/dev/null |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 88 | |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 89 | $(BIN): |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 90 | $(obj)%.bin: $(obj)% |
| 91 | $(OBJCOPY) -O binary $< $@ 2>/dev/null |
wdenk | dc7c9a1 | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 92 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 93 | ######################################################################### |
| 94 | |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 95 | # defines $(obj).depend target |
| 96 | include $(SRCTREE)/rules.mk |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 97 | |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 98 | sinclude $(obj).depend |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 99 | |
| 100 | ######################################################################### |