blob: 4d683400e14a1cc8b7da23ea4408356f5353b8b2 [file] [log] [blame]
Rafal Jaworowskia19be782008-01-09 19:39:36 +01001#
2# (C) Copyright 2007 Semihalf
3#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowskia19be782008-01-09 19:39:36 +01005#
6
Stefan Roese88fbf932010-04-15 16:07:28 +02007ifeq ($(ARCH),powerpc)
Rafal Jaworowskia19be782008-01-09 19:39:36 +01008LOAD_ADDR = 0x40000
9endif
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010010ifeq ($(ARCH),arm)
11LOAD_ADDR = 0x1000000
12endif
Rafal Jaworowskia19be782008-01-09 19:39:36 +010013
14include $(TOPDIR)/config.mk
15
Peter Tyser2dcb4e12009-06-22 18:01:39 -050016# Resulting ELF and binary exectuables will be named demo and demo.bin
17OUTPUT-$(CONFIG_API) = $(obj)demo
Peter Tyserbdb925e2009-06-22 18:01:41 -050018OUTPUT = $(OUTPUT-y)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010019
Peter Tyseracce4eb2009-07-20 19:02:21 -050020# Source files located in the examples/api directory
Peter Tyserbdb925e2009-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 Jaworowskia19be782008-01-09 19:39:36 +010025
Peter Tyseracce4eb2009-07-20 19:02:21 -050026# Source files which exist outside the examples/api directory
Peter Tyser685b7f52010-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 Roese88fbf932010-04-15 16:07:28 +020033ifeq ($(ARCH),powerpc)
34EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010035endif
Peter Tyser2dcb4e12009-06-22 18:01:39 -050036
Peter Tyserbdb925e2009-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 Tyseracce4eb2009-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 Jaworowskia19be782008-01-09 19:39:36 +010042
Peter Tyserbdb925e2009-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 Jaworowskia19be782008-01-09 19:39:36 +010048
Rafal Jaworowskia19be782008-01-09 19:39:36 +010049CPPFLAGS += -I..
50
Peter Tyserbdb925e2009-06-22 18:01:41 -050051all: $(obj).depend $(OUTPUT)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010052
53#########################################################################
Rafal Jaworowskia19be782008-01-09 19:39:36 +010054
Peter Tyserbdb925e2009-06-22 18:01:41 -050055$(OUTPUT): $(OBJS)
Che-liang Chioud74a67f2011-10-17 21:04:15 +000056 $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
Peter Tyser2dcb4e12009-06-22 18:01:39 -050057 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
Rafal Jaworowskia19be782008-01-09 19:39:36 +010058
Peter Tyserbdb925e2009-06-22 18:01:41 -050059# Rule to build generic library C files
Peter Tyser685b7f52010-04-12 22:28:05 -050060$(obj)%.o: $(SRCTREE)/lib/%.c
Peter Tyserbdb925e2009-06-22 18:01:41 -050061 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowskia19be782008-01-09 19:39:36 +010062
Peter Tyserbdb925e2009-06-22 18:01:41 -050063# Rule to build architecture-specific library assembly files
Peter Tysercede5d82010-04-12 22:28:04 -050064$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
Peter Tyserbdb925e2009-06-22 18:01:41 -050065 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowskia19be782008-01-09 19:39:36 +010066
67#########################################################################
68
69# defines $(obj).depend target
70include $(SRCTREE)/rules.mk
71
72sinclude $(obj).depend
73
74#########################################################################