From c3be09411a40ba09af14fe57df33e1ec3bfb5cd5 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Fri, 3 Dec 2021 08:38:27 -0700 Subject: [PATCH] automake: idiomatically mark test libraries as convenience libraries Instead of installing then deleting, mark the libraries which are only used at build time and should not be installed as noinst, so they don't get installed at all. Signed-off-by: Ross Burton Signed-off-by: Tom Hromatka (cherry picked from commit 1932bd3c46fc5f3532d6583ccc2ccd4c8d8530a2) --- src/Makefile.am | 9 +++------ src/tools/Makefile.am | 5 +---- src/tools/cgset.c | 4 ++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 30feb613..26e32238 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,20 +14,17 @@ AM_YFLAGS = -d CLEANFILES = lex.c parse.c parse.h AM_CPPFLAGS = -I$(top_srcdir)/include -lib_LTLIBRARIES = libcgroup.la libcgroupfortesting.la + +lib_LTLIBRARIES = libcgroup.la libcgroup_la_SOURCES = parse.h parse.y lex.l api.c config.c libcgroup-internal.h libcgroup.map wrapper.c log.c libcgroup_la_LIBADD = -lpthread $(CODE_COVERAGE_LIBS) libcgroup_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC=static libcgroup_la_LDFLAGS = -Wl,--version-script,$(srcdir)/libcgroup.map \ -version-number $(LIBRARY_VERSION_MAJOR):$(LIBRARY_VERSION_MINOR):$(LIBRARY_VERSION_RELEASE) +noinst_LTLIBRARIES = libcgroupfortesting.la libcgroupfortesting_la_SOURCES = $(libcgroup_la_SOURCES) libcgroupfortesting_la_LIBADD = -lpthread $(CODE_COVERAGE_LIBS) libcgroupfortesting_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC= -DUNIT_TEST libcgroupfortesting_la_LDFLAGS = -Wl,--version-script,$(top_srcdir)/tests/gunit/libcgroup_unittest.map \ -version-number $(LIBRARY_VERSION_MAJOR):$(LIBRARY_VERSION_MINOR):$(LIBRARY_VERSION_RELEASE) - -install-exec-hook: - find $(DESTDIR)$(libdir) -type f -name libcgroupfortesting.\* -delete - unlink $(DESTDIR)$(libdir)/libcgroupfortesting.so - unlink $(DESTDIR)$(libdir)/libcgroupfortesting.so.$(LIBRARY_VERSION_MAJOR) diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index bf761573..40608873 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -10,7 +10,7 @@ bin_PROGRAMS = cgexec cgclassify cgcreate cgset cgget cgdelete lssubsys\ sbin_PROGRAMS = cgconfigparser cgclear -lib_LTLIBRARIES = libcgset.la +noinst_LTLIBRARIES = libcgset.la cgexec_SOURCES = cgexec.c tools-common.c tools-common.h cgexec_LIBS = $(CODE_COVERAGE_LIBS) @@ -63,8 +63,5 @@ cgsnapshot_CFLAGS = $(CODE_COVERAGE_CFLAGS) install-exec-hook: chmod u+s $(DESTDIR)$(bindir)/cgexec - find $(DESTDIR)$(libdir) -type f -name libcgset.\* -delete - unlink $(DESTDIR)$(libdir)/libcgset.so - unlink $(DESTDIR)$(libdir)/libcgset.so.0 endif diff --git a/src/tools/cgset.c b/src/tools/cgset.c index fca08d83..a59e1d32 100644 --- a/src/tools/cgset.c +++ b/src/tools/cgset.c @@ -16,6 +16,7 @@ enum { COPY_FROM_OPTION = CHAR_MAX + 1 }; +#ifndef UNIT_TEST static struct option const long_options[] = { {"rule", required_argument, NULL, 'r'}, @@ -72,6 +73,7 @@ static void usage(int status, const char *program_name) printf(" --copy-from Control group whose "\ "parameters will be copied\n"); } +#endif /* !UNIT_TEST */ STATIC int parse_r_flag(const char * const program_name, const char * const name_value_str, @@ -124,6 +126,7 @@ err: return ret; } +#ifndef UNIT_TEST int main(int argc, char *argv[]) { int ret = 0; @@ -278,3 +281,4 @@ err: free(name_value); return ret; } +#endif /* !UNIT_TEST */ -- 2.47.2