[go: up one dir, main page]

File: Makefile

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (53 lines) | stat: -rw-r--r-- 1,877 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
TEST_CFLAGS  += -g -include $(srcdir)/tests/unittest.h -Wno-sign-compare

UNIT_TEST_SRC := $(srcdir)/uftrace.c
UNIT_TEST_SRC += $(wildcard $(srcdir)/cmds/*.c)
UNIT_TEST_SRC += $(wildcard $(srcdir)/utils/*.c)
UNIT_TEST_SRC += $(wildcard $(srcdir)/arch/$(ARCH)/*.c)
UNIT_TEST_SRC += $(wildcard $(srcdir)/libmcount/*.c)
UNIT_TEST_OBJ := $(patsubst $(srcdir)/%.c,$(objdir)/%.ot,$(UNIT_TEST_SRC))
UNIT_TEST_OBJ := $(filter-out %-nop.ot,$(UNIT_TEST_OBJ))

UNIT_TEST_HDR := $(srcdir)/uftrace.h
UNIT_TEST_HDR += $(srcdir)/tests/unittest.h
UNIT_TEST_HDR += $(wildcard $(srcdir)/utils/*.h)
UNIT_TEST_HDR += $(wildcard $(srcdir)/arch/$(ARCH)/*.h)
UNIT_TEST_HDR += $(wildcard $(srcdir)/libmcount/*.h)

UNIT_TEST_OBJ_VERSION := $(objdir)/cmds/script.ot $(objdir)/cmds/tui.ot
UNIT_TEST_OBJ_VERSION += $(objdir)/cmds/dump.ot   $(objdir)/cmds/info.ot
UNIT_TEST_OBJ_VERSION += $(objdir)/libmcount/mcount.ot

FULL_WORKER := -j $(shell getconf _NPROCESSORS_ONLN || echo 1)

# these needs to be recursively expanded
JOPT = $(filter -j%, $(MAKEFLAGS))
WORKER = $(if $(JOPT), $(if $(patsubst -j%,%,$(JOPT)), $(JOPT), $(FULL_WORKER)), -j1)

include $(srcdir)/Makefile.include

test: test_all

test_all: unittest
	$(QUIET_TEST)./unittest $(TESTARG) $(UNITTESTARG)
	$(QUIET_TEST)./runtest.py $(WORKER) $(TESTARG) $(RUNTESTARG)

test_run:
	$(QUIET_TEST)./runtest.py $(WORKER) $(TESTARG) $(RUNTESTARG)

test_unit: unittest
	$(QUIET_TEST)./unittest $(TESTARG) $(UNITTESTARG)

unittest: unittest.c unittest.h $(UNIT_TEST_OBJ)
	$(QUIET_LINK)$(CC) -o $@ $(TEST_CFLAGS) $< $(UNIT_TEST_OBJ) $(TEST_LDFLAGS)

$(UNIT_TEST_OBJ_VERSION): $(objdir)/version.h

$(UNIT_TEST_OBJ): $(objdir)/%.ot: $(srcdir)/%.c $(objdir)/.config $(UNIT_TEST_HDR)
	$(QUIET_CC)$(CC) -o $@ -c $(TEST_CFLAGS) $<

clean:
	$(call QUIET_CLEAN, test)
	@rm -f *.o *.so *.pyc t-* unittest $(UNIT_TEST_OBJ)

.PHONY: clean test test_run test_unit