Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / slof / 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 # - INCLCMNDIR : Points to the common include directory
16 # - INCLCMNDIR : Points to the board specific include directory
17 # - SLOFCMNDIR : Points to the common SLOF directory
18 # - SLOFBRDDIR : Points to the board specific SLOF directory
19 # - LLFWCMNDIR : Points to the common LLFW directory
20 # - LLFWBRDDIR : Points to the board specific LLFW directory
21
22 # Set LLFW directories (should normally be set from parent Makefile):
23 TOPBRDDIR ?= $(shell cd .. && pwd)
24 LLFWBRDDIR ?= $(TOPBRDDIR)/llfw
25 LLFWCMNDIR ?= $(SLOFCMNDIR:%/slof=%/llfw)
26 INCLBRDDIR ?= $(TOPBRDDIR)/include
27
28
29 CPPFLAGS += -I. -I$(INCLCMNDIR) -I$(INCLBRDDIR) -I$(INCLCMNDIR)/$(CPUARCH)
30 CFLAGS  = -DTARG=$(TARG) -static -Wall -W -std=gnu99 \
31           -O2 -fomit-frame-pointer -msoft-float $(FLAG) $(CPUARCHDEF) \
32           -fno-stack-protector -fno-strict-aliasing 
33 ASFLAGS = -Wa,-mpower4 -Wa,-mregnames $(FLAG) $(CPUARCHDEF)
34
35 LDFLAGS += -static -nostdlib -Wl,-q,-n
36
37 ifneq ($(TARG),unix)
38 CFLAGS  += -nostdinc -fno-builtin
39 CPPFLAGS += -I$(LIBCMNDIR)/libc/include
40 SLOF_LIBS += $(LIBCMNDIR)/libc.a
41 endif
42
43 DICT = $(SLOFCMNDIR)/prim.in $(SLOFCMNDIR)/engine.in \
44         $(BOARD_SLOF_IN) $(SLOFCMNDIR)/$(TARG).in
45
46 # Source code files with automatic dependencies:
47 SLOF_BUILD_SRCS = paflof.c helpers.c allocator.c
48
49 # Flags for pre-processing Forth code with CPP:
50 FPPFLAGS = -nostdinc -traditional-cpp -undef -P -C $(FLAG)
51 FPPINCLUDES ?= -I$(SLOFBRDDIR) -I$(SLOFCMNDIR)/fs
52
53 # Rules for pre-processing Forth code:
54 # - Use CPP for pre-processing #include directives
55 # - Use sed to strip all white spaces at the beginning of a line
56 # - Use sed to remove all lines that only contain a comment
57 # - Use sed to remove all empty lines from the file
58 %.fsi: %.fs
59 ifeq ($(V),1)
60         printf "\t[FPP]\t%s\n" `basename "$@"`
61 endif
62         rm -f $@
63         cpp $(FPPFLAGS) $(FPPINCLUDES) $< > $@.tmp
64         sed -e 's/^[     ]*//' < $@.tmp \
65           | sed -e '/^\\[        ]/d' \
66           | sed -e '/^([         ][^)]*[         ])[     ]*$$/d' \
67           | sed -e '/^$$/d' > $@
68         rm -f $@.tmp
69
70
71 OF.o:   OF.fsi
72         $(LD) -o $@ -r -bbinary $<
73
74
75 dict.xt: $(DICT) $(SLOFCMNDIR)/ref.pl 
76         cat $(DICT) | perl $(SLOFCMNDIR)/ref.pl -s $(CELLSIZE) > dict.xt
77
78 ifdef BOARD_SLOF_CODE
79 board.code: $(BOARD_SLOF_CODE)
80         cat $(BOARD_SLOF_CODE) > $@
81 else
82 board.code:
83         echo > $@
84 endif
85
86 paflof: $(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o paflof.o $(SLOFCMNDIR)/entry.o \
87         helpers.o allocator.o romfs.o version.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
88         $(LLFWBRDDIR)/io_generic_lib.o $(SLOF_LIBS)
89         $(CC) -T$(SLOFCMNDIR)/OF.lds $(SLOFCMNDIR)/ofw.o version.o paflof.o helpers.o allocator.o \
90         $(SLOFCMNDIR)/entry.o romfs.o OF.o nvramlog.o $(LLFWBRDDIR)/board_io.o \
91         $(LLFWBRDDIR)/io_generic_lib.o $(LDFLAGS) $(SLOF_LIBS) -o $@
92         #save a copy of paflof before stripping
93         @cp $@ $@.unstripped
94         $(STRIP) --strip-unneeded $@
95
96 paflof.o: board.code dict.xt
97         $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/paflof.c
98
99 helpers.o:
100         $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/helpers.c
101
102 allocator.o:
103         $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/allocator.c
104
105 $(SLOFCMNDIR)/xvect.bin: $(SLOFCMNDIR)/lowmem.o
106         $(CC) $(LDFLAGS) -Wl,--oformat,binary -Ttext=0x100 -o xvect.bin.tmp $<
107         dd if=xvect.bin.tmp of=$(SLOFCMNDIR)/xvect.bin bs=256 skip=1 2>/dev/null
108         rm -f xvect.bin.tmp
109
110 romfs.o:
111         $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $(LLFWCMNDIR)/romfs.S
112
113 nvramlog.o:
114         $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $(LLFWCMNDIR)/nvramlog.S
115
116 checkpoint.o:
117         $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $(LLFWCMNDIR)/checkpoint.S
118
119 $(LLFWBRDDIR)/board_io.o:
120         $(MAKE) -C $(LLFWBRDDIR) board_io.o
121
122 $(LLFWBRDDIR)/io_generic_lib.o:
123         $(MAKE) -C $(LLFWBRDDIR) io_generic_lib.o
124
125 default-font.o: $(SLOFCMNDIR)/default-font.c
126         $(CC) $(CPPFLAGS) $< -c -o default-font.o
127
128 $(SLOFBRDDIR)/default-font.bin: default-font.o
129         $(OBJCOPY) -Obinary default-font.o $@ 
130
131 .PHONY : create_OF.ffs clean_slof distclean_slof depend
132
133
134 # Create OF.ffs automatically from file list in OF_FFS_FILES variable.
135 # We have to use absolute path names there, so we have to use `pwd` to
136 # find them out:
137 create_OF_ffs:
138         rm -f OF.ffs
139         @for i in $(OF_FFS_FILES) ; do \
140                 CURRENTDIR=`pwd` ; cd `dirname $$i` ; \
141                 DIRNAME=`pwd` ; cd $$CURRENTDIR ; \
142                 echo `basename $$i | sed  -e s/\.fsi/\.fs/` \
143                      $$DIRNAME/`basename $$i` 0 0 >> OF.ffs ; \
144          done
145
146
147 # Targets for cleaning up:
148 clean_slof:
149         rm -f $(SLOFCMNDIR)/*.o $(SLOFCMNDIR)/*.bin $(SLOFCMNDIR)/*.elf
150         rm -f dict.xt board.code paflof paflof.unstripped default-font.bin
151         rm -f $(filter %.fsi,$(OF_FFS_FILES))
152
153 distclean_slof: clean_slof
154         rm -f Makefile.dep
155
156
157 # Rules for creating the dependency file:
158 depend:
159         rm -f Makefile.dep
160         $(MAKE) Makefile.dep
161
162 Makefile.dep: Makefile $(SLOFCMNDIR)/Makefile.inc OF.fs
163         $(CC) -M -MG $(CPPFLAGS) $(CFLAGS) $(SLOF_BUILD_SRCS:%=$(SLOFCMNDIR)/%) > Makefile.dep
164         cpp -M -MG $(FPPFLAGS) $(FPPINCLUDES) -MT OF.fsi OF.fs >> Makefile.dep
165         for i in $(filter %.fsi,$(OF_FFS_FILES)) ; do \
166                 cpp -M -MG $(FPPFLAGS) $(FPPINCLUDES) -MT $$i \
167                         `echo $$i | sed  -e 's/\.fsi/\.fs/'` >> Makefile.dep ; \
168         done
169
170 # Include dependency file if available:
171 -include Makefile.dep