2 # Copyright (C) 2015 - 2018 "IoT.bzh"
3 # Author "Romain Forlot" <romain.forlot@iot.bzh>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 THISFILE := $(lastword $(MAKEFILE_LIST))
18 BUILD_DIR := $(abspath $(dir $(THISFILE))/../../build)
19 BUILD_DIR_TEST := $(abspath $(dir $(THISFILE))/../../build-test)
20 BUILD_DIR_DEBUG := $(abspath $(dir $(THISFILE))/../../build-debug)
21 BUILD_DIR_COVERAGE := $(abspath $(dir $(THISFILE))/../../build-coverage)
22 BUILD_DIR_DEBUG_TEST := $(abspath $(dir $(THISFILE))/../../build-debug-test)
23 BUILD_DIR_COVERAGE_TEST := $(abspath $(dir $(THISFILE))/../../build-coverage-test)
26 .PHONY: all clean distclean configure build package help update configure-debug configure-coverage build-debug build-coverage package-test package-debug package-coverage package-debug package-debug-test package-coverage-test package-all
30 @echo "List of targets available:"
36 @echo "- build: compilation, link and prepare files for package into a widget"
37 @echo "- package: output a widget file '*.wgt'"
38 @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory"
40 @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt"
41 @echo "Don't use your build dir as DEST as wgt file is generated at this location"
44 @cmake --build ${BUILD_DIR} --target autobuild
47 @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} ${CLEAN_ARGS} clean) || echo Nothing to clean
53 @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
54 @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake -DCMAKE_BUILD_TYPE=RELEASE ${CONFIGURE_ARGS} ..)
57 @[ -d ${BUILD_DIR_TEST} ] || mkdir -p ${BUILD_DIR_TEST}
58 @[ -f ${BUILD_DIR_TEST}/Makefile ] || (cd ${BUILD_DIR_TEST} && cmake -DCMAKE_BUILD_TYPE=RELEASE ${CONFIGURE_ARGS} ..)
61 @[ -d ${BUILD_DIR_DEBUG} ] || mkdir -p ${BUILD_DIR_DEBUG}
62 @[ -f ${BUILD_DIR_DEBUG}/Makefile ] || (cd ${BUILD_DIR_DEBUG} && cmake -DCMAKE_BUILD_TYPE=DEBUG ${CONFIGURE_ARGS} ..)
65 @[ -d ${BUILD_DIR_COVERAGE} ] || mkdir -p ${BUILD_DIR_COVERAGE}
66 @[ -f ${BUILD_DIR_COVERAGE}/Makefile ] || (cd ${BUILD_DIR_COVERAGE} && cmake -DCMAKE_BUILD_TYPE=COVERAGE ${CONFIGURE_ARGS} ..)
69 @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
71 build-test: configure-test
72 @cmake --build ${BUILD_DIR_TEST} ${BUILD_ARGS} --target all
74 build-debug: configure-debug
75 @cmake --build ${BUILD_DIR_DEBUG} ${BUILD_ARGS} --target all
77 build-coverage: configure-coverage
78 @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
81 @mkdir -p ${BUILD_DIR}/$@/bin
82 @mkdir -p ${BUILD_DIR}/$@/etc
83 @mkdir -p ${BUILD_DIR}/$@/lib
84 @mkdir -p ${BUILD_DIR}/$@/htdocs
85 @mkdir -p ${BUILD_DIR}/$@/var
86 @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget
87 @if [ "${DEST}" != "${BUILD_DIR}" ]; then \
88 mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}; \
91 package-test: build-test
92 @mkdir -p ${BUILD_DIR_TEST}/$@/bin
93 @mkdir -p ${BUILD_DIR_TEST}/$@/etc
94 @mkdir -p ${BUILD_DIR_TEST}/$@/lib
95 @mkdir -p ${BUILD_DIR_TEST}/$@/htdocs
96 @mkdir -p ${BUILD_DIR_TEST}/$@/var
97 @cmake --build ${BUILD_DIR_TEST} ${PACKAGE_ARGS} --target widget
98 @cmake --build ${BUILD_DIR_TEST} ${PACKAGE_ARGS} --target test_widget
99 @if [ "${DEST}" != "${BUILD_DIR_TEST}" ]; then \
100 mkdir -p ${DEST} && cp ${BUILD_DIR_TEST}/*.wgt ${DEST}; \
103 package-debug: build-debug
104 @mkdir -p ${BUILD_DIR_DEBUG}/$@/bin
105 @mkdir -p ${BUILD_DIR_DEBUG}/$@/etc
106 @mkdir -p ${BUILD_DIR_DEBUG}/$@/lib
107 @mkdir -p ${BUILD_DIR_DEBUG}/$@/htdocs
108 @mkdir -p ${BUILD_DIR_DEBUG}/$@/var
109 @cmake --build ${BUILD_DIR_DEBUG} ${PACKAGE_ARGS} --target widget
110 @if [ "${DEST}" != "${BUILD_DIR_DEBUG}" ]; then \
111 mkdir -p ${DEST} && cp ${BUILD_DIR_DEBUG}/*.wgt ${DEST}; \
114 package-coverage: build-coverage
115 @mkdir -p ${BUILD_DIR_COVERAGE}/$@/bin
116 @mkdir -p ${BUILD_DIR_COVERAGE}/$@/etc
117 @mkdir -p ${BUILD_DIR_COVERAGE}/$@/lib
118 @mkdir -p ${BUILD_DIR_COVERAGE}/$@/htdocs
119 @mkdir -p ${BUILD_DIR_COVERAGE}/$@/var
120 @cmake --build ${BUILD_DIR_COVERAGE} ${PACKAGE_ARGS} --target widget
121 @if [ "${DEST}" != "${BUILD_DIR_COVERAGE}" ]; then \
122 mkdir -p ${DEST} && cp ${BUILD_DIR_COVERAGE}/*.wgt ${DEST}; \
125 package-coverage-test: build-coverage
126 @mkdir -p ${BUILD_DIR_COVERAGE_TEST}/$@/bin
127 @mkdir -p ${BUILD_DIR_COVERAGE_TEST}/$@/etc
128 @mkdir -p ${BUILD_DIR_COVERAGE_TEST}/$@/lib
129 @mkdir -p ${BUILD_DIR_COVERAGE_TEST}/$@/htdocs
130 @mkdir -p ${BUILD_DIR_COVERAGE_TEST}/$@/var
131 @cmake --build ${BUILD_DIR_COVERAGE_TEST} ${PACKAGE_ARGS} --target widget
132 @cmake --build ${BUILD_DIR_COVERAGE_TEST} ${PACKAGE_ARGS} --target test_widget
133 @if [ "${DEST}" != "${BUILD_DIR_COVERAGE_TEST}" ]; then \
134 mkdir -p ${DEST} && cp ${BUILD_DIR_COVERAGE_TEST}/*.wgt ${DEST}; \
138 package-debug-test: build-debug
139 @mkdir -p ${BUILD_DIR_DEBUG_TEST}/$@/bin
140 @mkdir -p ${BUILD_DIR_DEBUG_TEST}/$@/etc
141 @mkdir -p ${BUILD_DIR_DEBUG_TEST}/$@/lib
142 @mkdir -p ${BUILD_DIR_DEBUG_TEST}/$@/htdocs
143 @mkdir -p ${BUILD_DIR_DEBUG_TEST}/$@/var
144 @cmake --build ${BUILD_DIR_DEBUG_TEST} ${PACKAGE_ARGS} --target widget
145 @cmake --build ${BUILD_DIR_DEBUG_TEST} ${PACKAGE_ARGS} --target test_widget
146 @if [ "${DEST}" != "${BUILD_DIR_DEBUG_TEST}" ]; then \
147 mkdir -p ${DEST} && cp ${BUILD_DIR_DEBUG_TEST}/*.wgt ${DEST}; \
150 package-all: package package-test package-coverage package-debug
153 @cmake --build ${BUILD_DIR} ${INSTALL_ARGS} --target install