1project('test static link libs', 'c')
2
3pkg = import('pkgconfig')
4
5# libfunc2 should contain both func1() and func2() symbols
6libfunc1 = static_library('func1', 'func1.c',
7  install : false)
8libfunc2 = static_library('func2', 'func2.c',
9  link_whole : libfunc1,
10  install : true)
11
12# Same as above, but with link_with instead of link_whole,
13# libfunc4 should contain both func3() and func4() symbols
14libfunc3 = static_library('func3', 'func3.c',
15  install : false)
16libfunc4 = static_library('func4', 'func4.c',
17  link_with : libfunc3,
18  install : true)
19
20# Same as above, but also generate an pkg-config file. Use both_libraries() to
21# make sure a complete .pc file gets generated. libfunc5 should not be mentioned
22# into the .pc file because it's not installed.
23libfunc5 = static_library('func5', 'func5.c',
24  install : false)
25libfunc6 = both_libraries('func6', 'func6.c',
26  link_with : libfunc5,
27  install : true)
28pkg.generate(libfunc6)
29
30# libfunc9 should contain both func8() and func9() but not func7() because that
31# one gets installed. Also test that link_with and link_whole works the same way
32# because libfunc8 is uninstalled.
33libfunc7 = static_library('func7', 'func7.c',
34  install : true)
35libfunc8 = static_library('func8', 'func8.c',
36  link_with : libfunc7,
37  install : false)
38libfunc9_linkwith = static_library('func9_linkwith', 'func9.c',
39  link_with : libfunc8,
40  install : true)
41libfunc9_linkwhole = static_library('func9_linkwhole', 'func9.c',
42  link_whole : libfunc8,
43  install : true)
44
45# Pattern found in mesa:
46# - libfunc11 uses func10()
47# - libfunc12 uses both func10() and func11()
48# When a shared library link_whole on libfunc12, we ensure we don't include
49# func10.c.o twice which would fail to link.
50libfunc10 = static_library('func10', 'func10.c',
51  install : false)
52libfunc11 = static_library('func11', 'func11.c',
53  link_with : libfunc10,
54  install : false)
55libfunc12 = static_library('func12', 'func12.c',
56  link_with : [libfunc10, libfunc11],
57  install : false)
58libfunc13 = shared_library('func13', link_whole : libfunc12)
59
60# libfunc16 should contain func14(), func15() and func16()
61libfunc14 = static_library('func14', 'func14.c',
62  install : false)
63libfunc15 = static_library('func15', 'func15.c',
64  link_with : libfunc14,
65  install : false)
66libfunc16 = static_library('func16', 'func16.c',
67  link_with : libfunc15,
68  install : true)
69
70# Verify func17.c.o gets included only once into libfunc19, otherwise
71# func19-shared would failed with duplicated symbol.
72libfunc17 = static_library('func17', 'func17.c',
73  install : false)
74libfunc18 = static_library('func18', 'func18.c',
75  link_with : libfunc17,
76  install : false)
77libfunc19 = static_library('func19', 'func19.c',
78  link_whole : [libfunc17, libfunc18],
79  install : false)
80shared_library('func19-shared', link_whole : [libfunc19])
81