Commit ad2e3222 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Andrei Vagin

compel cli: add libs command, use it

Add "compel libs" that prints the list of libraries needed
to link the parasite loader.

Make compel/test/ and criu/ to use it.

travis-ci: success for More polishing for compel cli
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 7ad7ee4d
...@@ -4,6 +4,9 @@ COMPEL_SO_VERSION := $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),. ...@@ -4,6 +4,9 @@ COMPEL_SO_VERSION := $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),.
COMPEL_SO_VERSION_CODE := $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL)) COMPEL_SO_VERSION_CODE := $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL))
ccflags-y += -DINCLUDEDIR=\"$(INCLUDEDIR)\" ccflags-y += -DINCLUDEDIR=\"$(INCLUDEDIR)\"
ccflags-y += -DLIBEXECDIR=\"$(LIBEXECDIR)\" ccflags-y += -DLIBEXECDIR=\"$(LIBEXECDIR)\"
ccflags-y += -DLIBDIR=\"$(LIBDIR)\"
ccflags-y += -DSTATIC_LIB=\"$(LIBCOMPEL_A)\"
ccflags-y += -DDYN_LIB=\"$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR)\"
ccflags-y += -iquote compel/arch/$(ARCH)/src/lib/include ccflags-y += -iquote compel/arch/$(ARCH)/src/lib/include
ccflags-y += -iquote compel/include ccflags-y += -iquote compel/include
ccflags-y += -fno-strict-aliasing ccflags-y += -fno-strict-aliasing
......
...@@ -121,6 +121,7 @@ static int usage(int rc) { ...@@ -121,6 +121,7 @@ static int usage(int rc) {
fprintf(out, fprintf(out,
"Usage:\n" "Usage:\n"
" compel [--compat] includes | cflags | ldflags | plugins\n" " compel [--compat] includes | cflags | ldflags | plugins\n"
" compel [--compat] [--static] libs\n"
" compel -f FILE -o FILE -p NAME [-l N] hgen\n" " compel -f FILE -o FILE -p NAME [-l N] hgen\n"
" -f, --file FILE input (parasite object) file name\n" " -f, --file FILE input (parasite object) file name\n"
" -o, --output FILE output (header) file name\n" " -o, --output FILE output (header) file name\n"
...@@ -194,17 +195,37 @@ static void print_plugins(const char *list[]) ...@@ -194,17 +195,37 @@ static void print_plugins(const char *list[])
} }
} }
static int print_libs(bool is_static)
{
if (uninst_root) {
if (!is_static) {
fprintf(stderr, "Compel is not installed, can "
"only link with static libraries "
"(use --static)\n");
return 1;
}
printf("%s/%s\n", uninst_root, STATIC_LIB);
}
else {
printf("%s/%s\n", LIBDIR, (is_static) ? STATIC_LIB : DYN_LIB);
}
return 0;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int log_level = DEFAULT_LOGLEVEL; int log_level = DEFAULT_LOGLEVEL;
bool compat = false; bool compat = false;
bool is_static = false;
int opt, idx; int opt, idx;
char *action; char *action;
const char *plugins_list[] = { "std", NULL }; const char *plugins_list[] = { "std", NULL };
static const char short_opts[] = "cf:o:p:hVl:"; static const char short_opts[] = "csf:o:p:hVl:";
static struct option long_opts[] = { static struct option long_opts[] = {
{ "compat", no_argument, 0, 'c' }, { "compat", no_argument, 0, 'c' },
{ "static", no_argument, 0, 's' },
{ "file", required_argument, 0, 'f' }, { "file", required_argument, 0, 'f' },
{ "output", required_argument, 0, 'o' }, { "output", required_argument, 0, 'o' },
{ "prefix", required_argument, 0, 'p' }, { "prefix", required_argument, 0, 'p' },
...@@ -225,6 +246,9 @@ int main(int argc, char *argv[]) ...@@ -225,6 +246,9 @@ int main(int argc, char *argv[])
case 'c': case 'c':
compat = true; compat = true;
break; break;
case 's':
is_static = true;
break;
case 'f': case 'f':
opts.input_filename = optarg; opts.input_filename = optarg;
break; break;
...@@ -280,6 +304,10 @@ int main(int argc, char *argv[]) ...@@ -280,6 +304,10 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
if (!strcmp(action, "libs")) {
return print_libs(is_static);
}
if (!strcmp(action, "hgen")) { if (!strcmp(action, "hgen")) {
if (!opts.input_filename) { if (!opts.input_filename) {
fprintf(stderr, "Error: option --file required\n"); fprintf(stderr, "Error: option --file required\n");
......
...@@ -2,7 +2,6 @@ CC := gcc ...@@ -2,7 +2,6 @@ CC := gcc
CFLAGS ?= -O2 -g -Wall -Werror CFLAGS ?= -O2 -g -Wall -Werror
COMPEL := ../../../compel/compel-host COMPEL := ../../../compel/compel-host
COMPEL_LIBRARY := ../../../compel/libcompel.a
all: victim spy all: victim spy
...@@ -17,7 +16,7 @@ victim: victim.c ...@@ -17,7 +16,7 @@ victim: victim.c
$(CC) $(CFLAGS) -o $@ $^ $(CC) $(CFLAGS) -o $@ $^
spy: spy.c parasite.h spy: spy.c parasite.h
$(CC) $(CFLAGS) $(shell $(COMPEL) includes) -o $@ $< $(COMPEL_LIBRARY) $(CC) $(CFLAGS) $(shell $(COMPEL) includes) -o $@ $< $(shell $(COMPEL) --static libs)
parasite.h: parasite.po parasite.h: parasite.po
$(COMPEL) hgen -f $^ -l 4 \ $(COMPEL) hgen -f $^ -l 4 \
......
...@@ -2,7 +2,6 @@ CC := gcc ...@@ -2,7 +2,6 @@ CC := gcc
CFLAGS ?= -O2 -g -Wall -Werror CFLAGS ?= -O2 -g -Wall -Werror
COMPEL := ../../../compel/compel-host COMPEL := ../../../compel/compel-host
COMPEL_LIBRARY := ../../../compel/libcompel.a
all: victim spy all: victim spy
...@@ -14,4 +13,4 @@ victim: victim.c ...@@ -14,4 +13,4 @@ victim: victim.c
$(CC) $(CFLAGS) -o $@ $^ $(CC) $(CFLAGS) -o $@ $^
spy: spy.c spy: spy.c
$(CC) $(CFLAGS) $(shell $(COMPEL) includes) -o $@ $^ $(COMPEL_LIBRARY) $(CC) $(CFLAGS) $(shell $(COMPEL) includes) -o $@ $^ $(shell $(COMPEL) --static libs)
...@@ -9,6 +9,7 @@ export ARCH_DIR PIE_DIR ...@@ -9,6 +9,7 @@ export ARCH_DIR PIE_DIR
ifeq ($(filter clean mrproper,$(MAKECMDGOALS)),) ifeq ($(filter clean mrproper,$(MAKECMDGOALS)),)
COMPEL_UAPI_INCLUDES := $(shell $(COMPEL_BIN) includes) COMPEL_UAPI_INCLUDES := $(shell $(COMPEL_BIN) includes)
export COMPEL_UAPI_INCLUDES export COMPEL_UAPI_INCLUDES
COMPEL_LIBS := $(shell $(COMPEL_BIN) --static libs)
endif endif
# #
...@@ -65,7 +66,7 @@ PROGRAM-BUILTINS += images/built-in.o ...@@ -65,7 +66,7 @@ PROGRAM-BUILTINS += images/built-in.o
PROGRAM-BUILTINS += $(obj)/built-in.o PROGRAM-BUILTINS += $(obj)/built-in.o
PROGRAM-BUILTINS += $(ARCH-LIB) PROGRAM-BUILTINS += $(ARCH-LIB)
PROGRAM-BUILTINS += soccr/libsoccr.a PROGRAM-BUILTINS += soccr/libsoccr.a
PROGRAM-BUILTINS += compel/libcompel.a PROGRAM-BUILTINS += $(COMPEL_LIBS)
$(obj)/built-in.o: pie $(obj)/built-in.o: pie
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) all $(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) all
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment