Fixes setup.sh pxebr checks
[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
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 ############################################################################
36 # BEGIN of Include definitions
37 #
38 include ../config.mk
39 #
40 # END Include definitions
41 #############################################################################
42
43 .PHONY: setup
44 setup:
45         rm -f "$(BUILD_BASE)/f_odl"
46         ln -s "$(shell readlink -e $(BUILD_DIR))/f_odl" "$(shell readlink -e $(BUILD_BASE))/f_odl"
47
48 .PHONY: validate-cache
49 validate-cache:
50         @REMOTE_ID=$(shell git ls-remote $(ODL_MAIN_REPO) $(ODL_MAIN_TAG)^{} | awk '{print $$(NF-1)}'); \
51         if [ -z $$REMOTE_ID ] || [ $$REMOTE_ID = " " ]; \
52         then \
53            REMOTE_ID=$(shell git ls-remote $(ODL_MAIN_REPO) $(ODL_MAIN_TAG) | awk '{print $$(NF-1)}'); \
54         fi; \
55         if [ $$REMOTE_ID != $(shell cat $(VERSION_FILE) | grep odl | awk '{print $$NF}') ]; \
56         then \
57            echo "Cache does not match upstream OpenDaylight, cache must be rebuilt!"; \
58            exit 1; \
59         fi
60
61 .PHONY: odl
62 odl:
63
64 ifeq ($(ODL_MAIN_REPO),)
65         @echo "No config-spec target for ODL, nothing to build"
66 else
67
68 ifeq ($(shell if [ -e .odl-build.log ];then cat .odl-build.log; fi;),$(ODL_MAIN_TAG))
69         @cd /tmp && git clone $(ODL_MAIN_REPO) && cd /tmp/controller && git checkout $(ODL_MAIN_TAG)
70
71         @echo "ODL is up to date"
72 else
73         @if [ ! -d "/tmp/controller" ]; then\
74            cd /tmp && git clone $(ODL_MAIN_REPO);\
75         fi;
76
77         @if [ "$(UNIT_TEST)" = "FALSE" ]; then\
78            echo "Building ODL without unit test";\
79            cd /tmp/controller &&\
80            git checkout $(ODL_MAIN_TAG) &&\
81            mvn -D maven.test.skip=true -gs $(MAVEN_SPEC) clean install;\
82         else\
83            echo "Building ODL with unit test";\
84            cd /tmp/controller &&\
85            git checkout $(ODL_MAIN_TAG) &&\
86            mvn -gs $(MAVEN_SPEC) clean install;\
87         fi;
88
89         @echo "odl" `git -C /tmp/controller show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
90         @./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)
91         @echo $(ODL_MAIN_TAG) > .odl-build.log
92 endif
93 endif
94
95 .PHONY: clean $(SUBCLEAN)
96 clean: $(SUBCLEAN)
97         @rm -Rf /tmp/controller
98         @rm -f .odl-build.log
99         @./make-odl-deb.sh -C
100
101 .PHONY: release
102 release: