Merge "Includes fixes that remove need for interface hardcoding and adds support...
[genesis.git] / fuel / build / Makefile
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 SHELL = /bin/bash
12 ############################################################################
13 # BEGIN of variables to customize
14 #
15 #Input args
16 export UNIT_TEST = FALSE
17 export INTERACTIVE = TRUE
18 export ISOSRC = file:$(shell pwd)/fuel-6.0.1.iso
19 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
20 export PRODNO = "OPNFV_BGS"
21 export REVSTATE = "P0000"
22 export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
23
24 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
25 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
26
27 #Build variables
28 export BUILD_BASE := $(shell pwd)
29 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
30 export UDEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/debian-installer
31 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
32 export CACHE_DIR := $(BUILD_BASE)/cache
33 export VERSION_FILE := $(BUILD_BASE)/.versions
34 export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
35 export TOPDIR := $(shell pwd)
36
37 #Build subclasses
38
39 SUBDIRS := f_isoroot
40 SUBDIRS += f_opnfv_puppet
41 SUBDIRS += f_osnaily
42 SUBDIRS += f_l23network
43 SUBDIRS += f_resolvconf
44 SUBDIRS += f_ntp
45 SUBDIRS += f_odl_docker
46 #SUBDIRS += f_odl
47
48 # f_example is only an example of how to generate a .deb package and
49 # should not be enabled in official builds.
50 #SUBDIRS += f_example
51
52 ORIGDIR := $(TOPDIR)/origiso
53 #
54 # END of variables to customize
55 #############################################################################
56
57 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
58
59
60 .PHONY: all
61 all:
62         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
63         @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(VERSION_FILE)
64         @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(VERSION_FILE)
65         @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(VERSION_FILE)
66         $(MAKE) -C f_odl_docker -f Makefile all
67         @make -C docker
68         @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
69
70 ############################################################################
71 # BEGIN of Include definitions
72 #
73 include config.mk
74 include cache.mk
75 #
76 # END Include definitions
77 #############################################################################
78
79 $(ISOCACHE):
80         # Clone Fuel to non-persistent location and build
81         cd /tmp && git clone $(FUEL_MAIN_REPO)
82         cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
83         @echo "fuel" `git -C /tmp/fuel-main show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
84         # Setup cgroups for docker-in-docker
85         sudo /root/enable_dockerx2
86         # Patch to fix race condition when doing "Docker-in-Docker" build
87         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_1.patch
88         # Patch to make the sandbox chroot in Fuel succeed with package
89         # installation in a Docker build
90         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_2.patch
91         # Remove Docker optimizations, otherwise multistrap will fail during
92         # Fuel build.
93         sudo rm -f /etc/apt/apt.conf.d/docker*
94         #
95         cd /tmp/fuel-main && ./prepare-build-env.sh
96         cd /tmp/fuel-main && make iso
97         mv /tmp/fuel-main/build/artifacts/fuel*.iso .
98
99 .PHONY: mount-origiso umount-origiso
100 mount-origiso: $(ISOCACHE)
101         @echo "Mounting original ISO in $(ORIGDIR)"
102         @mkdir -p $(ORIGDIR)
103         @fuseiso $(ISOCACHE) $(ORIGDIR)
104
105 umount-origiso:
106         @echo "Unmounting original ISO from $(ORIGDIR)"
107         @fusermount -u $(ORIGDIR)
108         @rmdir $(ORIGDIR)
109
110 .PHONY: $(SUBDIRS)
111 $(SUBDIRS):
112         @mkdir -p release/packages/ubuntu/pool/main release/packages/ubuntu/pool/debian-installer release/puppet/modules release/isoroot
113         $(MAKE) -C $@ -f Makefile release
114
115 .PHONY: patch-packages
116 patch-packages:
117         ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
118
119 .PHONY: prepare
120 prepare:
121         #$(MAKE) -C opendaylight -f Makefile setup
122
123 .PHONY: odl
124 odl:
125         #$(MAKE) -C opendaylight -f Makefile
126
127 .PHONY: build-clean $(SUBCLEAN)
128 build-clean: $(SUBCLEAN)
129         $(MAKE) -C patch-packages -f Makefile clean
130         @rm -Rf release
131         @rm -Rf newiso
132         @rm -f $(NEWISO)
133
134 .PHONY: clean $(SUBCLEAN)
135 clean:  clean-cache prepare $(SUBCLEAN)
136         $(MAKE) -C patch-packages -f Makefile clean
137         #$(MAKE) -C opendaylight -f Makefile clean
138         @rm -f *.iso
139         @rm -Rf release
140         @rm -Rf newiso
141         @rm -f f_odl
142         @rm -f $(NEWISO)
143         @rm -f $(BUILD_BASE)/.versions
144
145 $(SUBCLEAN): %.clean:
146         $(MAKE) -C $* -f Makefile clean
147
148 # Todo: Make things smarter - we shouldn't need to clean everything
149 # betwen make invocations.
150 .PHONY: iso
151 iso:    prepare build-clean odl $(ISOCACHE) $(SUBDIRS) patch-packages
152         install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
153         @printf "\n\nProduct ISO is $(NEWISO)\n\n"