Update autobuild scripts
[apps/onscreenapp.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 directory is defined in relation to the release
23 # directory (BUILD_DIR), this needs to be kept in mind if over-riding
24 # it and building that widget types, the specific widget type variable
25 # (e.g. BUILD_DIR_DEBUG) may also need to be specified to yield the
26 # desired output hierarchy.
27 BUILD_DIR = $(ROOT_DIR)/build
28 BUILD_DIR_DEBUG = $(abspath $(BUILD_DIR)/../build-debug)
29
30 # Output directory variable for use in pattern rules.
31 # This is intended for internal use only, hence the explicit override
32 # definition.
33 override OUTPUT_DIR = $(BUILD_DIR)
34
35 # Final install directory for widgets
36 DEST = $(OUTPUT_DIR)
37
38 # Default build type for release builds
39 BUILD_TYPE = release
40
41 .PHONY: all help update install distclean
42 .PHONY: clean clean-release clean-debug clean-all
43 .PHONY: configure configure-release configure-debug
44 .PHONY: build build-release build-debug build-all
45 .PHONY: package package-release package-debug package-all
46
47 help:
48         @echo "List of targets available:"
49         @echo ""
50         @echo "- all"
51         @echo "- help"
52         @echo "- clean"
53         @echo "- distclean"
54         @echo "- configure"
55         @echo "- build: compilation, link and prepare files for package into a widget"
56         @echo "- package: output a widget file '*.wgt'"
57         @echo "- install: install in $(DEST) directory"
58         @echo ""
59         @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt"
60         @echo "Don't use your build dir as DEST as wgt file is generated at this location"
61
62 all: package-all
63
64 # Target specific variable over-rides so static pattern rules can be
65 # used for the various type-specific targets.
66
67 configure-debug build-debug package-debug clean-debug: OUTPUT_DIR = $(BUILD_DIR_DEBUG)
68 configure-debug build-debug package-debug: BUILD_TYPE = debug
69
70 clean-release clean-debug:
71         @if [ -d $(OUTPUT_DIR) ]; then \
72                 $(MAKE) -C $(OUTPUT_DIR) $(CLEAN_ARGS) clean; \
73         else \
74                 echo Nothing to clean; \
75         fi
76
77 clean: clean-release
78
79 clean-all: clean-release clean-debug
80
81 distclean: clean-all
82
83 configure-release configure-debug:
84         @mkdir -p $(OUTPUT_DIR)
85         @if [ ! -f $(OUTPUT_DIR)/Makefile ]; then \
86                 (cd $(OUTPUT_DIR) && qmake CONFIG+=$(BUILD_TYPE) $(CONFIGURE_ARGS) $(ROOT_DIR)); \
87         fi
88
89 configure: configure-release
90
91 build-release build-debug: build-%: configure-%
92         @$(MAKE) -C $(OUTPUT_DIR) $(BUILD_ARGS) all
93
94 build: build-release
95
96 build-all: build-release build-debug
97
98 package-release package-debug: package-%: build-%
99         @cp $(OUTPUT_DIR)/package/*.wgt $(OUTPUT_DIR)/
100         @if [ "$(abspath $(DEST))" != "$(abspath $(OUTPUT_DIR))" ]; then \
101                 mkdir -p $(DEST) && cp $(OUTPUT_DIR)/*.wgt $(DEST); \
102         fi
103
104
105 package: package-release
106
107 package-all: package-release package-debug
108
109 install: build
110         @$(MAKE) -C $(BUILD_DIR) $(INSTALL_ARGS) install