Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / Makefile.gen
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
14 MAKEARG = BOARD=$(BOARD) PLATFORM=$(PLATFORM) FLAG=$(FLAG) TARG=$(TARG)
15
16 BUILDS  = tools_build romfs_build
17
18 include ../make.rules
19
20 ifdef DRIVER
21 RELEASE=$(shell cat ../VERSION)
22 export DRIVER_NAME=$(shell cat ../VERSION | sed -e "s/-/./g" | awk -F . '{ printf("%s%02d%02d%1s%02s",$$1,$$2,$$3,$$4,$$5); }')
23 else
24 ifneq (,$(wildcard ../.git))
25 RELEASE=git-$(shell git rev-parse --short=16 HEAD)
26 else
27 ifneq (,$(shell cat ../VERSION))
28 RELEASE="$(USER)@$(HOSTNAME) release $(shell cat ../VERSION)"
29 export DRIVER_NAME=HEAD
30 else
31 RELEASE="$(USER)@$(HOSTNAME)(private build)"
32 export DRIVER_NAME=HEAD
33 endif
34 endif
35 endif
36
37
38 DRVDATE=$(shell date +%Y-%h%d)
39
40 FLASH_SIZE_MB = `echo $$[ $(FLASH_SIZE)/1024/1024 ]`
41
42 DTB_ROMFS_FLAG ?= 0
43 DTB_ROMFS_ADDR ?= 0
44
45 llfw_disassembly:
46         $(MAKE) -C $(LLFWBRDDIR) stage1.dis stage2.dis stageS.dis
47
48 clients_build:
49         @echo " ====== Building clients ======"
50         $(MAKE) -C ../clients $(MAKEARG)
51
52 other_licence_build:
53         $(MAKE) -C ../other-licence $(MAKEARG)
54
55 tools_build:
56         $(MAKE) -C ../tools
57
58 romfs_build:
59         $(MAKE) -C ../romfs/tools $(MAKEARG)
60
61 ../build_info.img:
62         @echo "$(CC)" > ../build_info.img
63         @$(CC) -v >> ../build_info.img 2>&1
64         @$(LD) -V >> ../build_info.img 2>&1
65
66 ../$(SUBBOARD).dtb:
67         @if [ -e dts/$(SUBBOARD).dts ]; then \
68                  dtc -q -I dts -O dtb dts/$(SUBBOARD).dts > $@; \
69         fi
70
71 boot_rom.bin:   $(BUILDS) ../build_info.img ../$(SUBBOARD).dtb
72         @echo " ====== Building $@ ======"
73         @if [ -e $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs ]; then \
74                 cat $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs > ../.boot_rom.ffs; \
75         else \
76                 cat $(ROMFSBRDDIR)/boot_rom.ffs > ../.boot_rom.ffs; \
77         fi
78         @if [ -e $(PCDBRDDIR)/pcdfiles.ffs ]; then \
79                 cat $(PCDBRDDIR)/pcdfiles.ffs >> ../.boot_rom.ffs; \
80         fi
81         cat $(SLOFBRDDIR)/OF.ffs >> ../.boot_rom.ffs
82         @echo build_info.img  build_info.img 0 0 >> ../.boot_rom.ffs
83         @if [ -e ../$(SUBBOARD).dtb ]; then \
84                 echo dtb $(SUBBOARD).dtb $(DTB_ROMFS_FLAG) \
85                         $(DTB_ROMFS_ADDR) >> ../.boot_rom.ffs; \
86         fi
87         cd .. && ./romfs/tools/build_romfs $(ROMFS_OPTIONS) .boot_rom.ffs $@
88         cd .. && if [ -f $@.gz ]; then rm -f $@.gz; gzip -9 $@ ; fi
89         rm -f ../.boot_rom.*ffs
90         rm -f ../$(SUBBOARD).dtb
91
92
93 external_flasher: ../boot_rom.bin
94         ../tools/make-flasher-image.sh $(FLASH_SIZE) ../boot_rom.bin \
95                 ../boot_rom-$(FLASH_SIZE_MB)MB-BigEndian.bin
96
97 driver_dirs:
98         @rm -rf ../driver-$(RELEASE)
99         @mkdir -p ../driver-$(RELEASE)/{rom,l2b,disassemblies}
100
101 driver_prep:
102         @echo "Building driver "$(RELEASE)" for $(BOARD)"
103
104 copy_disassemblies:     llfw_disassembly
105         cp $(LLFWBRDDIR)/stage1.dis  \
106                 ../driver-$(RELEASE)/disassemblies/$(RELEASE)-stage1.dis
107         cp $(LLFWBRDDIR)/stage2.dis  \
108                 ../driver-$(RELEASE)/disassemblies/$(RELEASE)-stage2.dis
109         cp $(LLFWBRDDIR)/stageS.dis  \
110                 ../driver-$(RELEASE)/disassemblies/$(RELEASE)-stageS.dis
111         cp $(LLFWBRDDIR)/meminit.dis  \
112                 ../driver-$(RELEASE)/disassemblies/$(RELEASE)-meminit.dis
113         @if [ -e ../clients/snk/client.dis ]; then cp ../clients/snk/client.dis \
114                 ../driver-$(RELEASE)/disassemblies/$(RELEASE)-client.dis; fi
115
116 copy_driver:    copy_disassemblies external_flasher
117         mv ../boot_rom-$(FLASH_SIZE_MB)MB-BigEndian.bin \
118                 ../driver-$(RELEASE)/rom/$(RELEASE)-boot_rom-$(FLASH_SIZE_MB)MB-BigEndian.bin
119         mv ../boot_rom.bin \
120                 ../driver-$(RELEASE)/rom/$(RELEASE)-boot_rom.bin
121         if [ -e ../boot_l2-dd2.ad ]; then \
122                 mv ../boot_l2-dd2.ad ../driver-$(RELEASE)/l2b/; \
123         else \
124                 mv ../boot_l2.ad ../driver-$(RELEASE)/l2b/; \
125         fi
126         mv ../boot_xdr.bin ../driver-$(RELEASE)/l2b/
127         cp ../VERSION ../driver-$(RELEASE)
128         cd ../driver-$(RELEASE) && md5sum rom/*.bin > md5sum.txt
129
130 tar_gz:         copy_driver
131         @cp -a ../driver-$(RELEASE) ../driver-$(RELEASE)-$(DRVDATE)-devel
132         tar czf ../driver-$(RELEASE)-$(DRVDATE)-devel.tar.gz \
133                 ../driver-$(RELEASE)-$(DRVDATE)-devel > /dev/null 2>&1
134         @rm -rf ../driver-$(RELEASE)-$(DRVDATE)-devel
135         @rm -rf ../driver-$(RELEASE)/disassemblies
136         @mv ../driver-$(RELEASE) ../driver-$(RELEASE)-$(DRVDATE)
137         tar czf ../driver-$(RELEASE)-$(DRVDATE).tar.gz \
138                 ../driver-$(RELEASE)-$(DRVDATE) > /dev/null  2>&1
139         @rm -rf ../driver-$(RELEASE)-$(DRVDATE)
140
141 clean_top:
142         @rm -f ../build_info.img
143         @rm -f ../.crc_flash
144         @rm -f ../$(SUBBOARD).dtb
145
146 clean_gen:      clean_top
147         $(MAKE) -C ../romfs/tools BOARD=$(BOARD) clean
148         $(MAKE) -C ../tools clean
149         $(MAKE) -C ../other-licence clean
150         $(MAKE) -C ../clients clean
151         @for dir in $(COMMON_LIBS); do \
152                 $(MAKE) -C ../lib/$$dir clean || exit 1; \
153         done
154
155 distclean_gen:  clean_top
156         $(MAKE) -C ../romfs/tools BOARD=$(BOARD) distclean
157         $(MAKE) -C ../tools distclean
158         $(MAKE) -C ../other-licence distclean
159         $(MAKE) -C ../clients distclean
160         @for dir in $(COMMON_LIBS); do \
161                 $(MAKE) -C ../lib/$$dir distclean || exit 1; \
162         done
163
164 common-libs:
165         @echo " ====== Building common libraries ======"
166         $(MAKE) -C $(LIBCMNDIR) $(COMMON_LIBS)
167
168 board-libs:
169         $(MAKE) -C lib $(MAKEARG)