1 # *****************************************************************************
2 # * Copyright (c) 2004, 2008 IBM Corporation
3 # * All rights reserved.
4 # * This program and the accompanying materials
5 # * are made available under the terms of the BSD License
6 # * which accompanies this distribution, and is available at
7 # * http://www.opensource.org/licenses/bsd-license.php
10 # * IBM Corporation - initial implementation
11 # ****************************************************************************/
13 # Before including this Makefile, you should specify the following variables
15 # - RTASCMNDIR : Points to the common RTAS directory
16 # - RTASBRDDIR : Points to the board specific RTAS directory
17 # - TOOLSDIR : Points to the common tools directory
18 # - OBJS : A list with all object files that should be linked into rtas.bin
19 # - BOARD_SRCS : A list with all board specific source code files
20 # (needed for "make depend")
24 CPPFLAGS += -I$(RTASBRDDIR) -I$(RTASCMNDIR) \
25 -I$(INCLCMNDIR) -I$(INCLBRDDIR) \
26 -I$(LIBCMNDIR)/libc/include \
27 -I$(INCLCMNDIR)/$(CPUARCH)
28 ASFLAGS = -Wa,-mregnames $(FLAG)
29 CFLAGS += -g -nostdinc -ffreestanding -Wall -Wextra -O2 -msoft-float \
30 -mno-altivec -mabi=no-altivec $(FLAG)
33 RTAS_SRC_ASM = reloc.S rtas_common.S rtas_entry.S rtas_term.S \
34 rtas_cpu.S rtas_flash_asm.S rtas_mem.S rtas_ras.S
35 RTAS_SRC_C = rtas_call.c rtas_flash_c.c rtas_h8.c \
36 rtas_nvramlog.c rtas_sensor.c rtas_init.c \
38 RTAS_SRCS = $(RTAS_SRC_ASM) $(RTAS_SRC_C)
39 RTAS_OBJ_ASM = $(RTAS_SRC_ASM:%.S=%.o)
40 RTAS_OBJ_C = $(RTAS_SRC_C:%.c=%.o)
44 $(CC) $(CPPFLAGS) $(CFLAGS) -c $(@:%.o=$(RTASCMNDIR)/%.c) -o $@
47 $(CC) $(CPPFLAGS) $(ASFLAGS) -c $(@:%.o=$(RTASCMNDIR)/%.S) -o $@
49 $(TOOLSDIR)/gen_reloc_table: $(TOOLSDIR)/gen_reloc_table.c
50 $(MAKE) -C $(TOOLSDIR) gen_reloc_table
53 # Rules for building rtas.bin:
55 $(OBJCOPY) -O binary $< $@
57 rtas: $(RTASCMNDIR)/rtas.lds $(OBJS) reloc_table.o $(LIBCMNDIR)/libc.a
58 $(LD) $(LDFLAGS) -o $@ -T $(RTASCMNDIR)/rtas.lds $(OBJS) \
59 reloc_table.o $(LIBCMNDIR)/libc.a
61 reloc_table.o: $(TOOLSDIR)/gen_reloc_table $(OBJS) $(LIBCMNDIR)/libc.a
62 $(TOOLSDIR)/create_reloc_table.sh --ld "$(ONLY_LD)" --ldflags "$(LDFLAGS)" \
63 --lds "$(RTASCMNDIR)/rtas.lds" --objcopy "$(OBJCOPY)" $(OBJS) $(LIBCMNDIR)/libc.a
67 $(MAKE) -C $(LIBCMNDIR) libc
70 # Rules for cleaning up:
72 rm -f $(OBJS) reloc_table.o rtas rtas.bin
73 rm -f $(RTASCMNDIR)/*~ $(RTASCMNDIR)/*.o
75 distclean_rtas: clean_rtas
79 # Rules for creating the dependency file:
84 Makefile.dep: Makefile $(RTASCMNDIR)/Makefile.inc
85 $(CC) -MM $(CPPFLAGS) $(CFLAGS) $(RTAS_SRCS:%=$(RTASCMNDIR)/%) > Makefile.dep
86 $(CC) -MM $(CPPFLAGS) $(CFLAGS) $(BOARD_SRCS) >> Makefile.dep
88 # Include dependency file if available: