blob: cad10a3ecb453cafa1fa3f472dbe0633fc0f691f [file] [log] [blame]
Rafal Jaworowski500856e2008-01-09 19:39:36 +01001#
2# (C) Copyright 2007 Semihalf
3#
Wolfgang Denk1a459662013-07-08 09:37:19 +02004# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowski500856e2008-01-09 19:39:36 +01005#
6
Stefan Roesea47a12b2010-04-15 16:07:28 +02007ifeq ($(ARCH),powerpc)
Rafal Jaworowski500856e2008-01-09 19:39:36 +01008LOAD_ADDR = 0x40000
9endif
Rafal Jaworowski7fb6c4f2009-01-23 13:27:16 +010010ifeq ($(ARCH),arm)
11LOAD_ADDR = 0x1000000
12endif
Rafal Jaworowski500856e2008-01-09 19:39:36 +010013
14include $(TOPDIR)/config.mk
15
Peter Tyser117d0ab2009-06-22 18:01:39 -050016# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090017OUTPUT = $(obj)demo
Rafal Jaworowski500856e2008-01-09 19:39:36 +010018
Peter Tyserd4abc752009-07-20 19:02:21 -050019# Source files located in the examples/api directory
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090020SOBJ_FILES-y += crt0.o
21COBJ_FILES-y += demo.o
22COBJ_FILES-y += glue.o
23COBJ_FILES-y += libgenwrap.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010024
Peter Tyserd4abc752009-07-20 19:02:21 -050025# Source files which exist outside the examples/api directory
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090026EXT_COBJ_FILES-y += lib/crc32.o
27EXT_COBJ_FILES-y += lib/ctype.o
28EXT_COBJ_FILES-y += lib/div64.o
29EXT_COBJ_FILES-y += lib/string.o
30EXT_COBJ_FILES-y += lib/time.o
31EXT_COBJ_FILES-y += lib/vsprintf.o
32EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Peter Tyser117d0ab2009-06-22 18:01:39 -050033
Peter Tyser876b3ce2009-06-22 18:01:41 -050034# Create a list of source files so their dependencies can be auto-generated
35SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
36SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
Peter Tyserd4abc752009-07-20 19:02:21 -050037SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
38SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010039
Peter Tyser876b3ce2009-06-22 18:01:41 -050040# Create a list of object files to be compiled
41OBJS += $(addprefix $(obj),$(SOBJ_FILES-y))
42OBJS += $(addprefix $(obj),$(COBJ_FILES-y))
43OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
44OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010045
Peter Tyser876b3ce2009-06-22 18:01:41 -050046all: $(obj).depend $(OUTPUT)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010047
48#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010049
Peter Tyser876b3ce2009-06-22 18:01:41 -050050$(OUTPUT): $(OBJS)
Rob Herringe32a2682013-10-04 10:22:40 -050051 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
Peter Tyser117d0ab2009-06-22 18:01:39 -050052 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
Rafal Jaworowski500856e2008-01-09 19:39:36 +010053
Peter Tyser876b3ce2009-06-22 18:01:41 -050054# Rule to build generic library C files
Peter Tyser78acc472010-04-12 22:28:05 -050055$(obj)%.o: $(SRCTREE)/lib/%.c
Peter Tyser876b3ce2009-06-22 18:01:41 -050056 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowski500856e2008-01-09 19:39:36 +010057
Peter Tyser876b3ce2009-06-22 18:01:41 -050058# Rule to build architecture-specific library assembly files
Peter Tyserea0364f2010-04-12 22:28:04 -050059$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
Peter Tyser876b3ce2009-06-22 18:01:41 -050060 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowski500856e2008-01-09 19:39:36 +010061
62#########################################################################
63
64# defines $(obj).depend target
65include $(SRCTREE)/rules.mk
66
67sinclude $(obj).depend
68
69#########################################################################