Migrates master to use direct upstream
[apex.git] / build / Makefile
1 ##############################################################################
2 # Copyright (c) 2016 Red Hat Inc.
3 # dradez@redhat.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 export USE_MASTER = ""
11 export RELEASE = "0"
12
13 export RPM_DIST = $(shell rpm -E %dist)
14 export RPMVERS = $(shell grep Version $(shell pwd)/rpm_specs/opnfv-apex.spec | head -n 1 | awk '{ print $$2 }')
15
16 export BUILD_ROOT = $(shell pwd)
17 export BUILD_DIR = $(shell dirname $$(pwd))/.build
18 export CACHE_DIR = $(shell dirname $$(pwd))/.cache
19 export RPM_DIR_ARGS = -D '_topdir $(BUILD_DIR)' -D '_builddir $(BUILD_DIR)' -D '_sourcedir $(BUILD_DIR)' -D '_rpmdir $(BUILD_DIR)' -D '_specdir $(BUILD_DIR)' -D '_srcrpmdir $(BUILD_DIR)'
20 export RPMCOM = $(BUILD_DIR)/noarch/python34-opnfv-apex-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
21
22 export NETVPP_VERS := $(shell grep Version $(shell pwd)/rpm_specs/networking-vpp.spec | head -n 1 | awk '{ print $$2 }')
23 export NETVPP_REPO := $(shell awk -F\= '/^netvpp_repo/ {print $$2}' variables.sh )
24 export NETVPP_BRANCH := $(shell awk -F\= '/^netvpp_branch/ {print $$2}' variables.sh )
25 export NETVPP_COMMIT := $(shell git ls-remote $(NETVPP_REPO) $(NETVPP_BRANCH) | awk '{print substr($$1,1,7)}')
26
27 .PHONY: all
28 all: rpm
29
30 .PHONY: clean
31 clean:
32         rm -rf $(BUILD_DIR)
33
34 .PHONY: clean-cache
35 clean-cache:
36         rm -rf $(CACHE_DIR)
37
38 .PHONY: rpm-check
39 rpm-check: apex-rpm-check
40
41 .PHONY: rpm-clean
42 rpm-clean:
43         rm -rf $(BUILD_DIR)/noarch
44         rm -rf $(BUILD_DIR)/BUILDROOT
45
46 $(BUILD_DIR)/opnfv-apex.tar.gz:
47         mkdir -p $(BUILD_DIR)
48         pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-$(RPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex.tar.gz
49
50 .PHONY: apex-rpm-check
51 apex-rpm-check: $(BUILD_DIR)/opnfv-apex.tar.gz
52         rpmbuild --clean -bi -bl rpm_specs/opnfv-apex.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
53
54 .PHONY: rpm
55 apex-rpm: $(BUILD_DIR)/opnfv-apex.tar.gz $(RPMCOM)
56
57 $(RPMCOM):
58         @echo "Building the Apex RPM"
59         # build the Apex RPM
60         rpmbuild --clean -ba rpm_specs/opnfv-apex.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
61
62
63 ##################
64 # NETWORKING-VPP #
65 ##################
66
67 $(BUILD_DIR)/python-networking-vpp.tar.gz:
68         @echo "Preparing the networking-vpp RPM prerequisites"
69         git clone $(NETVPP_REPO) -b $(NETVPP_BRANCH) $(BUILD_DIR)/python-networking-vpp-$(NETVPP_VERS)
70         tar czf $(BUILD_DIR)/python-networking-vpp.tar.gz -C $(BUILD_DIR) python-networking-vpp-$(NETVPP_VERS)
71
72 .PHONY: networking-vpp-rpm
73 networking-vpp-rpm: $(BUILD_DIR)/noarch/python-networking-vpp-*.noarch.rpm
74
75 $(BUILD_DIR)/noarch/python-networking-vpp-*.noarch.rpm: $(BUILD_DIR)/python-networking-vpp.tar.gz
76         @echo "Building the Networking VPP RPM"
77         rpmbuild --clean -ba --target noarch rpm_specs/networking-vpp.spec $(RPM_DIR_ARGS) -D 'git .git$(NETVPP_COMMIT)'
78
79 ##################
80 #  PYTHON TESTS  #
81 ##################
82
83 .PHONY: python-tests
84 python-tests:
85         tox -e py35
86
87 #######################
88 #  PYTHON PEP8 CHECK  #
89 #######################
90
91 .PHONY: python-pep8-check
92 python-pep8-check:
93         tox -e pep8
94
95 #############
96 #  YAMLLINT #
97 #############
98
99 .PHONY: yamllint
100 yamllint:
101         @echo "Running yamllint against all .yaml files"
102         cd ../ && yamllint $(shell cd ../ && git ls-tree -r HEAD --name-only | grep 'yaml$$')
103 #############
104 #  RPMLINT  #
105 #############
106
107 .PHONY: rpmlint
108 rpmlint:
109         @echo "Running rpmlint against all RPM spec files"
110         rpmlint rpm_specs/*.spec
111