2 # Follow the kernel version
3 VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion)
6 # Makefiles suck: This macro sets a default value of $(2) for the
7 # variable named by $(1), unless the variable has been set by
8 # environment or command line. This is necessary for CC and AR
9 # because make sets default values, so the simpler ?= approach
10 # won't work as expected.
12 $(if $(or $(findstring environment,$(origin $(1))),\
13 $(findstring command line,$(origin $(1)))),,\
17 # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
18 $(call allow-override,CC,$(CROSS_COMPILE)gcc)
19 $(call allow-override,AR,$(CROSS_COMPILE)ar)
20 $(call allow-override,STRIP,$(CROSS_COMPILE)strip)
21 $(call allow-override,PKG_CONFIG,pkg-config)
22 $(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
23 $(call allow-override,LDCONFIG,ldconfig)
26 FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
27 -fasynchronous-unwind-tables -fstack-clash-protection
28 WOPTS := -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
30 TRACEFS_HEADERS := $$($(PKG_CONFIG) --cflags libtracefs)
32 CFLAGS := -O -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(TRACEFS_HEADERS)
34 LIBS := $$($(PKG_CONFIG) --libs libtracefs) -lprocps
36 SRC := $(wildcard src/*.c)
37 HDR := $(wildcard src/*.h)
40 FILES := Makefile README.txt
42 TARBALL := $(NAME)-$(VERSION).tar.$(CEXT)
43 TAROPTS := -cvjf $(TARBALL)
46 DOCDIR := $(DATADIR)/doc
47 MANDIR := $(DATADIR)/man
48 LICDIR := $(DATADIR)/licenses
49 SRCTREE := $(or $(BUILD_SRC),$(CURDIR))
51 # If running from the tarball, man pages are stored in the Documentation
52 # dir. If running from the kernel source, man pages are stored in
53 # Documentation/tools/rtla/.
54 ifneq ($(wildcard Documentation/.*),)
55 DOCSRC = Documentation/
57 DOCSRC = $(SRCTREE)/../../../Documentation/tools/rtla/
64 $(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)
67 $(CC) -o rtla-static $(LDFLAGS) --static $(OBJ) $(LIBS) -lpthread -ldl
71 $(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
72 $(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR)
73 $(STRIP) $(DESTDIR)$(BINDIR)/rtla
74 @test ! -f $(DESTDIR)$(BINDIR)/osnoise || rm $(DESTDIR)$(BINDIR)/osnoise
75 ln -s $(DESTDIR)$(BINDIR)/rtla $(DESTDIR)$(BINDIR)/osnoise
76 @test ! -f $(DESTDIR)$(BINDIR)/timerlat || rm $(DESTDIR)$(BINDIR)/timerlat
77 ln -s $(DESTDIR)$(BINDIR)/rtla $(DESTDIR)$(BINDIR)/timerlat
81 @test ! -f rtla || rm rtla
82 @test ! -f rtla-static || rm rtla-static
83 @test ! -f src/rtla.o || rm src/rtla.o
84 @test ! -f $(TARBALL) || rm -f $(TARBALL)
85 @rm -rf *~ $(OBJ) *.tar.$(CEXT)
88 rm -rf $(NAME)-$(VERSION) && mkdir $(NAME)-$(VERSION)
89 echo $(VERSION) > $(NAME)-$(VERSION)/VERSION
90 cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION)
91 mkdir $(NAME)-$(VERSION)/Documentation/
92 cp -rp $(SRCTREE)/../../../Documentation/tools/rtla/* $(NAME)-$(VERSION)/Documentation/
93 tar $(TAROPTS) --exclude='*~' $(NAME)-$(VERSION)
94 rm -rf $(NAME)-$(VERSION)
96 .PHONY: doc doc_clean doc_install
101 $(MAKE) -C $(DOCSRC) clean
104 $(MAKE) -C $(DOCSRC) install