@@ -28,6 +28,8 @@ endef
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar)
$(call allow-override,PKG_CONFIG,pkg-config)
+$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
+$(call allow-override,LDCONFIG,ldconfig)
EXT = -std=gnu99
INSTALL = install
@@ -235,11 +237,35 @@ cscope: force
$(RM) cscope*
$(call find_tag_files) | cscope -b -q
+ifeq ("$(DESTDIR)", "")
+# If DESTDIR is not defined, then test if after installing the library
+# and running ldconfig, if the library is visible by ld.so.
+# If not, add the path to /etc/ld.so.conf.d/trace.conf and run ldconfig again.
+define install_ld_config
+ $(LDCONFIG); \
+ if ! grep "^$(libdir)$$" $(LD_SO_CONF_PATH)/* &> /dev/null ; then \
+ $(CC) -o $(OUTPUT)test $(srctree)/test.c -I $(includedir_SQ) \
+ -L $(libdir_SQ) -ltracefs; \
+ if ! $(OUTPUT)test > /dev/null; then \
+ echo $(libdir_SQ) >> $(LD_SO_CONF_PATH)/trace.conf; \
+ $(LDCONFIG); \
+ fi; \
+ echo $(RM) $(OUTPUT)test; \
+ fi
+endef
+else
+# If installing to a location for another machine or package, do not bother
+# with running ldconfig.
+define install_ld_config
+endef
+endif # DESTDIR = ""
+
install_libs: libs install_pkgconfig
$(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)); \
cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
$(Q)$(call do_install,$(src)/include/tracefs.h,$(includedir_SQ))
$(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ))
+ $(Q)$(call install_ld_config)
install: install_libs
new file mode 100644
@@ -0,0 +1,7 @@
+#include <tracefs.h>
+
+int main()
+{
+ tracefs_get_tracing_dir();
+ return 0;
+}