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