• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5include common.mk
6
7LIBDIR = lib
8PRELOADNAME = libminijailpreload.so
9PRELOADPATH = \"/$(LIBDIR)/$(PRELOADNAME)\"
10CPPFLAGS += -DPRELOADPATH="$(PRELOADPATH)"
11
12ifneq ($(HAVE_SECUREBITS_H),no)
13CPPFLAGS += -DHAVE_SECUREBITS_H
14endif
15ifneq ($(USE_seccomp),yes)
16CPPFLAGS += -DUSE_SECCOMP_SOFTFAIL
17endif
18
19all: CC_BINARY(minijail0) CC_LIBRARY(libminijail.so) \
20		CC_LIBRARY(libminijailpreload.so)
21
22# TODO(jorgelo): convert to TEST().
23tests: CC_BINARY(libminijail_unittest) CC_BINARY(syscall_filter_unittest)
24
25CC_BINARY(minijail0): LDLIBS += -lcap -ldl
26CC_BINARY(minijail0): libconstants.gen.o libsyscalls.gen.o libminijail.o \
27		syscall_filter.o signal_handler.o bpf.o util.o elfparse.o minijail0.o
28clean: CLEAN(minijail0)
29
30CC_LIBRARY(libminijail.so): LDLIBS += -lcap
31CC_LIBRARY(libminijail.so): libminijail.o syscall_filter.o signal_handler.o \
32    bpf.o util.o libconstants.gen.o libsyscalls.gen.o
33clean: CLEAN(libminijail.so)
34
35CC_BINARY(libminijail_unittest): LDLIBS += -lcap
36CC_BINARY(libminijail_unittest): libminijail_unittest.o libminijail.o \
37		syscall_filter.o signal_handler.o bpf.o util.o libconstants.gen.o \
38		libsyscalls.gen.o
39clean: CLEAN(libminijail_unittest)
40
41CC_LIBRARY(libminijailpreload.so): LDLIBS += -lcap -ldl
42CC_LIBRARY(libminijailpreload.so): libminijailpreload.o libminijail.o \
43		libconstants.gen.o libsyscalls.gen.o syscall_filter.o signal_handler.o \
44		bpf.o util.o
45clean: CLEAN(libminijailpreload.so)
46
47CC_BINARY(syscall_filter_unittest): syscall_filter_unittest.o syscall_filter.o \
48		bpf.o util.o libconstants.gen.o libsyscalls.gen.o
49clean: CLEAN(syscall_filter_unittest)
50
51libsyscalls.gen.o: CPPFLAGS += -I$(SRC)
52
53libsyscalls.gen.o.depends: libsyscalls.gen.c
54
55# Only regenerate libsyscalls.gen.c if the Makefile or header changes.
56# NOTE! This will not detect if the file is not appropriate for the target.
57# TODO(jorgelo): fix generation when 'CC' env variable is not set.
58libsyscalls.gen.c: $(SRC)/Makefile $(SRC)/libsyscalls.h
59	@printf "Generating target-arch specific $@... "
60	$(QUIET)$(SRC)/gen_syscalls.sh $@
61	@printf "done.\n"
62clean: CLEAN(libsyscalls.gen.c)
63
64$(eval $(call add_object_rules,libsyscalls.gen.o,CC,c,CFLAGS))
65
66libconstants.gen.o: CPPFLAGS += -I$(SRC)
67
68libconstants.gen.o.depends: libconstants.gen.c
69
70# Only regenerate libconstants.gen.c if the Makefile or header changes.
71# NOTE! This will not detect if the file is not appropriate for the target.
72# TODO(jorgelo): fix generation when 'CC' env variable is not set.
73libconstants.gen.c: $(SRC)/Makefile $(SRC)/libconstants.h
74	@printf "Generating target-arch specific $@... "
75	$(QUIET)$(SRC)/gen_constants.sh $@
76	@printf "done.\n"
77clean: CLEAN(libconstants.gen.c)
78
79$(eval $(call add_object_rules,libconstants.gen.o,CC,c,CFLAGS))
80