gitee.com/mysnapcore/mysnapd@v0.1.0/cmd/Makefile.am (about)

     1  
     2  EXTRA_DIST = VERSION snap-confine/PORTING
     3  CLEANFILES =
     4  TESTS =
     5  libexec_PROGRAMS =
     6  dist_man_MANS =
     7  noinst_PROGRAMS =
     8  noinst_LIBRARIES =
     9  
    10  CHECK_CFLAGS = -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes \
    11  	-Wno-missing-field-initializers -Wno-unused-parameter
    12  
    13  # Make all warnings errors when building for unit tests
    14  if WITH_UNIT_TESTS
    15  CHECK_CFLAGS += -Werror
    16  endif
    17  
    18  if USE_INTERNAL_BPF_HEADERS
    19  VENDOR_BPF_HEADERS_CFLAGS = -I$(srcdir)/libsnap-confine-private/bpf/vendor
    20  endif
    21  
    22  subdirs = \
    23  		  libsnap-confine-private \
    24  		  snap-confine \
    25  		  snap-device-helper \
    26  		  snap-discard-ns \
    27  		  snap-gdb-shim \
    28  		  snap-update-ns \
    29  		  snapd-env-generator \
    30  		  snapd-generator \
    31  		  system-shutdown
    32  
    33  # Run check-syntax when checking
    34  # TODO: conver those to autotools-style tests later
    35  check: check-unit-tests
    36  
    37  # Force particular coding style on all source and header files.
    38  .PHONY: check-syntax-c
    39  check-syntax-c:
    40  	echo "WARNING: check-syntax-c produces different results for different version of indent"
    41  	echo "Your version of indent: `indent --version`"
    42  	@d=`mktemp -d`; \
    43  	trap 'rm -rf $d' EXIT; \
    44  	for f in $(foreach dir,$(subdirs),$(wildcard $(srcdir)/$(dir)/*.[ch])) ; do \
    45  	       out="$$d/`basename $$f.out`"; \
    46  	       echo "Checking $$f ... "; \
    47  	       HOME=$(srcdir) indent "$$f" -o "$$out"; \
    48  	       diff -Naur "$$f" "$$out" || exit 1; \
    49  	done;
    50  
    51  .PHONY: check-unit-tests
    52  if WITH_UNIT_TESTS
    53  check-unit-tests: snap-confine/unit-tests system-shutdown/unit-tests libsnap-confine-private/unit-tests snap-device-helper/unit-tests
    54  	$(HAVE_VALGRIND) ./libsnap-confine-private/unit-tests
    55  	$(HAVE_VALGRIND) ./snap-confine/unit-tests
    56  	$(HAVE_VALGRIND) ./system-shutdown/unit-tests
    57  	$(HAVE_VALGRIND) ./snap-device-helper/unit-tests
    58  else
    59  check-unit-tests:
    60  	echo "unit tests are disabled (rebuild with --enable-unit-tests)"
    61  endif
    62  
    63  new_format = \
    64  	 libsnap-confine-private/bpf-support.c \
    65  	 libsnap-confine-private/bpf-support.h \
    66  	 libsnap-confine-private/cgroup-support.c \
    67  	 libsnap-confine-private/cgroup-support.h \
    68  	 libsnap-confine-private/cgroup-support-test.c \
    69  	 libsnap-confine-private/device-cgroup-support.c \
    70  	 libsnap-confine-private/device-cgroup-support.h \
    71  	 libsnap-confine-private/infofile-test.c \
    72  	 libsnap-confine-private/infofile.c \
    73  	 libsnap-confine-private/infofile.h \
    74  	 libsnap-confine-private/panic-test.h \
    75  	 libsnap-confine-private/panic.c \
    76  	 libsnap-confine-private/panic.h \
    77  	 snap-confine/seccomp-support-ext.c \
    78  	 snap-confine/seccomp-support-ext.h \
    79  	 snap-confine/selinux-support.c \
    80  	 snap-confine/selinux-support.h \
    81  	 snap-confine/snap-confine-invocation-test.c \
    82  	 snap-confine/snap-confine-invocation.c \
    83  	 snap-confine/snap-confine-invocation.h \
    84  	 snap-device-helper/main.c \
    85  	 snap-device-helper/snap-device-helper.c \
    86  	 snap-device-helper/snap-device-helper.h \
    87  	 snap-device-helper/snap-device-helper-test.c \
    88  	 snap-discard-ns/snap-discard-ns.c \
    89  	 snap-gdb-shim/snap-gdb-shim.c \
    90  	 snap-gdb-shim/snap-gdbserver-shim.c
    91  
    92  # NOTE: clang-format is using project-wide .clang-format file.
    93  .PHONY: fmt
    94  fmt:: $(filter     $(addprefix %,$(new_format)),$(foreach dir,$(subdirs),$(wildcard $(srcdir)/$(dir)/*.[ch])))
    95  	clang-format -i $^
    96  
    97  fmt:: $(filter-out $(addprefix %,$(new_format)),$(foreach dir,$(subdirs),$(wildcard $(srcdir)/$(dir)/*.[ch])))
    98  	HOME=$(srcdir) indent $^
    99  
   100  # The hack target helps developers work on snap-confine on their live system by
   101  # installing a fresh copy of snap confine and the appropriate apparmor profile.
   102  .PHONY: hack
   103  hack: snap-confine/snap-confine-debug snap-confine/snap-confine.apparmor snap-update-ns/snap-update-ns snap-seccomp/snap-seccomp snap-discard-ns/snap-discard-ns snap-device-helper/snap-device-helper snapd-apparmor/snapd-apparmor
   104  	sudo install -D -m 4755 snap-confine/snap-confine-debug $(DESTDIR)$(libexecdir)/snap-confine
   105  	if [ -d /etc/apparmor.d ]; then sudo install -m 644 snap-confine/snap-confine.apparmor $(DESTDIR)/etc/apparmor.d/$(patsubst .%,%,$(subst /,.,$(libexecdir))).snap-confine.real; fi
   106  	sudo install -d -m 755 $(DESTDIR)/var/lib/snapd/apparmor/snap-confine/
   107  	if [ "$$(command -v apparmor_parser)" != "" ]; then sudo apparmor_parser -r snap-confine/snap-confine.apparmor; fi
   108  	sudo install -m 755 snap-update-ns/snap-update-ns $(DESTDIR)$(libexecdir)/snap-update-ns
   109  	sudo install -m 755 snap-discard-ns/snap-discard-ns $(DESTDIR)$(libexecdir)/snap-discard-ns
   110  	sudo install -m 755 snap-seccomp/snap-seccomp $(DESTDIR)$(libexecdir)/snap-seccomp
   111  	sudo install -m 755 snap-device-helper/snap-device-helper $(DESTDIR)$(libexecdir)/snap-device-helper
   112  	sudo install -m 755 snapd-apparmor/snapd-apparmor $(DESTDIR)$(libexecdir)/snapd-apparmor
   113  	if [ "$$(command -v restorecon)" != "" ]; then sudo restorecon -R -v $(DESTDIR)$(libexecdir)/; fi
   114  
   115  # for the hack target also:
   116  snap-update-ns/snap-update-ns: snap-update-ns/*.go snap-update-ns/*.[ch]
   117  	cd snap-update-ns && GOPATH=$(or $(GOPATH),$(realpath $(srcdir)/../../../../..)) go build \
   118  		-ldflags='-extldflags=-static -linkmode=external' -v
   119  snap-seccomp/snap-seccomp: snap-seccomp/*.go
   120  	cd snap-seccomp && GOPATH=$(or $(GOPATH),$(realpath $(srcdir)/../../../../..)) go build -v
   121  snapd-apparmor/snapd-apparmor: snapd-apparmor/*.go
   122  	cd snapd-apparmor && GOPATH=$(or $(GOPATH),$(realpath $(srcdir)/../../../../..)) go build -v
   123  
   124  ##
   125  ## libsnap-confine-private.a
   126  ##
   127  
   128  noinst_LIBRARIES += libsnap-confine-private.a
   129  
   130  libsnap_confine_private_a_SOURCES = \
   131  	libsnap-confine-private/apparmor-support.c \
   132  	libsnap-confine-private/apparmor-support.h \
   133  	libsnap-confine-private/cgroup-freezer-support.c \
   134  	libsnap-confine-private/cgroup-freezer-support.h \
   135  	libsnap-confine-private/cgroup-support.c \
   136  	libsnap-confine-private/cgroup-support.h \
   137  	libsnap-confine-private/device-cgroup-support.c \
   138  	libsnap-confine-private/device-cgroup-support.h \
   139  	libsnap-confine-private/classic.c \
   140  	libsnap-confine-private/classic.h \
   141  	libsnap-confine-private/cleanup-funcs.c \
   142  	libsnap-confine-private/cleanup-funcs.h \
   143  	libsnap-confine-private/error.c \
   144  	libsnap-confine-private/error.h \
   145  	libsnap-confine-private/fault-injection.c \
   146  	libsnap-confine-private/fault-injection.h \
   147  	libsnap-confine-private/feature.c \
   148  	libsnap-confine-private/feature.h \
   149  	libsnap-confine-private/infofile.c \
   150  	libsnap-confine-private/locking.c \
   151  	libsnap-confine-private/locking.h \
   152  	libsnap-confine-private/mount-opt.c \
   153  	libsnap-confine-private/mount-opt.h \
   154  	libsnap-confine-private/mountinfo.c \
   155  	libsnap-confine-private/mountinfo.h \
   156  	libsnap-confine-private/panic.c \
   157  	libsnap-confine-private/panic.h \
   158  	libsnap-confine-private/privs.c \
   159  	libsnap-confine-private/privs.h \
   160  	libsnap-confine-private/secure-getenv.c \
   161  	libsnap-confine-private/secure-getenv.h \
   162  	libsnap-confine-private/snap.c \
   163  	libsnap-confine-private/snap.h \
   164  	libsnap-confine-private/string-utils.c \
   165  	libsnap-confine-private/string-utils.h \
   166  	libsnap-confine-private/tool.c \
   167  	libsnap-confine-private/tool.h \
   168  	libsnap-confine-private/utils.c \
   169  	libsnap-confine-private/utils.h
   170  if ENABLE_BPF
   171  libsnap_confine_private_a_SOURCES += \
   172  	libsnap-confine-private/bpf-support.c \
   173  	libsnap-confine-private/bpf-support.h
   174  endif
   175  libsnap_confine_private_a_CFLAGS = $(CHECK_CFLAGS) $(VENDOR_BPF_HEADERS_CFLAGS)
   176  
   177  noinst_LIBRARIES += libsnap-confine-private-debug.a
   178  libsnap_confine_private_debug_a_SOURCES = $(libsnap_confine_private_a_SOURCES)
   179  libsnap_confine_private_debug_a_CFLAGS = $(CHECK_CFLAGS) $(VENDOR_BPF_HEADERS_CFLAGS) -DSNAP_CONFINE_DEBUG_BUILD=1
   180  
   181  if WITH_UNIT_TESTS
   182  noinst_PROGRAMS += libsnap-confine-private/unit-tests
   183  libsnap_confine_private_unit_tests_SOURCES = \
   184  	libsnap-confine-private/cgroup-support-test.c \
   185  	libsnap-confine-private/classic-test.c \
   186  	libsnap-confine-private/cleanup-funcs-test.c \
   187  	libsnap-confine-private/error-test.c \
   188  	libsnap-confine-private/fault-injection-test.c \
   189  	libsnap-confine-private/feature-test.c \
   190  	libsnap-confine-private/infofile-test.c \
   191  	libsnap-confine-private/locking-test.c \
   192  	libsnap-confine-private/mount-opt-test.c \
   193  	libsnap-confine-private/mountinfo-test.c \
   194  	libsnap-confine-private/panic-test.c \
   195  	libsnap-confine-private/privs-test.c \
   196  	libsnap-confine-private/secure-getenv-test.c \
   197  	libsnap-confine-private/snap-test.c \
   198  	libsnap-confine-private/string-utils-test.c \
   199  	libsnap-confine-private/test-utils-test.c \
   200  	libsnap-confine-private/test-utils.c \
   201  	libsnap-confine-private/unit-tests-main.c \
   202  	libsnap-confine-private/unit-tests.c \
   203  	libsnap-confine-private/unit-tests.h \
   204  	libsnap-confine-private/utils-test.c
   205  
   206  libsnap_confine_private_unit_tests_CFLAGS = $(CHECK_CFLAGS) $(VENDOR_BPF_HEADERS_CFLAGS) $(GLIB_CFLAGS)
   207  libsnap_confine_private_unit_tests_LDADD = $(GLIB_LIBS)
   208  libsnap_confine_private_unit_tests_CFLAGS += -D_ENABLE_FAULT_INJECTION
   209  libsnap_confine_private_unit_tests_STATIC =
   210  
   211  if STATIC_LIBCAP
   212  libsnap_confine_private_unit_tests_STATIC += -lcap
   213  else
   214  libsnap_confine_private_unit_tests_LDADD += -lcap
   215  endif  # STATIC_LIBCAP
   216  
   217  # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
   218  libsnap-confine-private/unit-tests$(EXEEXT): $(libsnap_confine_private_unit_tests_OBJECTS) $(libsnap_confine_private_unit_tests_DEPENDENCIES) $(EXTRA_libsnap_confine_private_unit_tests_DEPENDENCIES) libsnap-confine-private/$(am__dirstamp)
   219  	@rm -f libsnap-confine-private/unit-tests$(EXEEXT)
   220  	$(AM_V_CCLD)$(libsnap_confine_private_unit_tests_LINK) $(libsnap_confine_private_unit_tests_OBJECTS) $(libsnap_confine_private_unit_tests_LDADD) $(LIBS)
   221  
   222  libsnap-confine-private/unit-tests$(EXEEXT): LIBS += -Wl,-Bstatic $(libsnap_confine_private_unit_tests_STATIC) -Wl,-Bdynamic
   223  endif  # WITH_UNIT_TESTS
   224  
   225  ##
   226  ## decode-mount-opts
   227  ##
   228  
   229  noinst_PROGRAMS += decode-mount-opts/decode-mount-opts
   230  
   231  decode_mount_opts_decode_mount_opts_SOURCES = \
   232  	decode-mount-opts/decode-mount-opts.c
   233  decode_mount_opts_decode_mount_opts_LDADD = libsnap-confine-private.a
   234  decode_mount_opts_decode_mount_opts_STATIC =
   235  
   236  if STATIC_LIBCAP
   237  decode_mount_opts_decode_mount_opts_STATIC += -lcap
   238  else
   239  decode_mount_opts_decode_mount_opts_LDADD += -lcap
   240  endif  # STATIC_LIBCAP
   241  
   242  # XXX: this makes automake generate decode_mount_opts_decode_mount_opts_LINK
   243  decode_mount_opts_decode_mount_opts_CFLAGS = -D_fake
   244  
   245  # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
   246  decode-mount-opts/decode-mount-opts$(EXEEXT): $(decode_mount_opts_decode_mount_opts_OBJECTS) $(decode_mount_opts_decode_mount_opts_DEPENDENCIES) $(EXTRA_decode_mount_opts_decode_mount_opts_DEPENDENCIES) libsnap-confine-private/$(am__dirstamp)
   247  	@rm -f decode-mount-opts/decode-mount-opts$(EXEEXT)
   248  	$(AM_V_CCLD)$(decode_mount_opts_decode_mount_opts_LINK) $(decode_mount_opts_decode_mount_opts_OBJECTS) $(decode_mount_opts_decode_mount_opts_LDADD) $(LIBS)
   249  
   250  decode-mount-opts/decode-mount-opts$(EXEEXT): LIBS += -Wl,-Bstatic $(decode_mount_opts_decode_mount_opts_STATIC) -Wl,-Bdynamic
   251  
   252  ##
   253  ## snap-confine
   254  ##
   255  
   256  libexec_PROGRAMS += snap-confine/snap-confine
   257  if HAVE_RST2MAN
   258  dist_man_MANS += snap-confine/snap-confine.8
   259  CLEANFILES += snap-confine/snap-confine.8
   260  endif
   261  EXTRA_DIST += snap-confine/snap-confine.rst
   262  EXTRA_DIST += snap-confine/snap-confine.apparmor.in
   263  
   264  snap_confine_snap_confine_SOURCES = \
   265  	snap-confine/cookie-support.c \
   266  	snap-confine/cookie-support.h \
   267  	snap-confine/mount-support-nvidia.c \
   268  	snap-confine/mount-support-nvidia.h \
   269  	snap-confine/mount-support.c \
   270  	snap-confine/mount-support.h \
   271  	snap-confine/ns-support.c \
   272  	snap-confine/ns-support.h \
   273  	snap-confine/seccomp-support-ext.c \
   274  	snap-confine/seccomp-support-ext.h \
   275  	snap-confine/seccomp-support.c \
   276  	snap-confine/seccomp-support.h \
   277  	snap-confine/snap-confine-args.c \
   278  	snap-confine/snap-confine-args.h \
   279  	snap-confine/snap-confine-invocation.c \
   280  	snap-confine/snap-confine-invocation.h \
   281  	snap-confine/snap-confine.c \
   282  	snap-confine/udev-support.c \
   283  	snap-confine/udev-support.h \
   284  	snap-confine/user-support.c \
   285  	snap-confine/user-support.h
   286  
   287  snap_confine_snap_confine_CFLAGS = $(CHECK_CFLAGS) $(AM_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -DNATIVE_LIBDIR=\"$(libdir)\"
   288  snap_confine_snap_confine_LDFLAGS = $(AM_LDFLAGS)
   289  snap_confine_snap_confine_LDADD = libsnap-confine-private.a
   290  snap_confine_snap_confine_CFLAGS += $(LIBUDEV_CFLAGS)
   291  snap_confine_snap_confine_LDADD += $(snap_confine_snap_confine_extra_libs)
   292  # _STATIC is where we collect statically linked in libraries
   293  snap_confine_snap_confine_STATIC =
   294  # use a separate variable instead of snap_confine_snap_confine_LDADD to collect
   295  # all external libraries, this way it can be reused in
   296  # snap_confine_snap_confine_debug_LDADD withouth applying any text
   297  # transformations
   298  snap_confine_snap_confine_extra_libs = $(LIBUDEV_LIBS) -ldl
   299  
   300  if STATIC_LIBCAP
   301  snap_confine_snap_confine_STATIC += -lcap
   302  else
   303  snap_confine_snap_confine_extra_libs += -lcap
   304  endif  # STATIC_LIBCAP
   305  
   306  # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
   307  snap-confine/snap-confine$(EXEEXT): $(snap_confine_snap_confine_OBJECTS) $(snap_confine_snap_confine_DEPENDENCIES) $(EXTRA_snap_confine_snap_confine_DEPENDENCIES) libsnap-confine-private/$(am__dirstamp)
   308  	@rm -f snap-confine/snap-confine$(EXEEXT)
   309  	$(AM_V_CCLD)$(snap_confine_snap_confine_LINK) $(snap_confine_snap_confine_OBJECTS) $(snap_confine_snap_confine_LDADD) $(LIBS)
   310  
   311  snap-confine/snap-confine$(EXEEXT): LIBS += -Wl,-Bstatic $(snap_confine_snap_confine_STATIC) -Wl,-Bdynamic -pthread
   312  
   313  # This is here to help fix rpmlint hardening issue.
   314  # https://en.opensuse.org/openSUSE:Packaging_checks#non-position-independent-executable
   315  snap_confine_snap_confine_CFLAGS += $(SUID_CFLAGS)
   316  snap_confine_snap_confine_LDFLAGS += $(SUID_LDFLAGS)
   317  
   318  if APPARMOR
   319  snap_confine_snap_confine_CFLAGS += $(APPARMOR_CFLAGS)
   320  if STATIC_LIBAPPARMOR
   321  snap_confine_snap_confine_STATIC += $(shell $(PKG_CONFIG) --static --libs libapparmor)
   322  else
   323  snap_confine_snap_confine_extra_libs += $(APPARMOR_LIBS)
   324  endif  # STATIC_LIBAPPARMOR
   325  endif  # APPARMOR
   326  
   327  if SELINUX
   328  snap_confine_snap_confine_SOURCES += \
   329  	snap-confine/selinux-support.c \
   330  	snap-confine/selinux-support.h
   331  snap_confine_snap_confine_CFLAGS += $(SELINUX_CFLAGS)
   332  if STATIC_LIBSELINUX
   333  snap_confine_snap_confine_STATIC += $(shell $(PKG_CONFIG) --static --libs libselinux)
   334  else
   335  snap_confine_snap_confine_extra_libs += $(SELINUX_LIBS)
   336  endif  # STATIC_LIBSELINUX
   337  endif  # SELINUX
   338  
   339  # an extra build that has additional debugging enabled at compile time
   340  
   341  noinst_PROGRAMS += snap-confine/snap-confine-debug
   342  snap_confine_snap_confine_debug_SOURCES = $(snap_confine_snap_confine_SOURCES)
   343  snap_confine_snap_confine_debug_CFLAGS = $(snap_confine_snap_confine_CFLAGS)
   344  snap_confine_snap_confine_debug_LDFLAGS = $(snap_confine_snap_confine_LDFLAGS)
   345  snap_confine_snap_confine_debug_LDADD = libsnap-confine-private-debug.a $(snap_confine_snap_confine_extra_libs)
   346  snap_confine_snap_confine_debug_CFLAGS += -DSNAP_CONFINE_DEBUG_BUILD=1
   347  snap_confine_snap_confine_debug_STATIC = $(snap_confine_snap_confine_STATIC)
   348  
   349  # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
   350  snap-confine/snap-confine-debug$(EXEEXT): $(snap_confine_snap_confine_debug_OBJECTS) $(snap_confine_snap_confine_debug_DEPENDENCIES) $(EXTRA_snap_confine_snap_confine_debug_DEPENDENCIES) libsnap-confine-private/$(am__dirstamp)
   351  	@rm -f snap-confine/snap-confine-debug$(EXEEXT)
   352  	$(AM_V_CCLD)$(snap_confine_snap_confine_debug_LINK) $(snap_confine_snap_confine_debug_OBJECTS) $(snap_confine_snap_confine_debug_LDADD) $(LIBS)
   353  
   354  snap-confine/snap-confine-debug$(EXEEXT): LIBS += -Wl,-Bstatic $(snap_confine_snap_confine_debug_STATIC) -Wl,-Bdynamic -pthread
   355  
   356  if WITH_UNIT_TESTS
   357  noinst_PROGRAMS += snap-confine/unit-tests
   358  snap_confine_unit_tests_SOURCES = \
   359  	libsnap-confine-private/test-utils.c \
   360  	libsnap-confine-private/unit-tests-main.c \
   361  	libsnap-confine-private/unit-tests.c \
   362  	libsnap-confine-private/unit-tests.h \
   363  	snap-confine/cookie-support-test.c \
   364  	snap-confine/mount-support-test.c \
   365  	snap-confine/ns-support-test.c \
   366  	snap-confine/snap-confine-args-test.c \
   367  	snap-confine/snap-confine-invocation-test.c
   368  snap_confine_unit_tests_CFLAGS = $(snap_confine_snap_confine_CFLAGS) $(GLIB_CFLAGS)
   369  snap_confine_unit_tests_LDADD = $(snap_confine_snap_confine_LDADD) $(GLIB_LIBS)
   370  snap_confine_unit_tests_LDFLAGS = $(snap_confine_snap_confine_LDFLAGS)
   371  snap_confine_unit_tests_STATIC = $(snap_confine_snap_confine_STATIC)
   372  
   373  # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
   374  snap-confine/unit-tests$(EXEEXT): $(snap_confine_unit_tests_OBJECTS) $(snap_confine_unit_tests_DEPENDENCIES) $(EXTRA_snap_confine_unit_tests_DEPENDENCIES) libsnap-confine-private/$(am__dirstamp)
   375  	@rm -f snap-confine/unit-tests$(EXEEXT)
   376  	$(AM_V_CCLD)$(snap_confine_unit_tests_LINK) $(snap_confine_unit_tests_OBJECTS) $(snap_confine_unit_tests_LDADD) $(LIBS)
   377  
   378  snap-confine/unit-tests$(EXEEXT): LIBS += -Wl,-Bstatic $(snap_confine_unit_tests_STATIC) -Wl,-Bdynamic -pthread
   379  endif  # WITH_UNIT_TESTS
   380  
   381  if HAVE_RST2MAN
   382  %.8: %.rst
   383  	$(HAVE_RST2MAN) $^ > $@
   384  endif
   385  
   386  snap-confine/snap-confine.apparmor: snap-confine/snap-confine.apparmor.in Makefile
   387  	sed -e 's,[@]LIBEXECDIR[@],$(libexecdir),g' -e 's,[@]SNAP_MOUNT_DIR[@],$(SNAP_MOUNT_DIR),g' <$< >$@
   388  
   389  # Install the apparmor profile
   390  #
   391  # NOTE: the funky make functions here just convert /foo/bar/froz into
   392  # foo.bar.froz The inner subst replaces slashes with dots and the outer
   393  # patsubst strips the leading dot
   394  install-data-local:: snap-confine/snap-confine.apparmor
   395  if APPARMOR
   396  	install -d -m 755 $(DESTDIR)/etc/apparmor.d/
   397  	install -m 644 snap-confine/snap-confine.apparmor $(DESTDIR)/etc/apparmor.d/$(patsubst .%,%,$(subst /,.,$(libexecdir))).snap-confine
   398  endif
   399  	install -d -m 755 $(DESTDIR)/var/lib/snapd/apparmor/snap-confine/
   400  
   401  # NOTE: The 'void' directory *has to* be chmod 111
   402  install-data-local::
   403  	install -d -m 111 $(DESTDIR)/var/lib/snapd/void
   404  
   405  install-exec-hook::
   406  # Ensure that snap-confine is u+s (setuid)
   407  	chmod 4755 $(DESTDIR)$(libexecdir)/snap-confine
   408  
   409  ##
   410  ## snap-mgmt
   411  ##
   412  
   413  libexec_SCRIPTS = snap-mgmt/snap-mgmt
   414  CLEANFILES += snap-mgmt/$(am__dirstamp) snap-mgmt/snap-mgmt
   415  
   416  snap-mgmt/$(am__dirstamp):
   417  	mkdir -p $$(dirname $@)
   418  	touch $@
   419  
   420  snap-mgmt/snap-mgmt: snap-mgmt/snap-mgmt.sh.in Makefile snap-mgmt/$(am__dirstamp)
   421  	sed -e 's,[@]SNAP_MOUNT_DIR[@],$(SNAP_MOUNT_DIR),' <$< >$@
   422  
   423  if SELINUX
   424  ##
   425  ## snap-mgmt-selinux
   426  ##
   427  
   428  libexec_SCRIPTS += snap-mgmt/snap-mgmt-selinux
   429  CLEANFILES += snap-mgmt/$(am__dirstamp) snap-mgmt/snap-mgmt-selinux
   430  
   431  snap-mgmt/snap-mgmt-selinux: snap-mgmt/snap-mgmt-selinux.sh.in Makefile snap-mgmt/$(am__dirstamp)
   432  	sed -e 's,[@]SNAP_MOUNT_DIR[@],$(SNAP_MOUNT_DIR),' <$< >$@
   433  endif
   434  
   435  ##
   436  ## ubuntu-core-launcher
   437  ##
   438  
   439  install-exec-hook::
   440  	install -d -m 755 $(DESTDIR)$(bindir)
   441  	ln -sf $(libexecdir)/snap-confine $(DESTDIR)$(bindir)/ubuntu-core-launcher
   442  
   443  ##
   444  ## snap-device-helper
   445  ##
   446  
   447  libexec_PROGRAMS += \
   448  	snap-device-helper/snap-device-helper
   449  
   450  snap_device_helper_snap_device_helper_SOURCES = \
   451  	snap-device-helper/main.c \
   452  	snap-device-helper/snap-device-helper.c
   453  snap_device_helper_snap_device_helper_CFLAGS = $(CHECK_CFLAGS) $(AM_CFLAGS)
   454  snap_device_helper_snap_device_helper_LDFLAGS = $(AM_LDFLAGS)
   455  snap_device_helper_snap_device_helper_LDADD = libsnap-confine-private.a
   456  
   457  if WITH_UNIT_TESTS
   458  noinst_PROGRAMS += snap-device-helper/unit-tests
   459  snap_device_helper_unit_tests_SOURCES = \
   460  	libsnap-confine-private/test-utils.c \
   461  	libsnap-confine-private/string-utils.c \
   462  	libsnap-confine-private/utils.c \
   463  	libsnap-confine-private/cleanup-funcs.c \
   464  	libsnap-confine-private/panic.c \
   465  	libsnap-confine-private/snap.c \
   466  	libsnap-confine-private/error.c \
   467  	libsnap-confine-private/unit-tests-main.c \
   468  	libsnap-confine-private/unit-tests.c \
   469  	libsnap-confine-private/unit-tests.h \
   470  	snap-device-helper/snap-device-helper-test.c
   471  snap_device_helper_unit_tests_CFLAGS = $(snap_device_helper_snap_device_helper_CFLAGS) $(GLIB_CFLAGS)
   472  snap_device_helper_unit_tests_LDADD = $(GLIB_LIBS)
   473  snap_device_helper_unit_tests_LDFLAGS =$(snap_device_helper_snap_device_helper_LDFLAGS)
   474  
   475  endif  # WITH_UNIT_TESTS
   476  
   477  ##
   478  ## snap-discard-ns
   479  ##
   480  
   481  libexec_PROGRAMS += snap-discard-ns/snap-discard-ns
   482  if HAVE_RST2MAN
   483  dist_man_MANS += snap-discard-ns/snap-discard-ns.8
   484  CLEANFILES += snap-discard-ns/snap-discard-ns.8
   485  endif
   486  EXTRA_DIST += snap-discard-ns/snap-discard-ns.rst
   487  
   488  snap_discard_ns_snap_discard_ns_SOURCES = \
   489  	snap-discard-ns/snap-discard-ns.c
   490  snap_discard_ns_snap_discard_ns_CFLAGS = $(CHECK_CFLAGS) $(AM_CFLAGS)
   491  snap_discard_ns_snap_discard_ns_LDFLAGS = $(AM_LDFLAGS)
   492  snap_discard_ns_snap_discard_ns_LDADD = libsnap-confine-private.a
   493  snap_discard_ns_snap_discard_ns_STATIC =
   494  
   495  # Use a hacked rule if we're doing static build. This allows us to inject the LIBS += .. rule below.
   496  snap-discard-ns/snap-discard-ns$(EXEEXT): $(snap_discard_ns_snap_discard_ns_OBJECTS) $(snap_discard_ns_snap_discard_ns_DEPENDENCIES) $(EXTRA_snap_discard_ns_snap_discard_ns_DEPENDENCIES) snap-discard-ns/$(am__dirstamp)
   497  	@rm -f snap-discard-ns/snap-discard-ns$(EXEEXT)
   498  	$(AM_V_CCLD)$(snap_discard_ns_snap_discard_ns_LINK) $(snap_discard_ns_snap_discard_ns_OBJECTS) $(snap_discard_ns_snap_discard_ns_LDADD) $(LIBS)
   499  
   500  snap-discard-ns/snap-discard-ns$(EXEEXT): LIBS += -Wl,-Bstatic $(snap_discard_ns_snap_discard_ns_STATIC) -Wl,-Bdynamic -pthread
   501  
   502  ##
   503  ## system-shutdown
   504  ##
   505  
   506  libexec_PROGRAMS += system-shutdown/system-shutdown
   507  
   508  system_shutdown_system_shutdown_SOURCES = \
   509  	system-shutdown/system-shutdown-utils.c \
   510  	system-shutdown/system-shutdown-utils.h \
   511  	system-shutdown/system-shutdown.c
   512  system_shutdown_system_shutdown_LDADD = libsnap-confine-private.a
   513  system_shutdown_system_shutdown_CFLAGS = $(CHECK_CFLAGS) $(filter-out -fPIE -pie,$(CFLAGS)) -static
   514  system_shutdown_system_shutdown_LDFLAGS = $(filter-out -fPIE -pie,$(LDFLAGS)) -static
   515  
   516  if WITH_UNIT_TESTS
   517  noinst_PROGRAMS += system-shutdown/unit-tests
   518  system_shutdown_unit_tests_SOURCES = \
   519  	libsnap-confine-private/unit-tests-main.c \
   520  	libsnap-confine-private/unit-tests.c \
   521  	system-shutdown/system-shutdown-utils-test.c
   522  system_shutdown_unit_tests_LDADD = libsnap-confine-private.a
   523  system_shutdown_unit_tests_CFLAGS = $(GLIB_CFLAGS)
   524  system_shutdown_unit_tests_LDADD +=  $(GLIB_LIBS)
   525  endif
   526  
   527  ##
   528  ## snap-gdb-shim
   529  ##
   530  
   531  libexec_PROGRAMS += snap-gdb-shim/snap-gdb-shim
   532  
   533  snap_gdb_shim_snap_gdb_shim_SOURCES = \
   534  	snap-gdb-shim/snap-gdb-shim.c
   535  
   536  snap_gdb_shim_snap_gdb_shim_LDADD = libsnap-confine-private.a
   537  snap_gdb_shim_snap_gdb_shim_LDFLAGS = -static
   538  
   539  ##
   540  ## snap-gdbserver-shim
   541  ##
   542  
   543  libexec_PROGRAMS += snap-gdb-shim/snap-gdbserver-shim
   544  
   545  snap_gdb_shim_snap_gdbserver_shim_SOURCES = \
   546  	snap-gdb-shim/snap-gdbserver-shim.c
   547  
   548  snap_gdb_shim_snap_gdbserver_shim_LDADD = libsnap-confine-private.a
   549  snap_gdb_shim_snap_gdbserver_shim_LDFLAGS = -static
   550  
   551  ##
   552  ## snapd-generator
   553  ##
   554  
   555  systemdsystemgeneratordir = $(SYSTEMD_SYSTEM_GENERATOR_DIR)
   556  systemdsystemgenerator_PROGRAMS = snapd-generator/snapd-generator
   557  
   558  snapd_generator_snapd_generator_SOURCES = snapd-generator/main.c
   559  snapd_generator_snapd_generator_LDADD = libsnap-confine-private.a
   560  
   561  ##
   562  ## snapd-env-generator
   563  ##
   564  
   565  systemdsystemenvgeneratordir=$(SYSTEMD_SYSTEM_ENV_GENERATOR_DIR)
   566  systemdsystemenvgenerator_PROGRAMS = snapd-env-generator/snapd-env-generator
   567  
   568  snapd_env_generator_snapd_env_generator_SOURCES = snapd-env-generator/main.c
   569  snapd_env_generator_snapd_env_generator_LDADD = libsnap-confine-private.a
   570  EXTRA_DIST += snapd-env-generator/snapd-env-generator.rst
   571  
   572  if HAVE_RST2MAN
   573  dist_man_MANS += snapd-env-generator/snapd-env-generator.8
   574  CLEANFILES += snapd-env-generator/snapd-env-generator.8
   575  endif
   576  
   577  install-exec-local::
   578  	install -d -m 755 $(DESTDIR)$(libexecdir)