File: GNUmakefile

package info (click to toggle)
dtrace 2.0.5-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 24,408 kB
  • sloc: ansic: 61,247; sh: 17,997; asm: 1,717; lex: 947; awk: 754; yacc: 695; perl: 37; sed: 17; makefile: 15
file content (181 lines) | stat: -rw-r--r-- 5,807 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Top-level makefile for dtrace.
#
# Build files in subdirectories are included by this file.
#
# Oracle Linux DTrace.
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

.DELETE_ON_ERROR:
.SUFFIXES:
.SECONDEXPANSION:

SHELL = /bin/bash

PROJECT := dtrace
VERSION := $(shell ./libdtrace/mkvers -vcurrent=t libdtrace/versions.list)

# Verify supported hardware.

ARCH := $(shell uname -m)

$(if $(subst sparc64,,$(subst aarch64,,$(subst x86_64,,$(ARCH)))), \
    $(error "Error: DTrace for Linux only supports x86_64, ARM64 and sparc64"),)
$(if $(subst Linux,,$(shell uname -s)), \
    $(error "Error: DTrace only supports Linux"),)

# Variables overridable by the command line and configure scripts.

CFLAGS ?= -O2 -Wall -pedantic -Wno-unknown-pragmas
LDFLAGS ?=

# The first non-system uid on this system.
USER_UID := $(shell grep '^UID_MIN' /etc/login.defs | awk '{print $$2;}')

# A uid suitable for unprivileged execution.
UNPRIV_UID ?= -3

# The group one must run as to invoke dumpcap: by default the group of
# the dumpcap binary.  If dumpcap is owned by root, use the same gid as
# the UNPRIV_UID unless otherwise overridden.
# (We avoid ?= here to avoid rerunning the stat over and over again.)
ifeq ($(origin DUMPCAP_GROUP), undefined)
DUMPCAP_GROUP := $(filter-out root,$(shell stat -c %G /usr/sbin/dumpcap /usr/bin/dumpcap 2>/dev/null | head -1))
endif

# Unwritable but readable directory suitable for overriding as the $HOME of
# unprivileged processes.
UNPRIV_HOME ?= /run/initramfs

# The substitution process in libdtrace needs kernel build trees for every
# kernel this userspace will be used with.  It only needs to know about major
# versions because to a first approximation the kernel-header-file #defines and
# data structures needed in translators do not change on a finer grain than
# that.  It also needs to know the name of the kernel architecture (as used in
# pathnames), and about the pieces of the pathname before and after the kernel
# version (so it can build include paths).

# Headers for installed kernels should be found automatically by the build
# logic.  For local builds, one should specify KERNELSRCDIR as the source
# location of the kernel tree, and KERNELOBJDIR as the location of the object
# tree.  If the kernel was built within the source tree, KERNELOBJDIR need not
# be specified.

# For RPM builds, set KERNELMODDIR to the root of the rpmsrc tree, and set
# KERNELSRCNAME and KERNELBLDNAME to the empty string.

KERNELS ?= $(shell uname -r)
KERNELMODDIR ?= /lib/modules
KERNELSRCNAME ?= source
KERNELBLDNAME ?= build

ifdef KERNELSRCDIR
KERNELOBJDIR ?= $(KERNELSRCDIR)
endif

KERNELARCH := $(subst sparc64,sparc,$(subst aarch64,arm64,$(subst x86_64,x86,$(ARCH))))

# Paths.

prefix ?= /usr
export objdir := $(abspath build)
LIBDIR = $(prefix)/lib$(BITNESS)
INSTLIBDIR = $(DESTDIR)$(LIBDIR)
INCLUDEDIR = $(prefix)/include
INSTINCLUDEDIR = $(DESTDIR)$(INCLUDEDIR)
SDTINCLUDEDIR = $(LIBDIR)/dtrace/include
INSTSDTINCLUDEDIR = $(DESTDIR)$(SDTINCLUDEDIR)
SBINDIR = $(prefix)/sbin
INSTSBINDIR = $(DESTDIR)$(SBINDIR)
UDEVDIR = $(prefix)/lib/udev/rules.d
INSTUDEVDIR = $(DESTDIR)$(UDEVDIR)
SYSTEMDPRESETDIR = $(prefix)/lib/systemd/system-preset
SYSTEMDUNITDIR = $(prefix)/lib/systemd/system
INSTSYSTEMDPRESETDIR = $(DESTDIR)$(SYSTEMDPRESETDIR)
INSTSYSTEMDUNITDIR = $(DESTDIR)$(SYSTEMDUNITDIR)
DOCDIR = $(prefix)/share/doc/dtrace-$(VERSION)
INSTDOCDIR = $(DESTDIR)$(DOCDIR)
MANDIR = $(prefix)/share/man
INSTMANDIR = $(DESTDIR)$(MANDIR)
PKGCONFIGDIR = $(prefix)/share/pkgconfig
INSTPKGCONFIGDIR = $(DESTDIR)$(PKGCONFIGDIR)
TESTDIR = $(LIBDIR)/dtrace/testsuite
INSTTESTDIR = $(DESTDIR)$(TESTDIR)
WITH_SYSTEMD = y
TARGETS =

DTRACE ?= $(objdir)/dtrace

# configure overrides (themselves overridden by explicit command-line options).

-include $(objdir)/config-vars.mk

# Variables derived from the above.

export CC ?= gcc

BITNESS := 64
NATIVE_BITNESS_ONLY := $(shell echo 'int main (void) { }' | $(CC) -x c -o /dev/null -m32 - 2>/dev/null || echo t)
ARCHINC := $(subst sparc64,sparc,$(subst aarch64,arm64,$(subst x86_64,i386,$(ARCH))))

INVARIANT_CFLAGS := -std=gnu99 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(if $(NATIVE_BITNESS_ONLY),-DNATIVE_BITNESS_ONLY) -D_DT_VERSION=\"$(VERSION)\"
CPPFLAGS += -Iinclude -Iuts/common -Iinclude/$(ARCHINC) -I$(objdir)

override CFLAGS += $(INVARIANT_CFLAGS)
PREPROCESS = $(CC) -E
export BPFC ?= bpf-unknown-none-gcc

BPFCPPFLAGS += -D$(subst sparc64,__sparc,$(subst aarch64,__aarch64__,$(subst x86_64,__amd64,$(ARCH))))
BPFCFLAGS ?= -O2 -Wall -Wno-unknown-pragmas $(if $(HAVE_BPFV3),-mcpu=v3) $(if $(HAVE_BPFMASM),-masm=normal) -ffreestanding
export BPFLD ?= bpf-unknown-none-ld

all::

# Include everything.

$(shell mkdir -p $(objdir))

include Makeoptions
include Makefunctions
include Makeconfig

# Building config.mk is quite expensive: avoid doing it when only
# documentation targets and such things are invoked.
ifeq ($(strip $(filter %clean help% dist tags TAGS gtags,$(MAKECMDGOALS))),)
-include $(objdir)/config.mk
endif
include Build $(sort $(wildcard */Build))
-include $(objdir)/*.deps
include Makerules
include Maketargets
include Makecheck

# Tarball distribution.

PHONIES += dist

.git/index:

.git-version.tmp:  .git/index
	if [[ -f .git/index ]]; then \
		git log --no-walk --pretty=format:%H > .git-version.tmp; \
	else \
		cp .git-archive-version .git-version.tmp; \
	fi

.git-version: .git-version.tmp
	if test -r "$@" && cmp -s "$@" "$^"; then \
		rm -f "$^"; \
	else \
		printf "VERSION: .git-version\n"; \
		mv -f "$^" "$@"; \
	fi

dist::
	git archive --prefix=dtrace-$(VERSION)/ HEAD | bzip2 > dtrace-$(VERSION).tar.bz2

clean::
	rm -f .git-version

.PHONY: $(PHONIES)