-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (94 loc) · 3.02 KB
/
Copy pathMakefile
File metadata and controls
119 lines (94 loc) · 3.02 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Tools and flags. We are pretty aggro about warnings. If set in the
# environment, use that value instead of what’s here.
CXX ?= g++
CC ?= gcc
AR ?= ar
CFLAGS ?= -Wall -Wextra -Werror -O3 -fPIC
CXXFLAGS ?= $(CFLAGS) -std=c++17
CPPFLAGS ?= -I./include -I./src
LDFLAGS ?= -static-libgcc
CXXLDFLAGS ?= -static-libstdc++ $(LDFLAGS)
# Directories
SRCDIR := src
LIBDIR := lib
BINDIR := bin
# Library sources
LIB_C_SRCS := \
$(SRCDIR)/libpseudo/cbmanage.c \
$(SRCDIR)/libpseudo/pseudo.c \
$(SRCDIR)/libpseudo/log.c \
$(SRCDIR)/libpseudo/syscall.c \
$(SRCDIR)/libpseudo/emulation.c \
$(SRCDIR)/handlers/idtrack.c \
$(SRCDIR)/handlers/virtid.c \
$(SRCDIR)/handlers/seccomp/seccomp.c \
$(SRCDIR)/handlers/seccomp/filter_trace.c \
$(SRCDIR)/handlers/seccomp/filter_fakechown.c \
$(SRCDIR)/handlers/seccomp/filter_fakeroot.c
# App sources
PSEUDO_SRCS := \
$(SRCDIR)/pseudo/pseudo-cli.c
POD_SRCS := \
$(SRCDIR)/pseudopod/pseudopod-cli.cpp \
$(SRCDIR)/pseudopod/userns.c
# Objects (in-place, next to sources)
LIB_C_OBJS := $(LIB_C_SRCS:.c=.o)
PSEUDO_OBJS := $(PSEUDO_SRCS:.c=.o)
POD_OBJS := $(filter %.o, $(POD_SRCS:.c=.o) $(POD_SRCS:.cpp=.o))
# Dependency files, 1:1 with objects
DEPS := $(LIB_C_OBJS:.o=.d) \
$(PSEUDO_OBJS:.o=.d) \
$(POD_OBJS:.o=.d)
# Artifacts
STATIC_LIB := $(LIBDIR)/libpseudo.a
PSEUDO_BIN := $(BINDIR)/pseudo
POD_BIN := $(BINDIR)/pseudopod
.PHONY: all clean dirs
all: dirs $(PSEUDO_BIN) $(POD_BIN)
dirs:
@mkdir -p $(LIBDIR) $(BINDIR)
.PHONY: libpseudo libpseudo-static pseudo pseudopod
# Static-only library
libpseudo: libpseudo-static
libpseudo-static: $(STATIC_LIB)
$(STATIC_LIB): $(LIB_C_OBJS) | $(LIBDIR)
$(AR) crs $@ $^
$(LIBDIR):
@mkdir -p $(LIBDIR)
# Binaries
pseudo: $(PSEUDO_BIN)
$(PSEUDO_BIN): $(PSEUDO_OBJS) $(STATIC_LIB)
$(CC) $(CFLAGS) -o $@ $(PSEUDO_OBJS) $(STATIC_LIB) $(LDFLAGS)
pseudopod: $(POD_BIN)
$(POD_BIN): $(POD_OBJS) $(STATIC_LIB)
$(CXX) $(CXXFLAGS) -o $@ $(POD_OBJS) $(STATIC_LIB) $(CXXLDFLAGS)
# Compile rules (objects produced next to sources)
$(SRCDIR)/libpseudo/%.o: $(SRCDIR)/libpseudo/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(SRCDIR)/handlers/%.o: $(SRCDIR)/handlers/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(SRCDIR)/handlers/seccomp/%.o: $(SRCDIR)/handlers/seccomp/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(SRCDIR)/pseudo/%.o: $(SRCDIR)/pseudo/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(SRCDIR)/pseudopod/%.o: $(SRCDIR)/pseudopod/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
.PHONY: test tests tests-build tests-run tests-clean
test: tests
tests: tests-run
tests-build: pseudo
$(MAKE) -C tests
tests-run: tests-build
$(MAKE) -C tests run
tests-clean:
$(MAKE) -C tests clean
clean:
$(MAKE) -C tests clean
rm -f \
$(LIBDIR)/libpseudo.a \
$(BINDIR)/pseudo $(BINDIR)/pseudopod \
$(LIB_C_OBJS) $(LIB_CXX_OBJS) $(PSEUDO_OBJS) $(POD_OBJS) \
$(DEPS)
# Include auto-generated dependency files if they exist
# Use '-' prefix to ignore missing files without treating other files as makefiles.
-include $(DEPS)