LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   "make" works. "make distcheck" doesn't. (https://www.linuxquestions.org/questions/programming-9/make-works-make-distcheck-doesnt-4175734275/)

hazel 02-26-2024 07:51 AM

"make" works. "make distcheck" doesn't.
 
I am converting some programs I wrote from gtk2 to gtk3, and making some other minor changes on the way.

The particular package that is giving me grief started out as a simple buttonbar to launch preselected programs and then acquired a couple of extra bits of desktop furniture: a mount tool (based on the one in Damn Small Linux) and a trashcan. There are two subdirectories under src: barbarella and accessories. I want to use the same header barbarella.h in both directories but distcheck doesn't allow that, neither with a copy nor with a link.

What do I do?

wpeckham 02-26-2024 08:26 AM

Quote:

Originally Posted by hazel (Post 6486014)
I am converting some programs I wrote from gtk2 to gtk3, and making some other minor changes on the way.

The particular package that is giving me grief started out as a simple buttonbar to launch preselected programs and then acquired a couple of extra bits of desktop furniture: a mount tool (based on the one in Damn Small Linux) and a trashcan. There are two subdirectories under src: barbarella and accessories. I want to use the same header barbarella.h in both directories but distcheck doesn't allow that, neither with a copy nor with a link.

What do I do?

Well for one, provide the exact error message and a bit of context so we have a place to start?

hazel 02-26-2024 08:30 AM

Code:

make[3]: Entering directory '/home/data/programming/barbarella/barbarella-4.0.3/barbarella-4.0.3/_build/sub/src/accessories'
gcc -DHAVE_CONFIG_H -I. -I../../../../src/accessories -I../..  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DICON_DIR=\""/home/data/programming/barbarella/barbarella-4.0.3/barbarella-4.0.3/_inst/share/pixmaps"\"  -g -O2 -MT mounts.o -MD -MP -MF .deps/mounts.Tpo -c -o mounts.o ../../../../src/accessories/mounts.c
../../../../src/accessories/mounts.c:3:10: fatal error: barbarella.h: No such file or directory
    3 | #include "barbarella.h"
      |          ^~~~~~~~~~~~~~
compilation terminated.

This is the second stage of compilation. The first stage builds the barbarella bar and doesn't complain about anything. Then it tries to build the mount tool and chokes.

pan64 02-26-2024 08:37 AM

I don't understand what did you do, but based on the error message you need a -I<location of barbarella.h> into that gcc command.
By the way you have a lot of duplicates in it.

hazel 02-26-2024 08:46 AM

Quote:

Originally Posted by pan64 (Post 6486026)
I don't understand what did you do, but based on the error message you need a -I<location of barbarella.h> into that gcc command.

That's a good starting point. Now where do I specify that in an autotools package? I'm aware that I could define a CFLAGS environmental variable containing -I but that wouldn't get into the built package, would it?

In configure.ac? Here's the contents of that file if you're interested:
Code:

AC_INIT([barbarella], [4.0.3], [hazel_russman@yahoo.co.uk])
AM_INIT_AUTOMAKE([-Wall, -Werror foreign])
AC_CONFIG_HEADERS([config.h])

AC_PROG_CC

dnl Checks for libraries.
PKG_CHECK_MODULES(DEPS, gtk+-3.0 >= 3.2 glib-2.0 >= 2.2)
AC_SUBST(DEPS_CFLAGS)
AC_SUBST(DEPS_LIBS)

AC_CHECK_HEADERS([stdlib.h string.h unistd.h blkid/blkid.h])
AC_FUNC_REALLOC


AC_CONFIG_FILES([
 Makefile
 src/barbarella/Makefile
 src/accessories/Makefile
 doc/Makefile
])
AC_OUTPUT

Quote:

By the way you have a lot of duplicates in it.
I never noticed that. Where did they all come from? I must admit that autotools is a black box for me.

ntubski 02-26-2024 07:46 PM

I think we need to see the Makefile.am files.

hazel 02-26-2024 11:54 PM

Quote:

Originally Posted by ntubski (Post 6486147)
I think we need to see the Makefile.am files.

The only active lines in the main one are:
Quote:

EXTRA_DIST = reconf configure
SUBDIRS = doc src/barbarella src/accessories
src/barbarella:
Quote:

icondir = $(datadir)/pixmaps
icon_DATA = barbarella.png
EXTRA_DIST = $(icon_DATA)

bin_PROGRAMS = barbarella

barbarella_SOURCES = configfile.c buttonbar.c barbarella.h
barbarella_LDADD = $(DEPS_LIBS) -lX11

AM_CPPFLAGS = $(DEPS_CFLAGS) \
-DICON_DIR=""$(datadir)/pixmaps""
And accessories
Code:

$ cat src/accessories/Makefile.am
##Process this file with automake to produce Makefile.in

icondir  = $(datadir)/pixmaps
icon_DATA = trash.png emptytrash.png
EXTRA_DIST  = $(icon_DATA)

bin_PROGRAMS = mount_tool trashcan
dist_bin_SCRIPTS = trash

mount_tool_SOURCES = mounts.c
trashcan_SOURCES = trashcan.c
mount_tool_LDADD = $(DEPS_LIBS) -lblkid -lX11
trashcan_LDADD = $(DEPS_LIBS) -lX11

AM_CPPFLAGS = $(DEPS_CPPFLAGS) -I@top_srcdir@\
              -DICON_DIR=\""$(datadir)/pixmaps"\"

I can see it now: The accessories subdir does contain a copy of barbarella.h but it isn't being picked up by automake.

pan64 02-27-2024 12:12 AM

Quote:

Originally Posted by hazel (Post 6486177)

I can see it now: The accessories subdir does contain a copy of barbarella.h but it isn't being picked up by automake.

It can be an ugly solution to copy it to another directory where it can be found. I still can't see how the gcc command was constructed.

GazL 02-27-2024 04:46 AM

Have you considered doing away with all that autotools complexity and just using a plain old makefile? If it's a small project then it probably isn't worth the pain of dealing with autotools.

Admittedly, I'm in the "cure is worse than the disease" camp when it comes to autotools, so I'm biased. I like "simple" and autotools is anything but.

hazel 02-27-2024 04:55 AM

Forget it. I've completely screwed it up now. I'm going to start again with the last gtk2 version that definitely builds and I'll do the gtk3 conversion from there. I should be able to remember how I did it!?:scratch:

PS: The edited gtk3 versions of the actual program code files were in geany, so I copied them over to a rescue directory. I can use those for reference.

Quote:

Originally Posted by GazL (Post 6486199)
Have you considered doing away with all that autotools complexity and just using a plain old makefile? If it's a small project then it probably isn't worth the pain of dealing with autotools.

There's a few source files involved. I don't know enough about make to do it by hand.

ntubski 02-27-2024 07:28 AM

Quote:

Originally Posted by hazel (Post 6486177)
I can see it now: The accessories subdir does contain a copy of barbarella.h but it isn't being picked up by automake.

I think that's because you didn't add the copied file to any of the lists. But you should just be able to add -I@top_srcdir@/barbarella to AM_CPPFLAGS in accessories/Makefile.am instead of having an extra copy.

https://www.gnu.org/software/automak...e.html#Headers
Quote:

All header files must be listed somewhere; in a _SOURCES variable or in a _HEADERS variable. Missing ones will not appear in the distribution.

hazel 02-27-2024 10:41 AM

OK, now it works. My mistake was to try to have a single header for all three programs. Two of them are simple one-file programs, so they don't need a separate header.

"make distcheck" now works, so the initial query is solved.

The current version still loads some library headers multiple times and I don't know why, but it clearly isn't doing any harm.
Code:

gcc -DHAVE_CONFIG_H -I. -I../../../../src/accessories -I../..  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DICON_DIR=""/home/data/programming/barbarella/barbarella-4.0.3/barbarella-4.0.3/_inst/share/pixmaps""  -g -O2 -MT mounts.o -MD -MP -MF .deps/mounts.Tpo -c -o mounts.o ../../../../src/accessories/mounts.c

gcc -DHAVE_CONFIG_H -I. -I../../../../src/barbarella -I../..  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DICON_DIR=""/home/data/programming/barbarella/barbarella-4.0.3/barbarella-4.0.3/_inst/share/pixmaps""  -g -O2 -MT configfile.o -MD -MP -MF .deps/configfile.Tpo -c -o configfile.o ../../../../src/barbarella/configfile.c


pan64 02-27-2024 10:47 AM

That is not a problem. It is working, just not nice. The construction of gcc commands can be probably simplified, but not that important if otherwise working.

ntubski 02-27-2024 09:34 PM

Quote:

Originally Posted by hazel (Post 6486246)
The current version still loads some library headers multiple times and I don't know why, but it clearly isn't doing any harm.

I guess there is some overlap in the include file paths for gtk+-3.0 and glib-2.0. I don't think it would be worth the trouble to reduce the duplication, actually I would just go and enable silent-rules so you don't have to see the verbosity most of the time.

https://www.gnu.org/software/automak...es-Option.html

hazel 02-28-2024 12:01 AM

Quote:

Originally Posted by ntubski (Post 6486330)
I guess there is some overlap in the include file paths for gtk+-3.0 and glib-2.0. I don't think it would be worth the trouble to reduce the duplication, actually I would just go and enable silent-rules so you don't have to see the verbosity most of the time.

https://www.gnu.org/software/automak...es-Option.html

Why bother? It doesn't do any harm, does it? I never even noticed it until pan64 mentioned it in #4.


All times are GMT -5. The time now is 05:28 AM.