Starting point for ODL Integration
[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 ############################################################################
12 # BEGIN of variables to customize
13 #
14 SHELL = /bin/bash
15
16 include config.mk
17
18 export BUILD_BASE = $(shell pwd)
19 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
20 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
21
22 ISOSRC = file:$(shell pwd)/fuel-6.0.1.iso
23 ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
24 PRODNO = "OPNFV_BGS"
25 REVSTATE = "P0000"
26 NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
27 DOCKERIMG = opnfv.org/ubuntu-builder:14.04
28 # Note! Invoke with "make REVSTATE=RXXXX iso" to make release build!
29 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
30 #
31 # END of variables to customize
32 #############################################################################
33 export TOPDIR := $(shell pwd)
34 ORIGDIR := $(TOPDIR)/origiso
35
36 SUBDIRS := f_isoroot
37 SUBDIRS += f_opnfv_puppet
38 SUBDIRS += f_osnaily
39 SUBDIRS += f_l23network
40 SUBDIRS += f_resolvconf
41 SUBDIRS += f_ntp
42 #SUBDIRS += f_gif
43 #SUBDIRS += f_libnss
44 #SUBDIRS += f_libpcs
45 #SUBDIRS += f_libxt
46 #SUBDIRS += f_comm_java
47 #SUBDIRS += f_ca_cert
48 #SUBDIRS += f_atk_wrap
49 #SUBDIRS += f_jre_head
50 #SUBDIRS += f_jre
51 #SUBDIRS += f_java
52 #SUBDIRS += f_odl
53
54
55
56 # f_example is only an example of how to generate a .deb package and
57 # should not be enabled in official builds.
58 #SUBDIRS += f_example
59
60 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
61
62 .PHONY: all
63 all:
64         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
65         @make -C docker
66         @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
67
68 $(ISOCACHE):
69         # Clone Fuel to non-persistent location and build
70         cd /tmp && git clone $(FUEL_MAIN_REPO)
71         cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
72         # Setup cgroups for docker-in-docker
73         sudo /root/enable_dockerx2
74         # Patch to fix race condition when doing "Docker-in-Docker" build
75         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_1.patch
76         # Patch to make the sandbox chroot in Fuel succeed with package
77         # installation in a Docker build
78         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_2.patch
79         # Remove Docker optimizations, otherwise multistrap will fail during
80         # Fuel build.
81         sudo rm -f /etc/apt/apt.conf.d/docker*
82         #
83         cd /tmp/fuel-main && ./prepare-build-env.sh
84         cd /tmp/fuel-main && make iso
85         mv /tmp/fuel-main/build/artifacts/fuel*.iso .
86
87 .PHONY: mount-origiso umount-origiso
88 mount-origiso: $(ISOCACHE)
89         @echo "Mounting original ISO in $(ORIGDIR)"
90         @mkdir -p $(ORIGDIR)
91         @fuseiso $(ISOCACHE) $(ORIGDIR)
92
93 umount-origiso:
94         @echo "Unmounting original ISO from $(ORIGDIR)"
95         @fusermount -u $(ORIGDIR)
96         @rmdir $(ORIGDIR)
97
98 .PHONY: $(SUBDIRS)
99 $(SUBDIRS):
100         @mkdir -p release/packages/ubuntu/pool/main release/puppet/modules release/isoroot
101         $(MAKE) -C $@ -f Makefile release
102
103 .PHONY: patch-packages
104 patch-packages:
105         ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
106
107 .PHONY: prepare
108 prepare:
109         $(MAKE) -C opendaylight -f Makefile setup
110
111 .PHONY: odl
112 odl:
113         $(MAKE) -C opendaylight -f Makefile
114
115 .PHONY: build-clean $(SUBCLEAN)
116 build-clean: $(SUBCLEAN)
117         $(MAKE) -C patch-packages -f Makefile clean
118         @rm -Rf release
119         @rm -Rf newiso
120         @rm -f $(NEWISO)
121
122 .PHONY: clean $(SUBCLEAN)
123 clean: prepare $(SUBCLEAN)
124         $(MAKE) -C patch-packages -f Makefile clean
125         $(MAKE) -C opendaylight -f Makefile clean
126         @rm -f *.iso
127         @rm -Rf release
128         @rm -Rf newiso
129         @rm -f f_odl
130         @rm -f $(NEWISO)
131
132 $(SUBCLEAN): %.clean:
133         $(MAKE) -C $* -f Makefile clean
134
135 # Todo: Make things smarter - we shouldn't need to clean everything
136 # betwen make invocations.
137 .PHONY: iso
138 iso:    prepare build-clean odl $(ISOCACHE) $(SUBDIRS) patch-packages
139         install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
140         @printf "\n\nProduct ISO is $(NEWISO)\n\n"