*** FIRST VERSION OF CI BUILD SCRIPT ***
[genesis.git] / fuel / build / opendaylight / 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 include ../config.mk
16
17 BUILD_DIR := $(shell pwd)
18 GIT_DIR := /tmp
19 export CONFIG_SPEC_SCRIPT
20 export MAVEN_OPTS = -Xmx1024m -XX:MaxPermSize=512m
21 MAINTAINER = "Main Tainer <main.tainer@example.org>"
22 ODL_SHORT_NAME = odl
23 ODL_VERSION = 0.1-1
24 DEPEND = openjdk-8-jdk
25 TARGET_BUILD_PATH="/tmp/controller/opendaylight/distribution/opendaylight-karaf/target/"
26 MAVEN_SPEC = $(BUILD_DIR)/odl_maven/settings.xml
27
28 #
29 # END of variables to customize
30 #############################################################################
31
32 .PHONY: all
33 all:    odl
34
35 .PHONY: setup
36 setup:
37         rm -f "$(BUILD_BASE)/f_odl"
38         ln -s "$(shell readlink -e $(BUILD_DIR))/f_odl" "$(shell readlink -e $(BUILD_BASE))/f_odl"
39
40 .PHONY: check-cache-validity
41 check-cache-validity:
42         @if [ $(git ls-remote $(ODL_MAIN_REPO) $(ODL_MAIN_TAG) | awk '{print $(NF-1)}') -ne $(cat $(CACHE_DIR)/.versions | grep odl | awk '{print $NF}') ]; then @echo "Cache is not up to date, stopping!"; exit 1; fi
43
44 .PHONY: odl
45 odl:
46
47 ifeq ($(ODL_MAIN_REPO),)
48         @echo "No config-spec target for ODL, nothing to build"
49 else
50
51 ifeq ($(shell if [ -e .odl-build.log ];then cat .odl-build.log; fi;),$(ODL_MAIN_TAG))
52         @cd /tmp && git clone $(ODL_MAIN_REPO) && cd /tmp/controller && git checkout $(ODL_MAIN_TAG)
53
54         @echo "ODL is up to date"
55 else
56         @if [ ! -d "/tmp/controller" ]; then\
57            cd /tmp && git clone $(ODL_MAIN_REPO);\
58         fi;
59
60         @if [ "$(UNIT_TEST)" = "FALSE" ]; then\
61            echo "Building ODL without unit test";\
62            cd /tmp/controller &&\
63            git checkout $(ODL_MAIN_TAG) &&\
64            mvn -D maven.test.skip=true -gs $(MAVEN_SPEC) clean install;\
65         else\
66            echo "Building ODL with unit test";\
67            cd /tmp/controller &&\
68            git checkout $(ODL_MAIN_TAG) &&\
69            mvn -gs $(MAVEN_SPEC) clean install;\
70         fi;
71
72         @echo "odl" `git -C /tmp/controller show | grep commit | rev | cut -f1 -d " "` >> $(BUILD_BASE)/.versions
73         @./make-odl-deb.sh -N $(ODL_SHORT_NAME)_`cd /tmp/controller; git rev-parse --short HEAD` -n $(ODL_SHORT_NAME) -v "$(ODL_VERSION)" -t "$(ODL_MAIN_TAG)" -m $(MAINTAINER) -d $(DEPEND) -p $(TARGET_BUILD_PATH)
74         @echo $(ODL_MAIN_TAG) > .odl-build.log
75 endif
76 endif
77
78 .PHONY: clean $(SUBCLEAN)
79 clean: $(SUBCLEAN)
80         @rm -Rf /tmp/controller
81         @rm -f .odl-build.log
82         @./make-odl-deb.sh -C
83
84 .PHONY: release
85 release: