blob: 33cc91ba711b345613ff4b41ab01746e6d0955ad [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
17OUTPUT-$(CONFIG_API) = $(obj)demo
Peter Tyser876b3ce2009-06-22 18:01:41 -050018OUTPUT = $(OUTPUT-y)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010019
Peter Tyserd4abc752009-07-20 19:02:21 -050020# Source files located in the examples/api directory
Peter Tyser876b3ce2009-06-22 18:01:41 -050021SOBJ_FILES-$(CONFIG_API) += crt0.o
22COBJ_FILES-$(CONFIG_API) += demo.o
23COBJ_FILES-$(CONFIG_API) += glue.o
24COBJ_FILES-$(CONFIG_API) += libgenwrap.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010025
Peter Tyserd4abc752009-07-20 19:02:21 -050026# Source files which exist outside the examples/api directory
Peter Tyser78acc472010-04-12 22:28:05 -050027EXT_COBJ_FILES-$(CONFIG_API) += lib/crc32.o
28EXT_COBJ_FILES-$(CONFIG_API) += lib/ctype.o
29EXT_COBJ_FILES-$(CONFIG_API) += lib/div64.o
30EXT_COBJ_FILES-$(CONFIG_API) += lib/string.o
31EXT_COBJ_FILES-$(CONFIG_API) += lib/time.o
32EXT_COBJ_FILES-$(CONFIG_API) += lib/vsprintf.o
Stefan Roesea47a12b2010-04-15 16:07:28 +020033ifeq ($(ARCH),powerpc)
34EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010035endif
Peter Tyser117d0ab2009-06-22 18:01:39 -050036
Peter Tyser876b3ce2009-06-22 18:01:41 -050037# Create a list of source files so their dependencies can be auto-generated
38SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
39SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
Peter Tyserd4abc752009-07-20 19:02:21 -050040SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
41SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010042
Peter Tyser876b3ce2009-06-22 18:01:41 -050043# Create a list of object files to be compiled
44OBJS += $(addprefix $(obj),$(SOBJ_FILES-y))
45OBJS += $(addprefix $(obj),$(COBJ_FILES-y))
46OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
47OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010048
Rafal Jaworowski500856e2008-01-09 19:39:36 +010049CPPFLAGS += -I..
50
Peter Tyser876b3ce2009-06-22 18:01:41 -050051all: $(obj).depend $(OUTPUT)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010052
53#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010054
Peter Tyser876b3ce2009-06-22 18:01:41 -050055$(OUTPUT): $(OBJS)
Rob Herringe32a2682013-10-04 10:22:40 -050056 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
Peter Tyser117d0ab2009-06-22 18:01:39 -050057 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
Rafal Jaworowski500856e2008-01-09 19:39:36 +010058
Peter Tyser876b3ce2009-06-22 18:01:41 -050059# Rule to build generic library C files
Peter Tyser78acc472010-04-12 22:28:05 -050060$(obj)%.o: $(SRCTREE)/lib/%.c
Peter Tyser876b3ce2009-06-22 18:01:41 -050061 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowski500856e2008-01-09 19:39:36 +010062
Peter Tyser876b3ce2009-06-22 18:01:41 -050063# Rule to build architecture-specific library assembly files
Peter Tyserea0364f2010-04-12 22:28:04 -050064$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
Peter Tyser876b3ce2009-06-22 18:01:41 -050065 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowski500856e2008-01-09 19:39:36 +010066
67#########################################################################
68
69# defines $(obj).depend target
70include $(SRCTREE)/rules.mk
71
72sinclude $(obj).depend
73
74#########################################################################