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 # - 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
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
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)
35 LDFLAGS += -static -nostdlib -Wl,-q,-n
38 CFLAGS += -nostdinc -fno-builtin
39 CPPFLAGS += -I$(LIBCMNDIR)/libc/include
40 SLOF_LIBS += $(LIBCMNDIR)/libc.a
43 DICT = $(SLOFCMNDIR)/prim.in $(SLOFCMNDIR)/engine.in \
44 $(BOARD_SLOF_IN) $(SLOFCMNDIR)/$(TARG).in
46 # Source code files with automatic dependencies:
47 SLOF_BUILD_SRCS = paflof.c helpers.c allocator.c
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
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
60 printf "\t[FPP]\t%s\n" `basename "$@"`
63 cpp $(FPPFLAGS) $(FPPINCLUDES) $< > $@.tmp
64 sed -e 's/^[ ]*//' < $@.tmp \
65 | sed -e '/^\\[ ]/d' \
66 | sed -e '/^([ ][^)]*[ ])[ ]*$$/d' \
67 | sed -e '/^$$/d' > $@
72 $(LD) -o $@ -r -bbinary $<
75 dict.xt: $(DICT) $(SLOFCMNDIR)/ref.pl
76 cat $(DICT) | perl $(SLOFCMNDIR)/ref.pl -s $(CELLSIZE) > dict.xt
79 board.code: $(BOARD_SLOF_CODE)
80 cat $(BOARD_SLOF_CODE) > $@
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
94 $(STRIP) --strip-unneeded $@
96 paflof.o: board.code dict.xt
97 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/paflof.c
100 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/helpers.c
103 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(SLOFCMNDIR)/allocator.c
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
111 $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $(LLFWCMNDIR)/romfs.S
114 $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $(LLFWCMNDIR)/nvramlog.S
117 $(CC) $(CPPFLAGS) $(ASFLAGS) -c -o $@ $(LLFWCMNDIR)/checkpoint.S
119 $(LLFWBRDDIR)/board_io.o:
120 $(MAKE) -C $(LLFWBRDDIR) board_io.o
122 $(LLFWBRDDIR)/io_generic_lib.o:
123 $(MAKE) -C $(LLFWBRDDIR) io_generic_lib.o
125 default-font.o: $(SLOFCMNDIR)/default-font.c
126 $(CC) $(CPPFLAGS) $< -c -o default-font.o
128 $(SLOFBRDDIR)/default-font.bin: default-font.o
129 $(OBJCOPY) -Obinary default-font.o $@
131 .PHONY : create_OF.ffs clean_slof distclean_slof depend
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
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 ; \
147 # Targets for cleaning up:
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))
153 distclean_slof: clean_slof
157 # Rules for creating the dependency file:
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 ; \
170 # Include dependency file if available:
171 -include Makefile.dep