blob: 9a0a63045f889832888a2382e2fe1f41d5f6ae7c [file] [log] [blame]
Ben Vanik7d2c17a2022-11-27 09:10:41 -08001# Copyright 2022 The IREE Authors
2#
3# Licensed under the Apache License v2.0 with LLVM Exceptions.
4# See https://llvm.org/LICENSE.txt for license information.
5# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7# This is an example showing a basic makefile that links in the IREE runtime by
8# way of the unified static library. It's recommended that IREE is added as a
9# subproject and cmake is used to add the dependencies (as in the CMakeLists.txt
10# in this directory) but when using other build systems this is easier to adapt.
11#
12# Configure the runtime:
13# cmake -GNinja -B ../iree-build-runtime/ . \
14# -DCMAKE_BUILD_TYPE=MinSizeRel \
15# -DIREE_SIZE_OPTIMIZED=ON
16# Build the runtime:
17# cmake --build ../iree-build-runtime/ --target iree_runtime_unified
18# Make this binary:
19# make custom-module-run-min RUNTIME_BUILD_DIR=../iree-build-runtime/
20#
21# Note that if IREE_SIZE_OPTIMIZED is used to build the runtime then the
22# -DNDEBUG and -DIREE_STATUS_MODE=0 are required on any binaries using it.
23
24RUNTIME_SRC_DIR ?= ../../runtime/src/
25RUNTIME_BUILD_DIR ?= ../../../iree-build/
26
27SRC_FILES := module.h module.cc main.c
28INCLUDE_DIRS := ${RUNTIME_SRC_DIR}
29INCLUDE_FLAGS := $(addprefix -I,${INCLUDE_DIRS})
30LIBRARY_DIRS := \
31 ${RUNTIME_BUILD_DIR}/build_tools/third_party/flatcc/ \
32 ${RUNTIME_BUILD_DIR}/runtime/src/iree/runtime/
33LINK_LIBRARIES := \
34 iree_runtime_unified \
35 flatcc_parsing
36LIBRARY_FLAGS := $(addprefix -L,${LIBRARY_DIRS}) $(addprefix -l,${LINK_LIBRARIES})
37CXX_FLAGS := -flto ${INCLUDE_FLAGS} ${LIBRARY_FLAGS}
38MIN_FLAGS := \
39 -s \
40 -Os \
41 -DNDEBUG \
42 -DIREE_STATUS_MODE=0
43
44all: custom-module-run custom-module-run-min
45clean:
46 rm -f custom-module-run custom-module-run-min
47
48custom-module-run: ${SRC_FILES}
49 ${CXX} ${SRC_FILES} ${CXX_FLAGS} -o $@
50custom-module-run-min: ${SRC_FILES}
51 ${CXX} ${SRC_FILES} ${CXX_FLAGS} ${MIN_FLAGS} -o $@