-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
48 lines (32 loc) · 1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright (c) 2017, Franz Hollerer.
# SPDX-License-Identifier: MIT
# ---------------------------------------- project specific settings ---
TARGETS := boot appl
export BUILD_ROOT_DIR := ./build
# --------------------------------------- derived settings and rules ---
export PROJECT_ROOT_DIR ?= $(CURDIR)
export BUILD_TYPE ?= release
MAKEFILE := $(lastword $(MAKEFILE_LIST))
all:
for i in $(TARGETS) ; do \
$(MAKE) -f $(MAKEFILE) CURRENT_TARGET=$$i $$i || exit 1; \
done
debug:
$(MAKE) -f $(MAKEFILE) BUILD_TYPE=debug
release:
$(MAKE) -f $(MAKEFILE) BUILD_TYPE=release
ifdef CURRENT_TARGET
BUILD_DIR := $(BUILD_ROOT_DIR)/$(CURRENT_TARGET)
$(CURRENT_TARGET): $(BUILD_DIR)/CMakeLists.txt build_target
build_target:
make -C $(BUILD_DIR)
$(BUILD_DIR)/CMakeLists.txt: \
$(PROJECT_ROOT_DIR)/CMakeLists_$(CURRENT_TARGET).txt
mkdir -p $(BUILD_DIR)
cp $< $@
cd $(BUILD_DIR) && \
cmake -DPROJECT_ROOT_DIR=$(PROJECT_ROOT_DIR) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
endif
clean:
rm -rf $(BUILD_ROOT_DIR)