rgbds
                                
                                 rgbds copied to clipboard
                                
                                    rgbds copied to clipboard
                            
                            
                            
                        building rgbasm warns about lack of libpng
following the build steps to build rgbasm on my alpine linux setup. libpng-dev is not installed. according to the building steps, libpng should not be required for the binaries other than rgbgfx, but the building process complains anyways.
$make rgbasm rgblink rgbfix Q=
...
cc -O3 -flto -DNDEBUG -Wall -pedantic -std=gnu11 -I include -D_POSIX_C_SOURCE=200809L -D_ISOC11_SOURCE `pkg-config --cflags libpng` -c -o src/asm/fixpoint.o src/asm/fixpoint.c
Package libpng was not found in the pkg-config search path.
Perhaps you should add the directory containing `libpng.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libpng', required by 'virtual:world', not found
...
after a quick look around the Makefile structure it seems like the problem is the call to pkg-config --cflags libpng for generating files that don't depend on libpng. there are multiple ways I can see to solve this:
- using gnu make feature-
src/gfx/%.o: CFLAGS += `pkg-config --cflags libpng`
pros: concise. cons: compatibility.
- adding an explicit rule for each file that uses those flags. there are only 3 files currently using it. pros: compatible. cons: code duplication.
- recursive makefile specifically for rgbgfx. pros: concise, compatible. cons: slow (but how slow?) and harder to maintain (is it really?).
@ISSOtm Was this solved already? Now that rgbgfx was rewritten in C++, PNGCFLAGS (`pkg-config --cflags libpng`) is only getting passed to its files, not to non-rgbgfx ones like src/asm/fixpoint.o. On the other hand, only three of those individual .cpp files have #include <png.h>; @DaKnig is this still an issue for you?
This "fix" will stop holding water if/as soon as any other programs are ported to C++. Whether this is solved by tweaking the build system, not doing any other language changes, or "the nuclear option" (:crab:), I think this issue should be kept open until then.
this did solve the issue- it builds just fine on my system, although it implicitly depends on bash (not mentioned in the dep list in the build instructions).
After #1176 this issue will come up again.
The current ~~solution~~ workaround is that rgbgfx uses all .cpp files, and everything else uses .c. So we can get away with two suffix rules:
.c.o:
	$Q${CC} ${REALCFLAGS} -c -o $@ $<
.cpp.o:
	$Q${CXX} ${REALCXXFLAGS} ${PNGCFLAGS} -c -o $@ $<
Possible solutions:
- Use a pattern rule src/gfx/%.o. Unfortunately this is GNU only, not POSIX/BSD. I would kind of like to just standardize on GNU make, like how some build+test scripts standardize on bash not POSIX sh.
- Use explicit rules for every rgbgfx source file. We already do have to list individual files for cmake, so doing it for one program in make isn't too bad.
- An even hackier ~~solution~~ workaround: use .cpp for C++ files that need PNG flags, and .cxx for the rest. Then the suffix rules will still work. ;)
@ISSOtm any preference?
I think it's worth biting the bullet and going with explicit rules.