forked from zerovm/zrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
163 lines (132 loc) · 4.37 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
include Makefile.env
############### libzrt.a source files to build
LIBZRT=lib/libzrt.a
LIBZRT_SOURCES= ${ZEROVM_ROOT}/api/zvm.c \
lib/syscall_manager.S \
lib/zrtlog.c \
lib/zrt.c \
lib/zrtsyscalls.c \
lib/enum_strings.c \
lib/helpers/conf_parser.c \
lib/helpers/path_utils.c \
lib/memory/memory_syscall_handlers.c \
lib/fs/fcntl_implem.c \
lib/fs/fstab_loader.c \
lib/fs/fstab_observer.c \
lib/fs/mounts_manager.c \
lib/fs/handle_allocator.c \
lib/fs/channels_mount.c \
lib/fs/channels_readdir.c \
lib/fs/transparent_mount.c \
lib/fs/mem_mount_wraper.cc \
lib/fs/unpack/stream_reader.c \
lib/fs/unpack/unpack_tar.c \
lib/fs/unpack/image_engine.c \
lib/fs/utils/parse_path.c
LIBZRT_OBJECTS=$(addsuffix .o, $(basename $(LIBZRT_SOURCES) ) )
############### zlibc.a source files to build
LIBZGLIBC=lib/libzglibc.a
LIBZGLIBC_SOURCES= lib/glibc_substitute/tmpfile.c \
lib/glibc_substitute/realpath.c \
lib/glibc_substitute/getcwd.c \
lib/glibc_substitute/getuid.c \
lib/glibc_substitute/getpwuid.c \
lib/glibc_substitute/fdopen.c \
lib/glibc_substitute/mkdir.c \
lib/glibc_substitute/rmdir.c \
lib/glibc_substitute/lstat.c \
lib/glibc_substitute/umask.c \
lib/glibc_substitute/unlink.c \
lib/glibc_substitute/chmod.c \
lib/glibc_substitute/fcntl.c \
lib/glibc_substitute/remove.c \
lib/glibc_substitute/rename.c \
lib/glibc_substitute/chown.c
#lib/glibc_substitute/malloc_free.c lib/memory/bget.c
LIBZGLIBC_OBJECTS=$(addsuffix .o, $(basename $(LIBZGLIBC_SOURCES) ) )
############## ported libraries build
LIBS= lib/mapreduce/libmapreduce.a lib/networking/libnetworking.a \
lib/lua-5.2.1/liblua.a gtest/libgtest.a lib/fs/nacl-mounts/libfs.a lib/sqlite3/libsqlite3.a
################# samples to build
UNSTABLE_SAMPLES=
SAMPLES=hello tarimage readdir sort_paging reqrep disort wordcount zshell time
TEST_SAMPLES=file_stat bigfile
TEST_SUITES=lua_test_suite
################# flags set
CFLAGS = -Wall -Wno-long-long -O2 -m64
CFLAGS += -Werror-implicit-function-declaration
#include paths
CFLAGS += -I. \
-Ilib \
-Ilib/memory \
-Ilib/helpers \
-Ilib/fs \
-Ilib/fs/unpack \
-Ilib/fs/utils \
-I${ZEROVM_ROOT}/api
CFLAGS += -DDEBUG
CFLAGS += -DUSER_SIDE
CXXFLAGS = -I. -Ilib -Ilib/fs
################# "make all" Build libs
#debug: LDFLAGS+=-lgcov -fprofile-arcs
#debug: CFLAGS+=-Wdisabled-optimization -fprofile-arcs -ftest-coverage -fdump-rtl-all -fdump-ipa-all
#debug: prepare ${LIBS} ${LIBZRT} ${LIBZGLIBC} autotests
all:
all: prepare ${LIBS} ${LIBZRT} ${LIBZGLIBC} autotests
prepare:
@chmod u+rwx ns_start.sh
@chmod u+rwx ns_stop.sh
${LIBZRT} : $(LIBZRT_OBJECTS)
$(AR) rcs $@ $(LIBZRT_OBJECTS)
@echo $@ updated
${LIBZGLIBC} : $(LIBZGLIBC_OBJECTS)
$(AR) rcs $@ $(LIBZGLIBC_OBJECTS)
@echo $@ updated
############## Build libs, invoke nested Makefiles
${LIBS}:
@make -C$(dir $@)
@echo move $@ library to final folder
@mv -f $@ lib
############## "make test" Build & Run all tests
test: test_suites zrt_tests
############## "make autotests" run zrt autotests
autotests:
@echo ------------- RUN zrt $@ ------------
@TESTS_ROOT=$@ make -Ctests/zrt_test_suite
############## "make zrt_tests" Build test samples
test_suites: ${TEST_SUITES}
${TEST_SUITES}:
@make -Ctests/$@
############## "make zrt_tests" Build test samples
zrt_tests: ${TEST_SAMPLES}
${TEST_SAMPLES}:
@make -Ctests/zrt_test_suite/functional/$@
############## "make all_samples" Build samples
all_samples: ${SAMPLES}
${SAMPLES}:
@make -Csamples/$@
################ "make cleanall" Cleaning libs, tests, samples
cleanall: clean clean_samples clean_test_suites
################ "make clean" Cleaning libs
LIBS_CLEAN =$(foreach smpl, ${LIBS}, $(smpl).clean)
clean: ${LIBS_CLEAN}
${LIBS_CLEAN}:
@make -C$(dir $@) clean
@TESTS_ROOT=autotests make -Ctests/zrt_test_suite clean
@rm -f $(LIBZRT_OBJECTS)
@rm -f $(LIBZGLIBC_OBJECTS)
@rm -f $(LIBS)
@rm -f lib/*.a
################ "make clean_samples" Cleaning samples
SAMPLES_CLEAN =$(foreach smpl, ${SAMPLES}, $(smpl).clean)
TEST_SAMPLES_CLEAN=$(foreach smpl, ${TEST_SAMPLES}, $(smpl).clean)
clean_samples: ${SAMPLES_CLEAN} ${TEST_SAMPLES_CLEAN}
${SAMPLES_CLEAN}:
@make -Csamples/$(basename $@) clean
${TEST_SAMPLES_CLEAN}:
@make -Ctests/zrt_test_suite/functional/$(basename $@) clean
################ "make clean_test_suites" Cleaning test suites
TESTS_CLEAN=$(foreach suite, ${TEST_SUITES}, $(suite).clean)
clean_test_suites: ${TESTS_CLEAN}
${TESTS_CLEAN}:
@make -Ctests/$(basename $@) clean