]>
Commit | Line | Data |
---|---|---|
500856eb RJ |
1 | # |
2 | # (C) Copyright 2007 Semihalf | |
3 | # | |
1a459660 | 4 | # SPDX-License-Identifier: GPL-2.0+ |
500856eb RJ |
5 | # |
6 | ||
a47a12be | 7 | ifeq ($(ARCH),powerpc) |
500856eb RJ |
8 | LOAD_ADDR = 0x40000 |
9 | endif | |
7fb6c4f9 RJ |
10 | ifeq ($(ARCH),arm) |
11 | LOAD_ADDR = 0x1000000 | |
12 | endif | |
500856eb RJ |
13 | |
14 | include $(TOPDIR)/config.mk | |
15 | ||
117d0ab5 PT |
16 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
17 | OUTPUT-$(CONFIG_API) = $(obj)demo | |
876b3cef PT |
18 | OUTPUT = $(OUTPUT-y) |
19 | ||
d4abc757 | 20 | # Source files located in the examples/api directory |
876b3cef PT |
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 | ||
d4abc757 | 26 | # Source files which exist outside the examples/api directory |
78acc472 PT |
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 | |
a47a12be SR |
33 | ifeq ($(ARCH),powerpc) |
34 | EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o | |
500856eb | 35 | endif |
117d0ab5 | 36 | |
876b3cef PT |
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)) | |
d4abc757 PT |
40 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c)) |
41 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S)) | |
500856eb | 42 | |
876b3cef PT |
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))) | |
500856eb | 48 | |
500856eb RJ |
49 | CPPFLAGS += -I.. |
50 | ||
876b3cef | 51 | all: $(obj).depend $(OUTPUT) |
500856eb RJ |
52 | |
53 | ######################################################################### | |
522f6f02 | 54 | |
876b3cef | 55 | $(OUTPUT): $(OBJS) |
349e83f0 | 56 | $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) |
117d0ab5 | 57 | $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null |
500856eb | 58 | |
876b3cef | 59 | # Rule to build generic library C files |
78acc472 | 60 | $(obj)%.o: $(SRCTREE)/lib/%.c |
876b3cef | 61 | $(CC) -g $(CFLAGS) -c -o $@ $< |
500856eb | 62 | |
876b3cef | 63 | # Rule to build architecture-specific library assembly files |
ea0364f1 | 64 | $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S |
876b3cef | 65 | $(CC) -g $(CFLAGS) -c -o $@ $< |
500856eb RJ |
66 | |
67 | ######################################################################### | |
68 | ||
69 | # defines $(obj).depend target | |
70 | include $(SRCTREE)/rules.mk | |
71 | ||
72 | sinclude $(obj).depend | |
73 | ||
74 | ######################################################################### |