Jorge Lucangeli Obes | fc8ab53 | 2012-03-20 10:14:31 -0700 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Kees Cook | ddb7970 | 2017-04-12 16:36:45 -0700 | [diff] [blame] | 5 | BASE_VER=0 |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 6 | include common.mk |
| 7 | |
Luis Hector Chavez | f6423bb | 2018-10-05 14:20:29 -0700 | [diff] [blame] | 8 | LIBDIR ?= /lib |
Jorge Lucangeli Obes | df4bd35 | 2012-08-29 19:12:28 -0700 | [diff] [blame] | 9 | PRELOADNAME = libminijailpreload.so |
Allen Webb | ee87607 | 2019-02-21 10:56:21 -0800 | [diff] [blame] | 10 | PRELOADPATH = "$(LIBDIR)/$(PRELOADNAME)" |
| 11 | CPPFLAGS += -DPRELOADPATH='$(PRELOADPATH)' |
| 12 | |
| 13 | # Defines the pivot root path used by the minimalistic-mountns profile. |
| 14 | DEFAULT_PIVOT_ROOT ?= /var/empty |
| 15 | CPPFLAGS += -DDEFAULT_PIVOT_ROOT='"$(DEFAULT_PIVOT_ROOT)"' |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 16 | |
Jorge Lucangeli Obes | 6a600a4 | 2017-04-07 15:53:06 -0400 | [diff] [blame] | 17 | ifeq ($(USE_seccomp),no) |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 18 | CPPFLAGS += -DUSE_SECCOMP_SOFTFAIL |
Utkarsh Sanghi | 0ef8a66 | 2014-08-18 15:50:11 -0700 | [diff] [blame] | 19 | endif |
Lei Zhang | eee3155 | 2012-10-17 21:27:10 -0700 | [diff] [blame] | 20 | |
Mike Frysinger | 916c6c3 | 2018-09-27 14:17:53 -0400 | [diff] [blame] | 21 | # Allow people to use -L and related flags. |
| 22 | ALLOW_DEBUG_LOGGING ?= yes |
| 23 | ifeq ($(ALLOW_DEBUG_LOGGING),yes) |
| 24 | CPPFLAGS += -DALLOW_DEBUG_LOGGING |
| 25 | endif |
| 26 | |
Luis Hector Chavez | daa0371 | 2017-09-06 08:10:33 -0700 | [diff] [blame] | 27 | ifeq ($(USE_ASAN),yes) |
Luis Héctor Chávez | 4baeafa | 2021-01-03 05:47:13 -0800 | [diff] [blame] | 28 | CPPFLAGS += -fsanitize=address -fno-omit-frame-pointer |
| 29 | LDFLAGS += -fsanitize=address -fno-omit-frame-pointer |
Luis Hector Chavez | daa0371 | 2017-09-06 08:10:33 -0700 | [diff] [blame] | 30 | USE_EXIT_ON_DIE = yes |
| 31 | endif |
| 32 | |
| 33 | # Setting this flag can be useful for both AddressSanitizer builds and running |
| 34 | # fuzzing tools, which do not expect crashes on gracefully-handled malformed |
| 35 | # inputs. |
| 36 | ifeq ($(USE_EXIT_ON_DIE),yes) |
| 37 | CPPFLAGS += -DUSE_EXIT_ON_DIE |
| 38 | endif |
| 39 | |
Nicole Anderson-Au | bcc8cfd | 2020-11-10 20:33:27 +0000 | [diff] [blame] | 40 | # Setting this flag allows duplicate syscalls definitions for seccomp filters. |
| 41 | ifeq ($(ALLOW_DUPLICATE_SYSCALLS),yes) |
| 42 | CPPFLAGS += -DALLOW_DUPLICATE_SYSCALLS |
| 43 | endif |
| 44 | |
Mike Frysinger | e131e13 | 2017-10-04 13:27:55 -0400 | [diff] [blame] | 45 | MJ_COMMON_FLAGS = -Wunused-parameter -Wextra -Wno-missing-field-initializers |
| 46 | CFLAGS += $(MJ_COMMON_FLAGS) |
| 47 | CXXFLAGS += $(MJ_COMMON_FLAGS) |
Jorge Lucangeli Obes | ce2c3ff | 2017-02-01 18:04:36 -0500 | [diff] [blame] | 48 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 49 | USE_SYSTEM_GTEST ?= no |
| 50 | ifeq ($(USE_SYSTEM_GTEST),no) |
Mike Frysinger | e1f046a | 2017-10-04 13:27:18 -0400 | [diff] [blame] | 51 | GTEST_CXXFLAGS := -std=gnu++14 |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 52 | GTEST_LIBS := gtest.a |
| 53 | else |
Allen Webb | f8c21ea | 2019-06-14 09:24:10 -0700 | [diff] [blame] | 54 | GTEST_CXXFLAGS := $(shell gtest-config --cxxflags 2>/dev/null || \ |
| 55 | echo "-pthread") |
| 56 | GTEST_LIBS := $(shell gtest-config --libs 2>/dev/null || \ |
| 57 | echo "-lgtest -pthread -lpthread") |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 58 | endif |
| 59 | |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 60 | CORE_OBJECT_FILES := libminijail.o syscall_filter.o signal_handler.o \ |
| 61 | bpf.o util.o system.o syscall_wrapper.o \ |
| 62 | libconstants.gen.o libsyscalls.gen.o |
| 63 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 64 | all: CC_BINARY(minijail0) CC_LIBRARY(libminijail.so) \ |
Zach Reizner | 2a93cee | 2019-02-01 15:13:09 -0800 | [diff] [blame] | 65 | CC_LIBRARY(libminijailpreload.so) |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 66 | |
Jorge Lucangeli Obes | f16d6d1 | 2016-09-29 20:25:27 -0400 | [diff] [blame] | 67 | parse_seccomp_policy: CXX_BINARY(parse_seccomp_policy) |
Luis Hector Chavez | cf504ca | 2020-01-30 21:39:13 -0800 | [diff] [blame] | 68 | dump_constants: CXX_STATIC_BINARY(dump_constants) |
Jorge Lucangeli Obes | f16d6d1 | 2016-09-29 20:25:27 -0400 | [diff] [blame] | 69 | |
Jorge Lucangeli Obes | e0c5a76 | 2017-02-02 15:17:08 -0500 | [diff] [blame] | 70 | tests: TEST(CXX_BINARY(libminijail_unittest)) \ |
Mike Frysinger | 4d2a81e | 2018-01-22 16:43:33 -0500 | [diff] [blame] | 71 | TEST(CXX_BINARY(minijail0_cli_unittest)) \ |
Mike Frysinger | 0b5cffa | 2017-08-15 18:06:18 -0400 | [diff] [blame] | 72 | TEST(CXX_BINARY(syscall_filter_unittest)) \ |
Mike Frysinger | 32c3992 | 2018-01-17 17:09:54 -0500 | [diff] [blame] | 73 | TEST(CXX_BINARY(system_unittest)) \ |
| 74 | TEST(CXX_BINARY(util_unittest)) \ |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 75 | |
Will Drewry | 6ac9112 | 2011-10-21 16:38:58 -0500 | [diff] [blame] | 76 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 77 | CC_BINARY(minijail0): LDLIBS += -lcap -ldl |
Mike Frysinger | 5ef22ca | 2018-01-20 13:42:10 -0500 | [diff] [blame] | 78 | CC_BINARY(minijail0): $(CORE_OBJECT_FILES) \ |
| 79 | elfparse.o minijail0.o minijail0_cli.o |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 80 | clean: CLEAN(minijail0) |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 81 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 82 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 83 | CC_LIBRARY(libminijail.so): LDLIBS += -lcap |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 84 | CC_LIBRARY(libminijail.so): $(CORE_OBJECT_FILES) |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 85 | clean: CLEAN(libminijail.so) |
Ben Chan | 4539701 | 2011-08-23 08:15:03 -0700 | [diff] [blame] | 86 | |
Stephen Barber | 27c5823 | 2019-12-09 17:20:28 -0800 | [diff] [blame] | 87 | CC_STATIC_LIBRARY(libminijail.pic.a): $(CORE_OBJECT_FILES) |
| 88 | CC_STATIC_LIBRARY(libminijail.pie.a): $(CORE_OBJECT_FILES) |
| 89 | clean: CLEAN(libminijail.*.a) |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 90 | |
| 91 | CXX_BINARY(libminijail_unittest): CXXFLAGS += -Wno-write-strings \ |
| 92 | $(GTEST_CXXFLAGS) |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 93 | CXX_BINARY(libminijail_unittest): LDLIBS += -lcap $(GTEST_LIBS) |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 94 | ifeq ($(USE_SYSTEM_GTEST),no) |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 95 | CXX_BINARY(libminijail_unittest): $(GTEST_LIBS) |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 96 | endif |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 97 | CXX_BINARY(libminijail_unittest): libminijail_unittest.o $(CORE_OBJECT_FILES) \ |
| 98 | testrunner.o |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 99 | clean: CLEAN(libminijail_unittest) |
Will Drewry | decdfdc | 2011-09-27 15:13:54 -0500 | [diff] [blame] | 100 | |
Luis Hector Chavez | 9acba45 | 2018-10-11 10:13:25 -0700 | [diff] [blame] | 101 | TEST(CXX_BINARY(libminijail_unittest)): CC_LIBRARY(libminijailpreload.so) |
| 102 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 103 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 104 | CC_LIBRARY(libminijailpreload.so): LDLIBS += -lcap -ldl |
Jorge Lucangeli Obes | 0b20877 | 2017-04-19 14:15:46 -0400 | [diff] [blame] | 105 | CC_LIBRARY(libminijailpreload.so): libminijailpreload.o $(CORE_OBJECT_FILES) |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 106 | clean: CLEAN(libminijailpreload.so) |
Elly Jones | cd7a904 | 2011-07-22 13:56:51 -0400 | [diff] [blame] | 107 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 108 | |
Mike Frysinger | 4d2a81e | 2018-01-22 16:43:33 -0500 | [diff] [blame] | 109 | CXX_BINARY(minijail0_cli_unittest): CXXFLAGS += $(GTEST_CXXFLAGS) |
| 110 | CXX_BINARY(minijail0_cli_unittest): LDLIBS += -lcap $(GTEST_LIBS) |
| 111 | ifeq ($(USE_SYSTEM_GTEST),no) |
| 112 | CXX_BINARY(minijail0_cli_unittest): $(GTEST_LIBS) |
| 113 | endif |
| 114 | CXX_BINARY(minijail0_cli_unittest): minijail0_cli_unittest.o \ |
| 115 | $(CORE_OBJECT_FILES) minijail0_cli.o elfparse.o testrunner.o |
| 116 | clean: CLEAN(minijail0_cli_unittest) |
| 117 | |
| 118 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 119 | CXX_BINARY(syscall_filter_unittest): CXXFLAGS += -Wno-write-strings \ |
| 120 | $(GTEST_CXXFLAGS) |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 121 | CXX_BINARY(syscall_filter_unittest): LDLIBS += -lcap $(GTEST_LIBS) |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 122 | ifeq ($(USE_SYSTEM_GTEST),no) |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 123 | CXX_BINARY(syscall_filter_unittest): $(GTEST_LIBS) |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 124 | endif |
| 125 | CXX_BINARY(syscall_filter_unittest): syscall_filter_unittest.o \ |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 126 | $(CORE_OBJECT_FILES) testrunner.o |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 127 | clean: CLEAN(syscall_filter_unittest) |
Jorge Lucangeli Obes | fc8ab53 | 2012-03-20 10:14:31 -0700 | [diff] [blame] | 128 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 129 | |
Mike Frysinger | 0b5cffa | 2017-08-15 18:06:18 -0400 | [diff] [blame] | 130 | CXX_BINARY(system_unittest): CXXFLAGS += $(GTEST_CXXFLAGS) |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 131 | CXX_BINARY(system_unittest): LDLIBS += -lcap $(GTEST_LIBS) |
Mike Frysinger | 0b5cffa | 2017-08-15 18:06:18 -0400 | [diff] [blame] | 132 | ifeq ($(USE_SYSTEM_GTEST),no) |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 133 | CXX_BINARY(system_unittest): $(GTEST_LIBS) |
Mike Frysinger | 0b5cffa | 2017-08-15 18:06:18 -0400 | [diff] [blame] | 134 | endif |
Luis Hector Chavez | 114a930 | 2017-09-05 20:36:58 -0700 | [diff] [blame] | 135 | CXX_BINARY(system_unittest): system_unittest.o \ |
| 136 | $(CORE_OBJECT_FILES) testrunner.o |
Mike Frysinger | 0b5cffa | 2017-08-15 18:06:18 -0400 | [diff] [blame] | 137 | clean: CLEAN(system_unittest) |
| 138 | |
| 139 | |
Mike Frysinger | 32c3992 | 2018-01-17 17:09:54 -0500 | [diff] [blame] | 140 | CXX_BINARY(util_unittest): CXXFLAGS += $(GTEST_CXXFLAGS) |
| 141 | CXX_BINARY(util_unittest): LDLIBS += -lcap $(GTEST_LIBS) |
| 142 | ifeq ($(USE_SYSTEM_GTEST),no) |
| 143 | CXX_BINARY(util_unittest): $(GTEST_LIBS) |
| 144 | endif |
| 145 | CXX_BINARY(util_unittest): util_unittest.o \ |
| 146 | $(CORE_OBJECT_FILES) testrunner.o |
| 147 | clean: CLEAN(util_unittest) |
| 148 | |
| 149 | |
Jorge Lucangeli Obes | f16d6d1 | 2016-09-29 20:25:27 -0400 | [diff] [blame] | 150 | CXX_BINARY(parse_seccomp_policy): parse_seccomp_policy.o syscall_filter.o \ |
| 151 | bpf.o util.o libconstants.gen.o libsyscalls.gen.o |
Jorge Lucangeli Obes | a1f4e0a | 2017-09-05 10:06:55 -0400 | [diff] [blame] | 152 | clean: CLEAN(parse_seccomp_policy) |
Jorge Lucangeli Obes | f16d6d1 | 2016-09-29 20:25:27 -0400 | [diff] [blame] | 153 | |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 154 | |
Luis Hector Chavez | cf504ca | 2020-01-30 21:39:13 -0800 | [diff] [blame] | 155 | # Compiling dump_constants as a static executable makes it easy to run under |
| 156 | # qemu-user, which in turn simplifies cross-compiling bpf policies. |
| 157 | CXX_STATIC_BINARY(dump_constants): dump_constants.o \ |
Luis Hector Chavez | f7b2018 | 2018-10-28 21:39:32 -0700 | [diff] [blame] | 158 | libconstants.gen.o libsyscalls.gen.o |
| 159 | clean: CLEAN(dump_constants) |
| 160 | |
| 161 | |
Luis Hector Chavez | cf504ca | 2020-01-30 21:39:13 -0800 | [diff] [blame] | 162 | constants.json: CXX_STATIC_BINARY(dump_constants) |
Luis Hector Chavez | f7b2018 | 2018-10-28 21:39:32 -0700 | [diff] [blame] | 163 | ./dump_constants > $@ |
| 164 | clean: CLEANFILE(constants.json) |
| 165 | |
| 166 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 167 | libsyscalls.gen.o: CPPFLAGS += -I$(SRC) |
Jorge Lucangeli Obes | fc8ab53 | 2012-03-20 10:14:31 -0700 | [diff] [blame] | 168 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 169 | libsyscalls.gen.o.depends: libsyscalls.gen.c |
Lee Campbell | 1e4fc6a | 2014-06-06 17:40:02 -0700 | [diff] [blame] | 170 | |
Will Drewry | 32ac9f5 | 2011-08-18 21:36:27 -0500 | [diff] [blame] | 171 | # Only regenerate libsyscalls.gen.c if the Makefile or header changes. |
| 172 | # NOTE! This will not detect if the file is not appropriate for the target. |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 173 | libsyscalls.gen.c: $(SRC)/Makefile $(SRC)/libsyscalls.h |
Jorge Lucangeli Obes | ae57f09 | 2016-11-23 15:04:55 -0500 | [diff] [blame] | 174 | @printf "Generating target-arch specific $@...\n" |
Dan Willemsen | 2acbec5 | 2017-09-14 17:28:36 -0700 | [diff] [blame] | 175 | $(QUIET)CC="$(CC)" $(SRC)/gen_syscalls.sh "$@" |
Jorge Lucangeli Obes | ae57f09 | 2016-11-23 15:04:55 -0500 | [diff] [blame] | 176 | @printf "$@ done.\n" |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 177 | clean: CLEAN(libsyscalls.gen.c) |
Will Drewry | 32ac9f5 | 2011-08-18 21:36:27 -0500 | [diff] [blame] | 178 | |
Jorge Lucangeli Obes | bc9dc1c | 2014-08-25 09:12:36 -0700 | [diff] [blame] | 179 | $(eval $(call add_object_rules,libsyscalls.gen.o,CC,c,CFLAGS)) |
Luis Hector Chavez | 40b2574 | 2013-09-22 19:44:06 -0700 | [diff] [blame] | 180 | |
| 181 | libconstants.gen.o: CPPFLAGS += -I$(SRC) |
| 182 | |
| 183 | libconstants.gen.o.depends: libconstants.gen.c |
| 184 | |
| 185 | # Only regenerate libconstants.gen.c if the Makefile or header changes. |
| 186 | # NOTE! This will not detect if the file is not appropriate for the target. |
Luis Hector Chavez | 40b2574 | 2013-09-22 19:44:06 -0700 | [diff] [blame] | 187 | libconstants.gen.c: $(SRC)/Makefile $(SRC)/libconstants.h |
Jorge Lucangeli Obes | ae57f09 | 2016-11-23 15:04:55 -0500 | [diff] [blame] | 188 | @printf "Generating target-arch specific $@...\n" |
Dan Willemsen | 2acbec5 | 2017-09-14 17:28:36 -0700 | [diff] [blame] | 189 | $(QUIET)CC="$(CC)" $(SRC)/gen_constants.sh "$@" |
Jorge Lucangeli Obes | ae57f09 | 2016-11-23 15:04:55 -0500 | [diff] [blame] | 190 | @printf "$@ done.\n" |
Luis Hector Chavez | 40b2574 | 2013-09-22 19:44:06 -0700 | [diff] [blame] | 191 | clean: CLEAN(libconstants.gen.c) |
| 192 | |
| 193 | $(eval $(call add_object_rules,libconstants.gen.o,CC,c,CFLAGS)) |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 194 | |
| 195 | |
| 196 | ################################################################################ |
| 197 | # Google Test |
| 198 | |
| 199 | ifeq ($(USE_SYSTEM_GTEST),no) |
| 200 | # Points to the root of Google Test, relative to where this file is. |
| 201 | # Remember to tweak this if you move this file. |
Luis Héctor Chávez | 4f830bd | 2021-01-03 05:47:11 -0800 | [diff] [blame] | 202 | GTEST_DIR = googletest-release-1.10.0/googletest |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 203 | |
| 204 | # Flags passed to the preprocessor. |
| 205 | # Set Google Test's header directory as a system directory, such that |
| 206 | # the compiler doesn't generate warnings in Google Test headers. |
| 207 | CPPFLAGS += -isystem $(GTEST_DIR)/include |
| 208 | |
| 209 | # Flags passed to the C++ compiler. |
Jorge Lucangeli Obes | e0c5a76 | 2017-02-02 15:17:08 -0500 | [diff] [blame] | 210 | GTEST_CXXFLAGS += -pthread |
Jorge Lucangeli Obes | 9bd316b | 2017-01-26 17:21:16 -0500 | [diff] [blame] | 211 | |
| 212 | # All Google Test headers. Usually you shouldn't change this |
| 213 | # definition. |
| 214 | GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ |
| 215 | $(GTEST_DIR)/include/gtest/internal/*.h |
| 216 | |
| 217 | # House-keeping build targets. |
| 218 | clean: clean_gtest |
| 219 | |
| 220 | clean_gtest: |
| 221 | rm -f gtest.a gtest_main.a *.o |
| 222 | |
| 223 | # Builds gtest.a and gtest_main.a. |
| 224 | |
| 225 | # Usually you shouldn't tweak such internal variables, indicated by a |
| 226 | # trailing _. |
| 227 | GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) |
| 228 | |
| 229 | # For simplicity and to avoid depending on Google Test's |
| 230 | # implementation details, the dependencies specified below are |
| 231 | # conservative and not optimized. This is fine as Google Test |
| 232 | # compiles fast and for ordinary users its source rarely changes. |
| 233 | gtest-all.o : $(GTEST_SRCS_) |
| 234 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) $(GTEST_CXXFLAGS) -c \ |
| 235 | $(GTEST_DIR)/src/gtest-all.cc -o $@ |
| 236 | |
| 237 | gtest_main.o : $(GTEST_SRCS_) |
| 238 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) $(GTEST_CXXFLAGS) -c \ |
| 239 | $(GTEST_DIR)/src/gtest_main.cc -o $@ |
| 240 | |
| 241 | gtest.a : gtest-all.o |
| 242 | $(AR) $(ARFLAGS) $@ $^ |
| 243 | |
| 244 | gtest_main.a : gtest-all.o gtest_main.o |
| 245 | $(AR) $(ARFLAGS) $@ $^ |
| 246 | |
| 247 | endif |
| 248 | ################################################################################ |