Init camera-gstreamer
[apps/camera-gstreamer.git] / autobuild / agl / autobuild
1 #!/usr/bin/make -f
2 # Copyright (C) 2015 - 2018 "IoT.bzh"
3 # Copyright (C) 2020 Konsulko Group
4 # Author "Romain Forlot" <romain.forlot@iot.bzh>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #        http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 THISFILE  := $(lastword $(MAKEFILE_LIST))
19 ROOT_DIR := $(abspath $(dir $(THISFILE))/../..)
20
21 # Build directories
22 # Note that the debug/test/coverage directories are defined in relation
23 # to the release directory (BUILD_DIR), this needs to be kept in mind
24 # if over-riding it and building those widget types, the specific widget
25 # type variable (e.g. BUILD_DIR_DEBUG) may also need to be specified
26 # to yield the desired output hierarchy.
27 BUILD_DIR = $(ROOT_DIR)/build
28 BUILD_DIR_DEBUG = $(abspath $(BUILD_DIR)/../build-debug)
29 BUILD_DIR_TEST = $(abspath $(BUILD_DIR)/../build-test)
30 BUILD_DIR_COVERAGE = $(abspath $(BUILD_DIR)/../build-coverage)
31
32 # Output directory variable for use in pattern rules.
33 # This is intended for internal use only, hence the explicit override
34 # definition.
35 override OUTPUT_DIR = $(BUILD_DIR)
36
37 # Final install directory for widgets
38 DEST = $(OUTPUT_DIR)
39
40 # Default build type for release/test builds
41 BUILD_TYPE = RELEASE
42
43 .PHONY: all help update install distclean
44 .PHONY: clean clean-release clean-debug clean-test clean-coverage clean-all
45 .PHONY: configure configure-release configure-debug configure-test configure-coverage
46 .PHONY: build build-release build-debug build-test build-coverage build-all
47 .PHONY: package package-release package-debug package-test package-coverage package-all
48
49 help:
50         @echo "List of targets available:"
51         @echo ""
52         @echo "- all"
53         @echo "- help"
54         @echo "- clean"
55         @echo "- distclean"
56         @echo "- configure"
57         @echo "- build: compilation, link and prepare files for package into a widget"
58         @echo "- package: output a widget file '*.wgt'"
59         @echo "- install: install in your $(CMAKE_INSTALL_DIR) directory"
60         @echo ""
61         @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt"
62         @echo "Don't use your build dir as DEST as wgt file is generated at this location"
63
64 all: package-all
65
66 # Target specific variable over-rides so static pattern rules can be
67 # used for the various type-specific targets.
68
69 configure-test build-test package-test clean-test: OUTPUT_DIR = $(BUILD_DIR_TEST)
70
71 configure-coverage build-coverage package-coverage clean-coverage: OUTPUT_DIR = $(BUILD_DIR_COVERAGE)
72 configure-coverage build-coverage package-coverage: BUILD_TYPE = COVERAGE
73
74 configure-debug build-debug package-debug clean-debug: OUTPUT_DIR = $(BUILD_DIR_DEBUG)
75 configure-debug build-debug package-debug: BUILD_TYPE = DEBUG
76
77 clean-release clean-test clean-debug clean-coverage:
78         @if [ -d $(OUTPUT_DIR) ]; then \
79                 $(MAKE) -C $(OUTPUT_DIR) $(CLEAN_ARGS) clean; \
80         else \
81                 echo Nothing to clean; \
82         fi
83
84 clean: clean-release
85
86 clean-all: clean-release clean-test clean-debug clean-coverage
87
88 distclean: clean-all
89
90 configure-release configure-test configure-debug configure-coverage:
91         @mkdir -p $(OUTPUT_DIR)
92         @if [ ! -f $(OUTPUT_DIR)/Makefile ]; then \
93                 (cd $(OUTPUT_DIR) && cmake -S $(ROOT_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(CONFIGURE_ARGS)); \
94         fi
95
96 configure: configure-release
97
98 build-release build-debug build-coverage: build-%: configure-%
99         @cmake --build $(OUTPUT_DIR) $(BUILD_ARGS) --target all
100
101 # Kept for consistency, empty to avoid building everything for test widget
102 build-test: configure-test
103
104 build: build-release
105
106 build-all: build-release build-debug build-test build-coverage
107
108 package-release package-debug package-coverage: package-%: build-%
109         @cmake --build $(OUTPUT_DIR) $(PACKAGE_ARGS) --target widget
110         @if [ "$(abspath $(DEST))" != "$(abspath $(OUTPUT_DIR))" ]; then \
111                 mkdir -p $(DEST) && cp $(OUTPUT_DIR)/*.wgt $(DEST); \
112         fi
113
114 package-test: build-test
115         @cmake --build $(OUTPUT_DIR) $(PACKAGE_ARGS) --target test_widget
116         @if [ "$(abspath $(DEST))" != "$(abspath $(OUTPUT_DIR))" ]; then \
117                 mkdir -p $(DEST) && cp $(OUTPUT_DIR)/*.wgt $(DEST); \
118         fi
119
120 package: package-release
121
122 package-all: package-release package-test package-coverage package-debug
123
124 update: configure
125         @cmake --build $(BUILD_DIR) --target autobuild
126
127 install: build
128         @cmake --build $(BUILD_DIR) $(INSTALL_ARGS) --target install