xref: /aosp_15_r20/external/ltp/INSTALL (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1Requirements
2------------
3
4Tools are needed for LTP compilation. They should be available as a
5package in any Linux distribution (no specific version is required).
6
7Debian / Ubuntu
8
9	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev
10
11openSUSE / SLES
12
13	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel
14
15Fedora / CentOS / RHEL
16
17	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers
18
19These are minimal build requirements for git compilation. Some tests require
20extra development files of some libraries, see ci/*.sh. There is also
21support for other Linux distributions not listed here.
22
23autoconf, automake, m4 (autoconf requirement), git and pkgconf (or pkg-config
24on older distros) are required only for compilation from git (used for creating
25configure file).
26
27pkgconf is recommended also for compilation from tarball as it
28does automatic detection of some library support.
29
30Configuration
31-------------
32
33Configuration requires autoconf:
34
35	$ cd $TOP_SRCDIR
36	$ make autotools
37	$ mkdir -p $TOP_BUILDDIR
38	$ cd $TOP_BUILDDIR && $TOP_SRCDIR/configure # configure args go here, e.g. CC=$CC, LDFLAGS=$LDFLAGS, etc
39
40- $TOP_SRCDIR and $TOP_BUILDDIR are the same for in-build-tree scenarios.
41- $TOP_SRCDIR and $TOP_BUILDDIR differ for out-of-build-tree scenarios.
42
43See the In-build-tree and Out-of-build-tree sections below for more details on
44what to do next.
45
46Compiling LTP
47-------------
48
49In-build-tree
50-------------
51
52In-build-tree support is when you build binaries (applications, binary objects)
53in the same directory where the source files reside.
54
55	$ make all
56	$ make \
57	  "DESTDIR=$SYSROOT" \
58	  SKIP_IDCHECK=[0|1] \
59	  install
60
61- Specifying DESTDIR is optional, but required when installing to a non-host
62  sysroot, as opposed to the host system's sysroot.
63- Specify SKIP_IDCHECK=1 if and when you don't want to modify /etc/{group,passwd}
64  on the target system's sysroot.
65
66If you get a build error, please report it to [email protected] with
67following information,
68
69 1. The error output before the failure.
70 2. If you used configure:
71	i.   include/config.h
72	ii.  include/mk/config.mk
73	iii. config.log
74
75Out-of-build-tree
76-----------------
77
78Out-of-build-tree support is when you build binaries (applications, binary
79objects, generated files) outside of the directory where the source files
80reside. This is typically used when cross-compiling for multiple targets.
81
82NOTE: This is by and large correctly implemented, but there are several corner
83cases, where this isn't implemented properly. Please see TODO for a list of
84items which need fixing in the LTP tree.
85
86	$ mkdir "$OUT_OF_BUILD_TREE_DIR"
87	$ make \
88	  -C "$OUT_OF_BUILD_TREE_DIR" \
89	  -f "$TOP_SRCDIR/Makefile" \
90	  "top_srcdir=$TOP_SRCDIR" \
91	  "top_builddir=$OUT_OF_BUILD_TREE_DIR"
92	$ make \
93	  -C "$OUT_OF_BUILD_TREE_DIR" \
94	  -f "$TOP_SRCDIR/Makefile" \
95	  "top_srcdir=$TOP_SRCDIR" \
96	  "top_builddir=$OUT_OF_BUILD_TREE_DIR" \
97	  "DESTDIR=$SYSROOT" \
98	  SKIP_IDCHECK=[0|1]
99	  install
100
101- Specifying DESTDIR is optional, but required when installing to a non-host
102  sysroot, as opposed to the host system's sysroot.
103- Specify SKIP_IDCHECK=1 if and when you don't want to modify /etc/{group,passwd}
104  on the target system's sysroot.
105
106Quick Start
107-----------
108
109	$ tar xzf ltp-XXXXXXXX.tar.gz
110	$ cd ltp
111	$ ./configure
112	$ make all
113	# make install
114	$ /opt/ltp/runltp
115
116*NOTE:
117- LTP assumes the existence of the nobody, bin, and daemon users and their
118groups.  If these IDs do not exist, certain tests will fail. The respective
119user and group IDs should be the same, i.e. if `nobody's' user ID is 99, then
120its group ID should also be 99. The names of the groups are irrelevant.
121- The installation directory is /opt/ltp by default. Please see
122"Using autoconf" above and specify the appropriate path via --prefix.
123DESTDIR= is also honored for install and will install into $DESTDIR/$prefix,
124if you want to install into a chroot or a rootfs for instance.
125
126Detailed Installation
127---------------------
128
129Beyond the "Quick Start" instructions, there are only a few other things
130that should be done.  The Linux Test Project build process uses a
131minimalist approach.  There is a lot of room for improvement and
132contributions are welcome.
133
1341. Log in as root.
135
1362. Untar the ltp tarball into a spare directory.  There is not a
137   standard location for it yet.  We put it in our home directory
138   while we're working on it.
139   Note that the full path to this location must be accessible for
140   unprivileged users, as some tests are run as a different user than root.
141   Hence /root is not a good choice on several distributions.
142
1433. Build and install everything, as described above. Note the minimum software
144   requirements above before doing so.
145
1464. The disk I/O tests can be run by executing the diskio.sh script.  In order
147   for these tests to successfully operate a writable high-density 3.5" floppy
148   must be in the disk drive and a CD-ROM with more than 100Mb of data must be
149   in the CD-ROM drive.  The corresponding tests will fail if either disk is
150   missing.
151
1525. The network tests related installation see testcases/network/README.md.
153
154Cross compiling
155---------------
156
157To cross compile, you must specify the correct variables when running configure.
158e.g. CC, LDFLAGS, etc.
159For correct pkgconf / pkg-config detection you need to set
160PKG_CONFIG_SYSROOT_DIR=$SYSROOT
161
162After configure has run, it will generate include/mk/config.mk. You can tweak
163settings in there if need be, but you should not specificy settings on the
164command-line when running make.
165
16632 bit build on 64 bit machine
167------------------------------
168
169You need to set CFLAGS=-m32 LDFLAGS=-m32 and PKG_CONFIG_LIBDIR
170
171* RPM based distributions (openSUSE, Fedora, etc.)
172PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
173
174* Debian / Ubuntu and derivates
175PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
176
177* Arch Linux
178PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig CFLAGS=-m32 LDFLAGS=-m32 ./configure
179
180Android Users
181-------------
182
183Specify ANDROID=1 when calling make. Many tests which would otherwise work are
184currently not built because they share a directory with an incompatible test.
185
186The shell scripts expect /bin/sh to exist, so create a symlink.
187
188Variables in Makefile
189---------------------
190
191The conventions enforced are standard ones. Here's a quick summary:
192
193CFLAGS   - used when compiling/linking C code, e.g. -D_GNU_SOURCE (no CPPFLAGS!)
194
195CPPFLAGS - used when preprocessor is run (so C/C++ compiling with $(CPP)
196	   functions, e.g. -I$SYSROOT/usr/include -I$SYSROOT/include -I$SYSROOT
197
198LDFLAGS  - linker flags, e.g. "-L$SYSROOT/usr/lib" "-L$SYSROOT/lib". DO NOT
199	   PUT LIBRARIES IN THIS LIST (see LDLIBS for that).
200
201LDLIBS   - libraries listed after objects during link, e.g. -lc, -lpthread,
202	   -lltp.
203
204For other variables and more info about the build systems see
205doc/Build-System.asciidoc.
206
207Common Issues
208-------------
209
210Issue:    When executing configure it says:
211
212checking for a BSD-compatible install... /usr/bin/install -c
213checking whether build environment is sane... yes
214checking for gawk... gawk
215checking whether make sets $(MAKE)... yes
216configure: error: cannot run /bin/sh ./config.sub
217
218Solution: You must upgrade autoconf to 0.10.2+ and m4 to 1.4.7+; config.guess and config.sub aren't necessarily generated with older revisions of the Gnu autotools chain.
219
220Issue:    When executing make [all] it says:
221
222    " *** No rule to make target `/$*', needed by `pan-all'.  Stop."
223
224Solution: You must upgrade to make 3.81. Please see the Requirements section above.
225
226Issue:    When executing make [all] it says something like:
227
228    # ...
229    install -m 00644 "/scratch/ltp-dev2/ltp/include/test.h" "/scratch/ltp-install12/include/test.h"
230    install -m 00644 "/scratch/ltp-dev2/ltp/include/tlibio.h" "/scratch/ltp-install12/include/tlibio.h"
231    install -m 00644 "/scratch/ltp-dev2/ltp/include/usctest.h" "/scratch/ltp-install12/include/usctest.h"
232    install -m 00644 "/scratch/ltp-dev2/ltp/include/write_log.h" "/scratch/ltp-install12/include/write_log.h"
233    make[1]: Leaving directory `/scratch/ltp-dev2/ltp/include'
234    make -C lib -f "/scratch/ltp-dev2/ltp/lib/Makefile" all
235    make[1]: Entering directory `/scratch/ltp-dev2/ltp/lib'
236    " *** No rule to make target `dataascii.o', needed by `libltp.a'.  Stop." # <-- the error
237
238Solution: You cannot build LTP with -r / --no-builtin-rules and/or
239	  -R / --no-builtin-variables specified. LTP relies heavily on built-in
240	  implicit rules and variables to function properly.
241
242Issue:    When executing make (no target, 3.80), it does the following, and doesn't execute all:
243
244    #
245    make -C testcases/realtime autotools
246    make[1]: Entering directory `/scratch/ltp/testcases/realtime'
247    autoheader
248    make[1]: Leaving directory `/scratch/ltp/testcases/realtime'
249