File: Makefile

package info (click to toggle)
libtree 3.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 288 kB
  • sloc: ansic: 1,412; makefile: 202
file content (39 lines) | stat: -rw-r--r-- 1,372 bytes parent folder | download | duplicates (3)
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
LD_LIBRARY_PATH=

# test whether RUNPATH < LD_LIBRARY_PATH < RPATH
# the exe's both need libb.so, but there are two of those:
# ./dir/libb.so needs liba.so
# ./libb.so needs nothing.

.PHONY: clean

all: check

dir:
	mkdir $@

dir/liba.so: dir
	echo 'int a(){return 42;}' | $(CC) -shared -Wl,-soname,$(@F) -Wl,--no-as-needed -o $@ -nostdlib -x c -

dir/libb.so: dir/liba.so
	echo 'int b(){return a();}' | $(CC) -shared -Wl,-soname,$(@F) -Wl,--no-as-needed -Wl,--disable-new-dtags '-Wl,-rpath,$$ORIGIN' -Wno-implicit-function-declaration -o $@ -nostdlib dir/liba.so -x c -

libb.so:
	echo 'int b(){return 10;}' | $(CC) -shared -Wl,-soname,$(@F) -Wl,--no-as-needed -o $@ -Wno-implicit-function-declaration -nostdlib -x c -

exe_rpath: libb.so
	echo 'int _start(){return b();}' | $(CC) -Wl,--no-as-needed -Wl,--disable-new-dtags "-Wl,-rpath,$(CURDIR)" libb.so -o $@ -Wno-implicit-function-declaration -nostdlib -x c -

exe_runpath: libb.so
	echo 'int _start(){return b();}' | $(CC) -Wl,--no-as-needed -Wl,--enable-new-dtags "-Wl,-rpath,$(CURDIR)" libb.so -o $@ -Wno-implicit-function-declaration -nostdlib -x c -

check: exe_rpath exe_runpath dir/libb.so
	../../libtree exe_rpath
	LD_LIBRARY_PATH="$(CURDIR)/dir" ../../libtree exe_rpath
	../../libtree exe_runpath
	LD_LIBRARY_PATH="$(CURDIR)/dir" ../../libtree exe_runpath

clean:
	rm -rf *.so dir exe*

CURDIR ?= $(.CURDIR)