Lines of
Makefile
from check-in b502b175ea
that are changed by the sequence of edits moving toward
check-in 997a035b20:
1: TCLSH_NATIVE := tclsh
2: TCL_CONFIG_SH_DIR := $(shell echo 'puts [tcl::pkgconfig get libdir,runtime]' | $(TCLSH_NATIVE))
3: TCL_CONFIG_SH := $(TCL_CONFIG_SH_DIR)/tclConfig.sh
4: XVFS_ROOT_MOUNTPOINT := //xvfs:/
5: CPPFLAGS := -DXVFS_ROOT_MOUNTPOINT='"$(XVFS_ROOT_MOUNTPOINT)"' -I. -DUSE_TCL_STUBS=1 -DXVFS_DEBUG $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_INCLUDE_SPEC}") $(XVFS_ADD_CPPFLAGS)
6: CFLAGS := -fPIC -g3 -ggdb3 -Wall $(XVFS_ADD_CFLAGS)
7: LDFLAGS := $(XVFS_ADD_LDFLAGS)
8: LIBS := $(XVFS_ADD_LIBS)
9: TCL_LIB := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_LIB_SPEC}")
10: TCL_STUB_LIB := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_STUB_LIB_SPEC}")
11: TCLSH := tclsh
12: LIB_SUFFIX := $(shell . "${TCL_CONFIG_SH}"; echo "$${TCL_SHLIB_SUFFIX:-.so}")
13:
14: all: example-standalone$(LIB_SUFFIX) example-client$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) xvfs$(LIB_SUFFIX)
15:
16: example.c: $(shell find example -type f) $(shell find lib -type f) lib/xvfs/xvfs.c.rvt xvfs-create-c xvfs-create Makefile
17: rm -f example.c.new.1 example.c.new.2
18: ./xvfs-create-c --directory example --name example > example.c.new.1
19: ./xvfs-create --directory example --name example > example.c.new.2
20: bash -c "diff -u <(grep -v '^ *$$' example.c.new.1) <(grep -v '^ *$$' example.c.new.2)" || :
21: rm -f example.c.new.2
22: mv example.c.new.1 example.c
23:
24: example-standalone.o: example.c xvfs-core.h xvfs-core.c Makefile
25: $(CC) $(CPPFLAGS) -DXVFS_MODE_STANDALONE $(CFLAGS) -o example-standalone.o -c example.c
26:
27: example-standalone$(LIB_SUFFIX): example-standalone.o Makefile
28: $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-standalone$(LIB_SUFFIX) example-standalone.o $(LIBS) $(TCL_STUB_LIB)
29:
30: example-client.o: example.c xvfs-core.h Makefile
31: $(CC) $(CPPFLAGS) -DXVFS_MODE_CLIENT $(CFLAGS) -o example-client.o -c example.c
32:
33: example-client$(LIB_SUFFIX): example-client.o Makefile
34: $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-client$(LIB_SUFFIX) example-client.o $(LIBS) $(TCL_STUB_LIB)
35:
36: example-flexible.o: example.c xvfs-core.h xvfs-core.c Makefile
37: $(CC) $(CPPFLAGS) -DXVFS_MODE_FLEXIBLE $(CFLAGS) -o example-flexible.o -c example.c
38:
39: example-flexible$(LIB_SUFFIX): example-flexible.o Makefile
40: $(CC) $(CFLAGS) $(LDFLAGS) -shared -o example-flexible$(LIB_SUFFIX) example-flexible.o $(LIBS) $(TCL_STUB_LIB)
41:
42: xvfs.o: xvfs-core.h xvfs-core.c Makefile
43: $(CC) $(CPPFLAGS) -DXVFS_MODE_SERVER $(CFLAGS) -o xvfs.o -c xvfs-core.c
44:
45: xvfs$(LIB_SUFFIX): xvfs.o Makefile
46: $(CC) $(CFLAGS) $(LDFLAGS) -shared -o xvfs$(LIB_SUFFIX) xvfs.o $(LIBS) $(TCL_STUB_LIB)
47:
48: # xvfs-create-standalone is a standalone (i.e., no external dependencies
49: # like lib/minirivet, xvfs-core.c, etc) version of "xvfs-create"
50: xvfs-create-standalone: $(shell find lib -type f) xvfs-create xvfs-core.c xvfs-core.h lib/xvfs/xvfs.c.rvt Makefile
51: rm -f xvfs-create-standalone.new xvfs-create-standalone
52: ./xvfs-create --dump-tcl --remove-debug > xvfs-create-standalone.new
53: chmod +x xvfs-create-standalone.new
54: mv xvfs-create-standalone.new xvfs-create-standalone
55:
56: xvfs-create-c: xvfs-create-c.o
57: $(CC) $(CFLAGS) $(LDFLAGS) -o xvfs-create-c xvfs-create-c.o $(LIBS)
58:
59: xvfs-create-c.o: xvfs-create-c.c
60: $(CC) $(CPPFLAGS) $(CFLAGS) -o xvfs-create-c.o -c xvfs-create-c.c
61:
62: xvfs_random$(LIB_SUFFIX): $(shell find example -type f) $(shell find lib -type f) lib/xvfs/xvfs.c.rvt xvfs-create-random Makefile
63: ./xvfs-create-random | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DXVFS_MODE_FLEXIBLE -x c - -shared -o xvfs_random$(LIB_SUFFIX) $(LIBS)
64:
65: xvfs_synthetic$(LIB_SUFFIX): $(shell find lib -type f) lib/xvfs/xvfs.c.rvt xvfs-create-synthetic Makefile
66: ./xvfs-create-synthetic | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DXVFS_MODE_FLEXIBLE -x c - -shared -o xvfs_synthetic$(LIB_SUFFIX) $(LIBS)
67:
68: do-benchmark:
69: $(MAKE) clean all XVFS_ADD_CPPFLAGS="-UXVFS_DEBUG" XVFS_ADD_CFLAGS="-g0 -ggdb0 -s -O3"
70: ./benchmark.tcl
71:
72: test: example-standalone$(LIB_SUFFIX) xvfs$(LIB_SUFFIX) example-client$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) Makefile
73: rm -f __test__.tcl
74: echo 'if {[catch { eval $$::env(XVFS_TEST_LOAD_COMMANDS); source $(XVFS_ROOT_MOUNTPOINT)example/main.tcl }]} { puts stderr $$::errorInfo; exit 1 }; exit 0' > __test__.tcl
75: @export XVFS_ROOT_MOUNTPOINT; export XVFS_TEST_LOAD_COMMANDS; for XVFS_TEST_LOAD_COMMANDS in \
76: 'load ./example-standalone$(LIB_SUFFIX) Xvfs_example' \
77: 'load -global ./xvfs$(LIB_SUFFIX); load ./example-client$(LIB_SUFFIX) Xvfs_example' \
78: 'load ./xvfs$(LIB_SUFFIX); load ./example-flexible$(LIB_SUFFIX) Xvfs_example' \
b502b175ea 2020-04-13 79: 'load ./example-flexible$(LIB_SUFFIX) Xvfs_example'; do \
80: echo "[$${XVFS_TEST_LOAD_COMMANDS}] $(GDB) $(TCLSH) __test__.tcl $(TCL_TEST_ARGS)"; \
81: $(GDB) $(TCLSH) __test__.tcl $(TCL_TEST_ARGS) || exit 1; \
82: done
83: rm -f __test__.tcl
84:
85: do-test: test
86:
87: do-coverage:
88: $(MAKE) clean
89: $(MAKE) XVFS_ADD_CFLAGS=-coverage XVFS_ADD_LDFLAGS=-coverage
90: $(MAKE) test XVFS_TEST_EXIT_ON_FAILURE=0
91: rm -f xvfs-test-coverage.info
92: lcov --capture --directory . --output-file xvfs-test-coverage.info
93: rm -rf xvfs-test-coverage
94: mkdir xvfs-test-coverage
95: genhtml xvfs-test-coverage.info --output-directory xvfs-test-coverage
96: rm -f xvfs-test-coverage.info
97:
98: profile-bare: profile.c example.c xvfs-core.h xvfs-core.c Makefile
99: $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -UUSE_TCL_STUBS -o profile-bare profile.c -ltcl
100:
101: profile-gperf: profile.c example.c xvfs-core.h xvfs-core.c Makefile
102: $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -pg -UUSE_TCL_STUBS -o profile-gperf profile.c -ltcl
103:
104: do-profile: profile-bare profile-gperf Makefile
105: rm -rf oprofile_data
106: rm -f gmon.out callgrind.out
107: operf ./profile-bare
108: opreport
109: ./profile-gperf
110: gprof ./profile-gperf
111: valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./profile-bare 10 2
112: callgrind_annotate callgrind.out
113:
114: do-valgrind: Makefile
115: $(MAKE) test XVFS_TEST_EXIT_ON_FAILURE=0 GDB='valgrind --tool=memcheck --track-origins=yes --leak-check=full'
116:
117: tclsh-local: tclsh-local.c
118: $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -UUSE_TCL_STUBS -o tclsh-local tclsh-local.c $(LIBS) $(TCL_LIB)
119:
120: do-asan: Makefile
121: rm -f tclsh-local
122: $(MAKE) tclsh-local test XVFS_TEST_EXIT_ON_FAILURE=0 CC='clang -fsanitize=address,undefined,leak' XVFS_ADD_CFLAGS='-Wno-string-plus-int' TCLSH=./tclsh-local
123:
124: do-msan: Makefile
125: rm -f tclsh-local
126: $(MAKE) tclsh-local test XVFS_TEST_EXIT_ON_FAILURE=0 CC='clang -fsanitize=memory' XVFS_ADD_CFLAGS='-Wno-string-plus-int' TCLSH=./tclsh-local
127:
128: clean:
129: rm -f xvfs-create-standalone.new xvfs-create-standalone
130: rm -f xvfs-create-c.o xvfs-create-c
131: rm -f example.c example.c.new example.c.new.1 example.c.new.2
132: rm -f example-standalone$(LIB_SUFFIX) example-standalone.o
133: rm -f example-client.o example-client$(LIB_SUFFIX)
134: rm -f example-flexible.o example-flexible$(LIB_SUFFIX)
135: rm -f xvfs.o xvfs$(LIB_SUFFIX)
136: rm -f example-standalone.gcda example-standalone.gcno
137: rm -f example-client.gcda example-client.gcno
138: rm -f example-flexible.gcda example-flexible.gcno
139: rm -f xvfs-create-c.gcda xvfs-create-c.gcno
140: rm -f xvfs_random$(LIB_SUFFIX) xvfs_synthetic$(LIB_SUFFIX)
141: rm -f xvfs.gcda xvfs.gcno
142: rm -f __test__.tcl
143: rm -f profile-bare profile-gperf
144: rm -f gmon.out
145: rm -f callgrind.out
146: rm -rf oprofile_data
147: rm -f xvfs-test-coverage.info
148: rm -rf xvfs-test-coverage
149: rm -f tclsh-local
150:
151: distclean: clean
152:
153: .PHONY: all clean distclean test do-test do-coverage do-benchmark do-profile do-valgrind do-asan do-msan