[ZBX-11764] Automake cleanups and small files Created: 2017 Feb 01  Updated: 2024 Apr 10  Resolved: 2019 Oct 16

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Installation (I)
Affects Version/s: 3.4.0alpha1
Fix Version/s: 5.0.0alpha1, 5.0 (plan)

Type: Problem report Priority: Trivial
Reporter: Tomasz Kłoczko Assignee: Andrejs Kozlovs
Resolution: Fixed Votes: 0
Labels: compilation, installation, patch
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File zabbix-am_fixes-top_srcdir-4.2_v1.10.patch     File zabbix-am_fixes.patch     File zabbix-am_top_srcdir_fixes-3.0.patch     File zabbix-am_top_srcdir_fixes-3.2.patch     File zabbix-am_top_srcdir_fixes-trunk_v1.3.patch    
Team: Team A
Sprint: Sprint 57 (Oct 2019)
Story Points: 2

 Description   

Attached patch contains some automake cleanups against trunk.
List of small improvements/fixes which my patch delivers:

  1. replace @FOO@ by $(FOO) to allow on execute make command override some variables
  2. put in each *_SOURCE list all files in separated lines and sort list of those files alphabetically
  3. do not use $(top_sourcedir) in paths of static libraries. It should be always used $(top_builddir) to allow build zabbix code from read only source tree
  4. remove from src/libs/zbxsysinfo/Makefile.am EXTRA_DIST files which are included in *_SOURCES in subdirectories


 Comments   
Comment by Glebs Ivanovskis (Inactive) [ 2017 Feb 01 ]

Could you provide more details on what you want to override with 1.? Does anyone really care about 2.? When is 3. a problem?

Comment by Tomasz Kłoczko [ 2017 Feb 02 ]

ad 2) it makes easy to add new file by one line change. Other thing is with keeping the same format everywhere. Generally importance is the same as with keeping the same style of C code indentation. As our brain is perfectly suited to catch any broken patterns keeping the same style everywhere allows easier catch points where (in this case automake) code is wrong.
ad 1)

-libzbxdbcache_a_CFLAGS = -I@top_srcdir@/src/zabbix_server/ -I@top_srcdir@/src/libs/zbxalgo
+libzbxdbcache_a_CFLAGS = \
+          -I$(top_srcdir)/src/zabbix_server \
+          -I$(top_srcdir)/src/libs/zbxalgo

Without this is not possible to specify top_srcdir after running configure because it will be hardcoded at the end of configure execution, or:

-       -DSYSCONFDIR="\"@sysconfdir@\"" \
-       -DLIBDIR="\"@libdir@\""
+       -DSYSCONFDIR="\"$(sysconfdir)\"" \
+       -DLIBDIR="\"$(libdir)\""

This will break for example overwriting sysconfdir on "make test sysconfdir=/my/cfg" where temporary new object file will be created, linked and used on tests.
In other places is not needed m4 macroing because automake automatically generates in Makefile.in files lines with variables:
FOO = @FOO@ so all what is needed in Makefile.am is use those variables straight

Generally using @FOO@ macroing in Makefile.am is kind bad habit. Usually it does not harm but when project grows/extends and for example sophisticated test (before install) will be added such things makes whole automake broken or it may be source of some confusion.
ad 3)

tar xzf zabbix-<version>.tar.gz
mkdir tmp_builddir
cd tmp_builddir
../zabbix-<version>/configure <params>
make

Above will keep zabbix-<version>/ clean and all temporary files, Makefile, object files will go to tmp_builddir/.
Original source tree can be even on RO storage. It is very useful for example when you need perform test builds with different "configure <params>" and/or when you want to keep archived for the record all files used during build.
Automake automatically generated all static libraries (and other build stage files as well) in $(top_builddir) and some linker *_LDADD have hard coded $(top_srcdir) such build will fail.

Comment by Tomasz Kłoczko [ 2017 Feb 10 ]

Sorry .. may I ask for update?

Comment by Glebs Ivanovskis (Inactive) [ 2017 Feb 10 ]

I am not in charge of making decisions which features are implemented, which bugs get fixed or which patches to review and test. Zabbix developers are few and they are overloaded. Sometimes I spend my free time to have a glance at user requests, problems, patches, etc. But at these moments I am usually an ordinary community member like you. Sorry.

Comment by Tomasz Kłoczko [ 2017 May 02 ]

Seems it is a problem with accepting my fixes.
Will try another approach by sending only patches against one issue.
Here are patches replacing use $(top_srcdir) by $(top_builddir) for trunk, 3.2 and 3.0.

Comment by Tomasz Kłoczko [ 2017 May 12 ]

Uploaded s/top_srcdir/top_builddir/ trunk patch.

Comment by Tomasz Kłoczko [ 2017 May 19 ]

Updated patch against trunk branch.

Comment by Alexei Vladishev [ 2017 May 21 ]

I am trying to repeat it with the latest trunk and it fails with and without top_srcdir patch:

tar xzf zabbix-3.4.0alpha1.tar.gz
mkdir tmp_builddir
cd tmp_builddir
../zabbix-3.4.0alpha1/configure --enable-server --with-mysql
make

Error running make:

make[1]: Entering directory '/tmp/tmp_builddir/src'
Making all in libs
make[2]: Entering directory '/tmp/tmp_builddir/src/libs'
Making all in zbxcrypto
make[3]: Entering directory '/tmp/tmp_builddir/src/libs/zbxcrypto'
gcc -DHAVE_CONFIG_H -I. -I../../../../zabbix-3.4.0alpha1/src/libs/zbxcrypto -I../../../include     -g -O2  -MT libzbxcrypto_a-md5.o -MD -MP -MF .deps/libzbxcrypto_a-md5.Tpo -c -o libzbxcrypto_a-md5.o `test -f 'md5.c' || echo '../../../../zabbix-3.4.0alpha1/src/libs/zbxcrypto/'`md5.c
../../../../zabbix-3.4.0alpha1/src/libs/zbxcrypto/md5.c:54:20: fatal error: common.h: No such file or directory
compilation terminated.

I suspect it's something to do with include path that possibly also should be adjusted somewhere.

Comment by Tomasz Kłoczko [ 2017 Sep 05 ]

Just found what exactly was missing in cinfigure.ac to make this patch working.
This patch is against trunk so it is ready to evaluate/test and possible commit.
later will try to prepare the same patches for 3.2 and 3.0 branches.

Comment by Tomasz Kłoczko [ 2019 Oct 04 ]

FYI: In next few hours will try to upload updated version of that patch.

Comment by Tomasz Kłoczko [ 2019 Oct 07 ]

Just uploaded latest version of that patch for 4.2.7.

Comment by Andrejs Kozlovs [ 2019 Oct 15 ]

Fixed in:

Generated at Sun Mar 16 17:00:08 EET 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.