summaryrefslogtreecommitdiffstats
path: root/sandbox/linux/seccomp/Makefile
blob: 5fde2d203e96c075cc418ba5edf80c859f31bdc1 (plain)
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
49
50
51
52
53
54
55
56
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This Makefile temporarily has been checked into the source tree so that
# we can run the tests. It will be replaced with a proper gyp file.

CFLAGS = -g -O0 -Wall -Werror -Wextra -Wno-missing-field-initializers         \
         -Wno-unused-parameter -I.
LDFLAGS = -g
CPPFLAGS =
MODS := allocator library debug maps x86_decode securemem sandbox     \
        syscall syscall_table trusted_thread trusted_process                  \
        access exit clone getpid gettid ioctl ipc madvise mmap mprotect       \
        munmap open sigprocmask socketcall stat
OBJS64 := $(shell echo ${MODS} | xargs -n 1 | sed -e 's/$$/.o64/')
OBJS32 := $(shell echo ${MODS} | xargs -n 1 | sed -e 's/$$/.o32/')
HEADERS:= $(shell for i in ${MODS}; do [ -r "$$i" ] && echo "$$i"; done)

.SUFFIXES: .o64 .o32

all: test

clean:
	-rm -f *.o *.o32 *.o64 tests/*.o32 tests/*.o.64
	-rm -f core core.* vgcore vgcore.* strace.log*

test: run_tests_64 run_tests_32
	./run_tests_64
	./run_tests_32

# TODO: Track header file dependencies properly
tests/test_syscalls.o64 tests/test_syscalls.o32: tests/test-list.h

tests/test-list.h: tests/list_tests.py tests/test_syscalls.cc
	python tests/list_tests.py tests/test_syscalls.cc > $@

run_tests_64: $(OBJS64) tests/test_syscalls.o64 tests/test-list.h
	g++ -m64 tests/test_syscalls.o64 $(OBJS64) -lpthread -lutil -o $@
run_tests_32: $(OBJS32) tests/test_syscalls.o32 tests/test-list.h
	g++ -m32 tests/test_syscalls.o32 $(OBJS32) -lpthread -lutil -o $@

.cc.o: ${HEADERS}
	${CXX} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<

.cc.o64: ${HEADERS}
	${CXX} ${CFLAGS} ${CPPFLAGS} -fPIC -c -o $@ $<

.c.o64: ${HEADERS}
	${CC} ${CFLAGS} ${CPPFLAGS} --std=gnu99 -fPIC -c -o $@ $<

.cc.o32: ${HEADERS}
	${CXX} ${CFLAGS} ${CPPFLAGS} -m32 -fPIC -c -o $@ $<

.c.o32: ${HEADERS}
	${CC} ${CFLAGS} ${CPPFLAGS} -m32 --std=gnu99 -fPIC -c -o $@ $<