nsjail/Makefile

94 lines
2.5 KiB
Makefile
Raw Normal View History

2015-05-15 05:44:48 +08:00
#
# nsjail - Makefile
2016-03-09 07:56:20 +08:00
# -----------------------------------------
2015-05-15 05:44:48 +08:00
#
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
2016-03-01 02:09:39 +08:00
CC ?= gcc
2016-03-09 01:22:50 +08:00
2016-03-10 06:51:13 +08:00
CFLAGS += -O2 -c -std=gnu11 \
2015-05-15 05:44:48 +08:00
-D_GNU_SOURCE \
2016-03-09 01:22:50 +08:00
-fstack-protector-all -Wformat -Wformat=2 -Wformat-security -fPIE \
2015-05-15 05:44:48 +08:00
-Wall -Wextra -Werror
2016-03-09 08:11:05 +08:00
LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie -Wl,-z,noexecstack
2016-03-09 01:22:50 +08:00
SRCS = nsjail.c cmdline.c contain.c log.c cgroup.c mount.c net.c pid.c sandbox.c subproc.c user.c util.c uts.c
2016-03-10 06:51:13 +08:00
OBJS = $(SRCS:.c=.o)
BIN = nsjail
ifdef DEBUG
CFLAGS += -g -ggdb -gdwarf-4
endif
2016-03-09 01:49:06 +08:00
USE_KAFEL = yes
2016-09-13 18:10:15 +08:00
ifneq ("$(wildcard kafel/include/kafel.h)","")
ifeq ($(USE_KAFEL), yes)
2016-09-13 18:10:15 +08:00
CFLAGS += -I./kafel/include/ -DUSE_KAFEL
LIBS += kafel/libkafel.a
endif
endif
2016-09-13 18:10:15 +08:00
USE_NL3 = yes
2016-03-01 05:12:01 +08:00
ifeq ("$(wildcard /usr/include/libnl3/netlink/route/link/macvlan.h)","/usr/include/libnl3/netlink/route/link/macvlan.h")
ifeq ($(USE_NL3), yes)
2016-03-01 05:12:01 +08:00
CFLAGS += -DNSJAIL_NL3_WITH_MACVLAN -I/usr/include/libnl3
LDFLAGS += -lnl-3 -lnl-route-3
endif
endif
2016-03-01 05:12:01 +08:00
2015-05-15 05:44:48 +08:00
.c.o: %.c
$(CC) $(CFLAGS) $< -o $@
all: $(BIN)
2016-09-13 18:10:15 +08:00
$(BIN): $(OBJS) $(LIBS)
$(CC) -o $(BIN) $(OBJS) $(LIBS) $(LDFLAGS)
ifneq ("$(wildcard kafel/Makefile)","")
kafel/libkafel.a:
$(MAKE) -C kafel
endif
2015-05-15 05:44:48 +08:00
clean:
$(RM) core Makefile.bak $(OBJS) $(BIN)
2016-09-13 18:10:15 +08:00
ifneq ("$(wildcard kafel/Makefile)","")
$(MAKE) -C kafel clean
endif
2015-05-15 05:44:48 +08:00
depend:
makedepend -Y. -- -- $(SRCS)
2015-05-15 05:44:48 +08:00
indent:
indent -linux -l100 -lc100 *.c *.h; rm -f *~
2015-05-15 05:44:48 +08:00
# DO NOT DELETE THIS LINE -- make depend depends on it.
2016-03-03 22:37:04 +08:00
nsjail.o: nsjail.h common.h cmdline.h log.h net.h subproc.h
2016-01-17 11:14:09 +08:00
cmdline.o: cmdline.h common.h log.h util.h
2016-06-19 18:47:28 +08:00
contain.o: contain.h common.h cgroup.h log.h mount.h net.h pid.h util.h uts.h
2015-05-15 05:44:48 +08:00
log.o: log.h common.h
2016-06-19 19:54:36 +08:00
cgroup.o: cgroup.h common.h log.h util.h
mount.o: mount.h common.h log.h subproc.h util.h
2016-10-18 04:53:31 +08:00
net.o: net.h common.h log.h subproc.h
pid.o: pid.h common.h log.h subproc.h
sandbox.o: sandbox.h common.h log.h
2016-06-19 21:50:25 +08:00
subproc.o: subproc.h common.h cgroup.h contain.h log.h net.h sandbox.h user.h
subproc.o: util.h
2016-10-18 04:53:31 +08:00
user.o: user.h common.h log.h subproc.h util.h
2016-03-03 22:37:04 +08:00
util.o: util.h common.h log.h
2016-03-03 23:09:25 +08:00
uts.o: uts.h common.h log.h