]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - examples/api/Makefile
1cefbe777d469b117a28530b4d7ad4314ff2a6a1
[karo-tx-uboot.git] / examples / api / Makefile
1 #
2 # (C) Copyright 2007 Semihalf
3 #
4 # SPDX-License-Identifier:      GPL-2.0+
5 #
6
7 ifeq ($(ARCH),powerpc)
8 LOAD_ADDR = 0x40000
9 endif
10 ifeq ($(ARCH),arm)
11 LOAD_ADDR = 0x1000000
12 endif
13
14 include $(TOPDIR)/config.mk
15
16 # Resulting ELF and binary exectuables will be named demo and demo.bin
17 OUTPUT-$(CONFIG_API) = $(obj)demo
18 OUTPUT = $(OUTPUT-y)
19
20 # Source files located in the examples/api directory
21 SOBJ_FILES-$(CONFIG_API) += crt0.o
22 COBJ_FILES-$(CONFIG_API) += demo.o
23 COBJ_FILES-$(CONFIG_API) += glue.o
24 COBJ_FILES-$(CONFIG_API) += libgenwrap.o
25
26 # Source files which exist outside the examples/api directory
27 EXT_COBJ_FILES-$(CONFIG_API) += lib/crc32.o
28 EXT_COBJ_FILES-$(CONFIG_API) += lib/ctype.o
29 EXT_COBJ_FILES-$(CONFIG_API) += lib/div64.o
30 EXT_COBJ_FILES-$(CONFIG_API) += lib/string.o
31 EXT_COBJ_FILES-$(CONFIG_API) += lib/time.o
32 EXT_COBJ_FILES-$(CONFIG_API) += lib/vsprintf.o
33 ifeq ($(ARCH),powerpc)
34 EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o
35 endif
36
37 # Create a list of source files so their dependencies can be auto-generated
38 SRCS    += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
39 SRCS    += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
40 SRCS    += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
41 SRCS    += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
42
43 # Create a list of object files to be compiled
44 OBJS    += $(addprefix $(obj),$(SOBJ_FILES-y))
45 OBJS    += $(addprefix $(obj),$(COBJ_FILES-y))
46 OBJS    += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
47 OBJS    += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
48
49 all:    $(obj).depend $(OUTPUT)
50
51 #########################################################################
52
53 $(OUTPUT):      $(OBJS)
54                 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
55                 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
56
57 # Rule to build generic library C files
58 $(obj)%.o: $(SRCTREE)/lib/%.c
59         $(CC) -g $(CFLAGS) -c -o $@ $<
60
61 # Rule to build architecture-specific library assembly files
62 $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
63         $(CC) -g $(CFLAGS) -c -o $@ $<
64
65 #########################################################################
66
67 # defines $(obj).depend target
68 include $(SRCTREE)/rules.mk
69
70 sinclude $(obj).depend
71
72 #########################################################################