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 ##############################################################################
11 ############################################################################
12 # BEGIN of variables to customize
17 BUILD_DIR := $(shell pwd)
19 export CONFIG_SPEC_SCRIPT
20 export MAVEN_OPTS = -Xmx1024m -XX:MaxPermSize=512m
21 MAINTAINER = "Main Tainer <main.tainer@example.org>"
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
29 # END of variables to customize
30 #############################################################################
35 ############################################################################
36 # BEGIN of Include definitions
40 # END Include definitions
41 #############################################################################
45 rm -f "$(BUILD_BASE)/f_odl"
46 ln -s "$(shell readlink -e $(BUILD_DIR))/f_odl" "$(shell readlink -e $(BUILD_BASE))/f_odl"
48 .PHONY: 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 = " " ]; \
53 REMOTE_ID=$(shell git ls-remote $(ODL_MAIN_REPO) $(ODL_MAIN_TAG) | awk '{print $$(NF-1)}'); \
55 if [ $$REMOTE_ID != $(shell cat $(VERSION_FILE) | grep odl | awk '{print $$NF}') ]; \
57 echo "Cache does not match upstream OpenDaylight, cache must be rebuilt!"; \
64 ifeq ($(ODL_MAIN_REPO),)
65 @echo "No config-spec target for ODL, nothing to build"
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)
71 @echo "ODL is up to date"
73 @if [ ! -d "/tmp/controller" ]; then\
74 cd /tmp && git clone $(ODL_MAIN_REPO);\
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;\
83 echo "Building ODL with unit test";\
84 cd /tmp/controller &&\
85 git checkout $(ODL_MAIN_TAG) &&\
86 mvn -gs $(MAVEN_SPEC) clean install;\
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
95 .PHONY: clean $(SUBCLEAN)
97 @rm -Rf /tmp/controller