-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
97 lines (85 loc) · 2.61 KB
/
Makefile
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/make
#
# tizian - better chrooting with containers
# Copyright (C) 2017 Salvatore Mesoraca <s.mesoraca16@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
ifndef DESTDIR
DESTDIR := /
endif
ifndef BINDIR
BINDIR := usr/sbin/
endif
PROGNAME := tizian
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
CFLAGS := -Wall -pedantic -std=gnu99 -O2 -fstack-protector -fPIE $(CFLAGS)
LDFLAGS := -s -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -pie -lseccomp -lcap -lutil $(LDFLAGS)
ifndef NO_APPARMOR
LDFLAGS := $(LDFLAGS) -lapparmor
else
CFLAGS := $(CFLAGS) -DNO_APPARMOR
endif
ifndef NO_SARA
LDFLAGS := $(LDFLAGS) -lsara
else
CFLAGS := $(CFLAGS) -DNO_SARA
endif
BIN := ./
SOURCE := ./
all: $(BIN)$(PROGNAME)
$(SOURCE)%.o: $(SOURCE)%.c
$(CC) -c -o $@ $< $(CFLAGS)
$(BIN)$(PROGNAME): $(SOURCE)cgroups.o \
$(SOURCE)container.o \
$(SOURCE)mount.o \
$(SOURCE)namespaces.o \
$(SOURCE)pty.o \
$(SOURCE)user_setup.o \
$(SOURCE)main.o
$(CC) -o $@ $^ $(LDFLAGS)
clean:
-rm -f $(SOURCE)*.o $(SOURCE)*~
-rm -f *.o *~
-rm -f debian/*~
distclean: clean
-rm -f $(BIN)$(PROGNAME)
-rm -rf pkgs/
install: all
mkdir -p $(DESTDIR)/$(BINDIR)
ifndef NO_APPARMOR
mkdir -p $(DESTDIR)/etc/apparmor.d/tunables
endif
cp $(BIN)$(PROGNAME) $(DESTDIR)/$(BINDIR)
cp $(SRC)$(PROGNAME)-chown-tree $(DESTDIR)/$(BINDIR)
ifndef NO_APPARMOR
cp $(SRC)apparmor $(DESTDIR)/etc/apparmor.d/$(PROGNAME)
cp $(SRC)apparmor.tunables $(DESTDIR)/etc/apparmor.d/tunables/$(PROGNAME)
endif
chmod 755 $(DESTDIR)/$(BINDIR)/$(PROGNAME)
chmod 755 $(DESTDIR)/$(BINDIR)/$(PROGNAME)-chown-tree
uninstall:
-rm -f $(DESTDIR)/$(BINDIR)/$(PROGNAME)
-rm -f $(DESTDIR)/$(BINDIR)/$(PROGNAME)-chown-tree
deb: distclean
dpkg-buildpackage -b -uc -tc
mkdir -p pkgs
mv ../$(PROGNAME)_*.deb pkgs/
mv ../$(PROGNAME)_*.changes pkgs/
lintian pkgs/$(PROGNAME)_* || true
tar: distclean
mkdir -p pkgs
git archive --format=tar.gz --prefix=$(PROGNAME)/ master -o pkgs/$(PROGNAME).tar.gz
.PHONY: all install uninstall clean distclean deb tar