xref: /linux/tools/tracing/rtla/Makefile.rtla (revision dbcedec3a31119d7594baacc743300d127c99c56)
1# SPDX-License-Identifier: GPL-2.0-only
2
3define allow-override
4  $(if $(or $(findstring environment,$(origin $(1))),\
5            $(findstring command line,$(origin $(1)))),,\
6    $(eval $(1) = $(2)))
7endef
8
9# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
10$(call allow-override,CC,$(CROSS_COMPILE)gcc)
11$(call allow-override,AR,$(CROSS_COMPILE)ar)
12$(call allow-override,STRIP,$(CROSS_COMPILE)strip)
13$(call allow-override,PKG_CONFIG,pkg-config)
14$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
15$(call allow-override,LDCONFIG,ldconfig)
16export CC AR STRIP PKG_CONFIG LD_SO_CONF_PATH LDCONFIG
17
18FOPTS		:= -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong	\
19		-fasynchronous-unwind-tables -fstack-clash-protection
20WOPTS		:= -O -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2		\
21		-Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
22
23ifeq ($(CC),clang)
24  FOPTS		:= $(filter-out -flto=auto -ffat-lto-objects, $(FOPTS))
25  WOPTS		:= $(filter-out -Wno-maybe-uninitialized, $(WOPTS))
26endif
27
28CFLAGS		:= -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(WOPTS) $(CFLAGS)
29LDFLAGS		:= -ggdb $(LDFLAGS)
30
31RM		:= rm -rf
32LN		:= ln -s
33INSTALL		:= install
34MKDIR		:= mkdir
35STRIP		:= strip
36BINDIR		:= /usr/bin
37
38.PHONY: install
39install: doc_install
40	@$(MKDIR) -p $(DESTDIR)$(BINDIR)
41	$(call QUIET_INSTALL,rtla)$(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR)
42	@$(STRIP) $(DESTDIR)$(BINDIR)/rtla
43	@test ! -f $(DESTDIR)$(BINDIR)/osnoise || $(RM) $(DESTDIR)$(BINDIR)/osnoise
44	@$(LN) rtla $(DESTDIR)$(BINDIR)/osnoise
45	@test ! -f $(DESTDIR)$(BINDIR)/hwnoise || $(RM) $(DESTDIR)$(BINDIR)/hwnoise
46	@$(LN) -s rtla $(DESTDIR)$(BINDIR)/hwnoise
47	@test ! -f $(DESTDIR)$(BINDIR)/timerlat || $(RM) $(DESTDIR)$(BINDIR)/timerlat
48	@$(LN) -s rtla $(DESTDIR)$(BINDIR)/timerlat
49
50.PHONY: doc doc_clean doc_install
51doc:
52	$(MAKE) -C $(DOCSRC)
53
54doc_clean:
55	$(MAKE) -C $(DOCSRC) clean
56
57doc_install:
58	$(MAKE) -C $(DOCSRC) install
59
60# This section is neesary for the tarball, when the tarball
61# support is removed, we can delete these entries.
62NAME		:= rtla
63DIRS		:= src
64FILES		:= Makefile README.txt
65CEXT		:= bz2
66TARBALL		:= $(NAME)-$(VERSION).tar.$(CEXT)
67TAROPTS		:= -cvjf $(TARBALL)
68SRCTREE		:=	$(or $(BUILD_SRC),$(CURDIR))
69
70tarball: clean
71	$(RM) $(NAME)-$(VERSION) && $(MKDIR) $(NAME)-$(VERSION)
72	echo $(VERSION) > $(NAME)-$(VERSION)/VERSION
73	cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION)
74	$(MKDIR) $(NAME)-$(VERSION)/Documentation/
75	cp -rp $(SRCTREE)/../../../Documentation/tools/$(NAME)/* $(NAME)-$(VERSION)/Documentation/
76	cp Makefile.standalone $(NAME)-$(VERSION)/Makefile
77	cp Makefile.$(NAME) $(NAME)-$(VERSION)/
78	tar $(TAROPTS) --exclude='*~' $(NAME)-$(VERSION)
79	$(RM) $(NAME)-$(VERSION)
80.PHONY: tarball
81