df0f1e35b7
GCC has become too aggressive with its warnings, complaining about more and more perfectly valid code. In August 2020 I received a report of GCC 10.1 generating a warning about strncat: --------8<-------- cc -D_FORTIFY_SOURCE=2 -Wall -W -Wextra -pedantic -Werror -pedantic-errors -fstack-protector-all -O3 -c -o ssocr.o ssocr.c In file included from /usr/include/string.h:495, from ssocr.c:29: In function ‘strncat’, inlined from ‘tmp_imgfile’ at ssocr.c:79:12, inlined from ‘main’ at ssocr.c:454:15: /usr/include/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ssocr.c: In function ‘main’: ssocr.c:67:19: note: length computed here 67 | pattern_len = strlen(dir) + strlen(DIR_SEP TMP_FILE_PATTERN) + 1; | ^~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [<builtin>: ssocr.o] Error 1 -------->8-------- Basically the same problem has been reported in GitHub issue #15, "Fails to build on Arm": --------8<-------- cc -D_FORTIFY_SOURCE=2 -Wall -W -Wextra -pedantic -Werror -pedantic-errors -fstack-protector-all -O3 -c -o ssocr.o ssocr.c In file included from /usr/include/string.h:495, from ssocr.c:29: In function ‘strncat’, inlined from ‘tmp_imgfile’ at ssocr.c:79:12, inlined from ‘main’ at ssocr.c:529:15: /usr/include/arm-linux-gnueabihf/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ssocr.c: In function ‘main’: ssocr.c:67:19: note: length computed here 67 | pattern_len = strlen(dir) + strlen(DIR_SEP TMP_FILE_PATTERN) + 1; | ^~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [<builtin>: ssocr.o] Error 1 -------->8-------- As described in a Red Hat blog post[1], this warning cannot be avoided without rewriting the code to not use strncat. I do not intend to do so, instead I just accept that GCC will generate warnings. Thus this commit removes -Werror and -pedantic-errors from the CFLAGS. This fixes compilation on a x86_64 Debian Buster (11) GNU/Linux test system with gcc (Debian 10.2.1-6) 10.2.1 20210110. This strncat warning is the only warning generated by that gcc version. [1] I do not link to that blog post here, because it requires JavaScript to display textual information, which I find unacceptable.
63 lines
2.3 KiB
Makefile
63 lines
2.3 KiB
Makefile
# minimal CFLAGS definition (try if compilation fails with default CFLAGS)
|
|
#CFLAGS := $(shell imlib2-config --cflags)
|
|
# default CFLAGS definition
|
|
CFLAGS := -D_FORTIFY_SOURCE=2 -Wall -W -Wextra -pedantic -fstack-protector-all $(shell imlib2-config --cflags) -O3
|
|
LDLIBS := -lm $(shell imlib2-config --libs)
|
|
PREFIX := /usr/local
|
|
BINDIR := $(PREFIX)/bin
|
|
MANDIR := $(PREFIX)/share/man/man1
|
|
DOCDIR := $(PREFIX)/share/doc/ssocr
|
|
DOCS := AUTHORS COPYING INSTALL README THANKS
|
|
VERSION := $(shell sed -n 's/^.*VERSION.*\(".*"\).*/\1/p' defines.h)
|
|
CRYEARS := $(shell sed -n 's/^.*fprintf.*Copyright.*\(2004-2[0-9][0-9][0-9]\).*Erik.*Auerswald.*$$/\1/p' help.c)
|
|
|
|
all: ssocr ssocr.1
|
|
|
|
ssocr: ssocr.o imgproc.o help.o charset.o
|
|
|
|
ssocr.o: ssocr.c ssocr.h defines.h imgproc.h help.h charset.h Makefile
|
|
imgproc.o: imgproc.c defines.h imgproc.h help.h Makefile
|
|
help.o: help.c defines.h imgproc.h help.h Makefile
|
|
charset.o: charset.c charset.h defines.h help.h Makefile
|
|
|
|
ssocr.1: ssocr.1.in Makefile
|
|
sed -e 's/@VERSION@/$(VERSION)/' \
|
|
-e "s/@DATE@/$(shell date +%Y-%m-%d)/" \
|
|
-e 's/@CRYEARS@/$(CRYEARS)/' <$< >$@
|
|
|
|
ssocr-manpage.html: ssocr.1
|
|
man -l -Thtml $< >$@
|
|
|
|
install: all
|
|
install -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR) $(DESTDIR)$(DOCDIR)
|
|
install -s -m 0755 ssocr $(DESTDIR)$(BINDIR)/ssocr
|
|
install -m 0644 ssocr.1 $(DESTDIR)$(MANDIR)/ssocr.1
|
|
gzip -9 $(DESTDIR)$(MANDIR)/ssocr.1
|
|
install -m 0644 $(DOCS) $(DESTDIR)$(DOCDIR)
|
|
|
|
ssocr-dir:
|
|
install -d ssocr-$(VERSION)
|
|
install -m 0644 Makefile $(DOCS) *.[ch] *.in ssocr-$(VERSION)
|
|
install -d ssocr-$(VERSION)/notdebian
|
|
install -m 0644 notdebian/* ssocr-$(VERSION)/notdebian
|
|
chmod +x ssocr-$(VERSION)/notdebian/rules
|
|
|
|
notdebian/changelog:
|
|
printf "ssocr ($(VERSION)-1) unstable; urgency=low\n\n * self built package of current ssocr version in .deb format\n\n -- $(USER) $(shell date -R)\n" >$@
|
|
|
|
selfdeb: notdebian/changelog notdebian/control notdebian/rules ssocr-dir
|
|
(cd ssocr-$(VERSION); ln -sv notdebian debian; fakeroot debian/rules binary; fakeroot debian/rules clean; rm -f debian)
|
|
|
|
tar: ssocr-dir
|
|
tar cvfj ssocr-$(VERSION).tar.bz2 ssocr-$(VERSION)
|
|
|
|
clean:
|
|
$(RM) ssocr ssocr.1 *.o *~ testbild.png ssocr-manpage.html
|
|
$(RM) notdebian/changelog
|
|
$(RM) -r ssocr-$(VERSION) ssocr-?.?.? ssocr-?.??.?
|
|
|
|
distclean: clean
|
|
$(RM) *.deb *.bz2
|
|
|
|
.PHONY: clean tar ssocr-dir install
|