Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / rtas / Makefile.inc
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
8 # *
9 # * Contributors:
10 # *     IBM Corporation - initial implementation
11 # ****************************************************************************/
12
13 # Before including this Makefile, you should specify the following variables
14 # in your Makefile:
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")
21
22
23 LDFLAGS         = -nostdlib
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)
31
32 # Common RTAS files:
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 \
37                   rtas_flash_cfi.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)
41
42 # Common build rules:
43 $(RTAS_OBJ_C):
44         $(CC) $(CPPFLAGS) $(CFLAGS) -c $(@:%.o=$(RTASCMNDIR)/%.c) -o $@
45
46 $(RTAS_OBJ_ASM):
47         $(CC) $(CPPFLAGS) $(ASFLAGS) -c $(@:%.o=$(RTASCMNDIR)/%.S) -o $@
48
49 $(TOOLSDIR)/gen_reloc_table: $(TOOLSDIR)/gen_reloc_table.c
50         $(MAKE) -C $(TOOLSDIR) gen_reloc_table
51
52
53 # Rules for building rtas.bin:
54 rtas.bin: rtas
55         $(OBJCOPY) -O binary $< $@
56
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
60
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
64
65
66 $(LIBCMNDIR)/libc.a:
67         $(MAKE) -C $(LIBCMNDIR) libc
68
69
70 # Rules for cleaning up:
71 clean_rtas:
72         rm -f $(OBJS) reloc_table.o rtas rtas.bin
73         rm -f $(RTASCMNDIR)/*~ $(RTASCMNDIR)/*.o
74
75 distclean_rtas: clean_rtas
76         rm -f Makefile.dep
77
78
79 # Rules for creating the dependency file:
80 depend:
81         rm -f Makefile.dep
82         $(MAKE) Makefile.dep
83
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
87
88 # Include dependency file if available:
89 -include Makefile.dep