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