commit 0e50a59ae2ad957ec84e24805ac9351136974b6f from: Thomas Adam date: Wed Sep 29 11:37:48 2021 UTC portable: propagate AM_CFLAGS/AM_CPPFLAGS Compiling with warnings and certain compiler flags is important for security and bug-free code. Set a bunch of warnings via AM_CFLAGS in a common Makefile, and let those values propagate to all other Makefiles. While here, also fix the version string to remove quotes. commit - cc1cb6fe00a13f31ed58d5f0d2e612f74b83acc2 commit + 0e50a59ae2ad957ec84e24805ac9351136974b6f blob - 99173d49290ba9b60f69d539d9e5a4aacd4ae2a4 blob + 0cb3993aefb556f7a63d6f8a9149eef25892fe10 --- .gitignore +++ .gitignore @@ -7,6 +7,7 @@ *~ .ccls-cache/ .deps/ +Makefile.common aclocal.m4 autom4te.cache/ compat/.dirstamp blob - ae25dd0b8c480bbd035f0bec9258dad705303e35 blob + fa47506aea539b04738688df171df55668af4f29 --- Makefile.am +++ Makefile.am @@ -1,24 +1,10 @@ SUBDIRS = compat libexec got tog gotadmin +include $(top_builddir)/Makefile.common + EXTRA_DIST = CHANGES CHANGELOG -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION'" \ - -DGOT_VERSION_NUMBER='"@VERSION"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/include - LDADD = $(LIBOBJS) -# FIXME: enable via --enable-debug. Hard-code for now. -AM_CFLAGS += -g -AM_CFLAGS += -Wno-long-long -Wall -W -Wformat=2 -AM_CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -AM_CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -AM_CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align -AM_CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes -AM_CFLAGS += -Wno-unused-result - tests: $(MAKE) -C regress/cmdline -f Makefile.linux blob - /dev/null blob + 7058983ed084085670616f347aa65ee20daad518 (mode 644) --- /dev/null +++ Makefile.common.in @@ -0,0 +1,19 @@ +AM_CFLAGS += \ + @AM_CPPFLAGS@ \ + -g -Wall -Wno-long-long -W -Wformat=2 -Wmissing-prototypes \ + -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings \ + -Wshadow -Wpointer-arith -Wsign-compare -Wundef \ + -Wbad-function-cast -Winline -Wcast-align \ + -Wdeclaration-after-statement -Wno-pointer-sign \ + -Wno-attributes -Wno-unused-result + +AM_CPPFLAGS += \ + @AM_CPPFLAGS@ \ + -DGOT_VERSION=@VERSION@ \ + -DGOT_VERSION_NUMBER=@VERSION@ \ + -DGOT_LIBEXECDIR="$(libexecdir)" \ + -I$(top_srcdir) \ + -I$(top_srcdir)/compat \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/include \ + -I. blob - 49f23799a8f498120c8f4e78513e02cfb55f0417 blob + 958a3d67dfe92ddf1caf9fd8e3586f887a36001b --- compat/Makefile.am +++ compat/Makefile.am @@ -1,14 +1,8 @@ noinst_LIBRARIES = libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. +include $(top_builddir)/Makefile.common + libopenbsd_compat_a_SOURCES = \ asprintf.c \ base64.c \ blob - febc60ec9dfe3e5a3f42ce573ad749f7bba15b72 blob + bb6b96f80a2665fa9a99c27e8186481cc9cdf4f2 --- configure.ac +++ configure.ac @@ -447,6 +447,7 @@ AC_CONFIG_FILES([Makefile got/Makefile gotadmin/Makefile tog/Makefile + Makefile.common:Makefile.common.in regress/cmdline/Makefile.linux:regress/cmdline/Makefile.am]) AC_OUTPUT blob - 5ebca066f379fb262f13f31703af74482e68c58b blob + 5ce2fefb817223e866a42709aabddf2711dbd24e --- got/Makefile.am +++ got/Makefile.am @@ -1,5 +1,7 @@ bin_PROGRAMS = got +include $(top_builddir)/Makefile.common + got_SOURCES = got.c \ $(top_srcdir)/lib/blame.c \ $(top_srcdir)/lib/commit_graph.c \ @@ -53,15 +55,6 @@ got_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-c man1_MANS = got.1 man5_MANS = got.conf.5 git-repository.5 got-worktree.5 -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 24e66f03dea8cd705d37baa3ea4031e721128300 blob + c6eba1dbd81b57dadad698d0cf227e01f5f62566 --- gotadmin/Makefile.am +++ gotadmin/Makefile.am @@ -1,5 +1,7 @@ bin_PROGRAMS = gotadmin +include $(top_builddir)/Makefile.common + gotadmin_SOURCES = gotadmin.c \ $(top_srcdir)/lib/deflate.c \ $(top_srcdir)/lib/delta.c \ @@ -28,15 +30,6 @@ gotadmin_DEPENDENCIES = $(top_builddir)/compat/libopen man1_MANS = gotadmin.1 -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 6f7ce0f513e24d00d5139cc4bc89bd07ad2038be blob + 66ca64b11bfe3094c4914c43da63b6f393128bcf --- libexec/got-fetch-pack/Makefile.am +++ libexec/got-fetch-pack/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-fetch-pack + +include $(top_builddir)/Makefile.common + got_fetch_pack_SOURCES = \ got-fetch-pack.c \ $(top_srcdir)/lib/error.c \ @@ -12,15 +15,6 @@ got_fetch_pack_SOURCES = \ got_fetch_pack_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - c7352e7d1a7fd2efb4a960a825101ff89cc039dd blob + 9e14e929bb5df6aece44e69a8767dfc7bf1cc0e7 --- libexec/got-index-pack/Makefile.am +++ libexec/got-index-pack/Makefile.am @@ -1,5 +1,7 @@ libexec_PROGRAMS = got-index-pack -bin_PROGRAMS = got-index-pack + +include $(top_builddir)/Makefile.common + got_index_pack_SOURCES = got-index-pack.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -14,15 +16,6 @@ got_index_pack_SOURCES = got-index-pack.c \ got_index_pack_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 9787e4287b6c2b403820e9d2265d2179e217e6bb blob + fe1e85bd32592cac6f44d8ad36ad5f2c189e40c9 --- libexec/got-read-blob/Makefile.am +++ libexec/got-read-blob/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-blob + +include $(top_builddir)/Makefile.common + got_read_blob_SOURCES = got-read-blob.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -9,15 +12,6 @@ got_read_blob_SOURCES = got-read-blob.c \ got_read_blob_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 3586ea049605e4d04cfea21e0ca4aa20ef7924ba blob + a57f5ee816d1b72bd729aa6bf408844cfe50d03c --- libexec/got-read-commit/Makefile.am +++ libexec/got-read-commit/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-commit + +include $(top_builddir)/Makefile.common + got_read_commit_SOURCES = got-read-commit.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -9,15 +12,6 @@ got_read_commit_SOURCES = got-read-commit.c \ got_read_commit_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 5699d7034d03c8eb443a6820c6325923357d6168 blob + de089287b3dd54d447997fe6790315faf8f58615 --- libexec/got-read-gitconfig/Makefile.am +++ libexec/got-read-gitconfig/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-gitconfig + +include $(top_builddir)/Makefile.common + got_read_gitconfig_SOURCES = got-read-gitconfig.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -10,15 +13,6 @@ got_read_gitconfig_SOURCES = got-read-gitconfig.c \ got_read_gitconfig_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 264f7aad9a614cb59909dddf2f06a020e85cf28d blob + 58eb65bdd20b1edb5e5246f762cda1cb23c1248b --- libexec/got-read-gotconfig/Makefile.am +++ libexec/got-read-gotconfig/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-gotconfig + +include $(top_builddir)/Makefile.common + got_read_gotconfig_SOURCES = \ got-read-gotconfig.c \ gotconfig.h \ @@ -12,15 +15,6 @@ got_read_gotconfig_SOURCES = \ got_read_gotconfig_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 089f1d5923f32b25698bbb3d9e1df4cb6cbaf4df blob + 89fab35d568498f3240f57b08d05b25bbbd15205 --- libexec/got-read-object/Makefile.am +++ libexec/got-read-object/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-object + +include $(top_builddir)/Makefile.common + got_read_object_SOURCES = got-read-object.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -9,15 +12,6 @@ got_read_object_SOURCES = got-read-object.c \ got_read_object_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - c11d0fae56e2e3b3c07e1b798641d9a4c17ec2f9 blob + e42644c2288b0376c58274c1b19ba3030e65749b --- libexec/got-read-pack/Makefile.am +++ libexec/got-read-pack/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-pack + +include $(top_builddir)/Makefile.common + got_read_pack_SOURCES = got-read-pack.c \ $(top_srcdir)/lib/delta.c \ $(top_srcdir)/lib/delta_cache.c \ @@ -15,15 +18,6 @@ got_read_pack_SOURCES = got-read-pack.c \ got_read_pack_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 58829dc6b5691553e2ba41c554b68bba14ad6985 blob + f21b5534c55e0f56bb07bf07e6aca05a67aeed8b --- libexec/got-read-tag/Makefile.am +++ libexec/got-read-tag/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-tag + +include $(top_builddir)/Makefile.common + got_read_tag_SOURCES = got-read-tag.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -9,15 +12,6 @@ got_read_tag_SOURCES = got-read-tag.c \ got_read_tag_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 63e7bf8526ff4755fb7ececc2c0b141d9c3acac0 blob + 6c2dc784c89dca2cef6b99452a9d23136e1ddeae --- libexec/got-read-tree/Makefile.am +++ libexec/got-read-tree/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-read-tree + +include $(top_builddir)/Makefile.common + got_read_tree_SOURCES = got-read-tree.c \ $(top_srcdir)/lib/error.c \ $(top_srcdir)/lib/inflate.c \ @@ -9,15 +12,6 @@ got_read_tree_SOURCES = got-read-tree.c \ got_read_tree_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 496757723bf7f3852ad7b6645a1524b9f0fb6663 blob + 79e87b03c6de83cd98519d73720c83ce68f499a1 --- libexec/got-send-pack/Makefile.am +++ libexec/got-send-pack/Makefile.am @@ -1,4 +1,7 @@ libexec_PROGRAMS = got-send-pack + +include $(top_builddir)/Makefile.common + got_send_pack_SOURCES = \ got-send-pack.c \ $(top_srcdir)/lib/error.c \ @@ -12,15 +15,6 @@ got_send_pack_SOURCES = \ got_send_pack_DEPENDENCIES = $(top_builddir)/compat/libopenbsd-compat.a -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat if HOST_FREEBSD LDADD += -lmd blob - 45ba80e940a88b7dc707882566aea5cc20312cb6 blob + 3503b0a3ee2a09bab034c51681f03d5e7094219f --- tog/Makefile.am +++ tog/Makefile.am @@ -1,5 +1,7 @@ bin_PROGRAMS = tog +include $(top_builddir)/Makefile.common + tog_SOURCES = tog.c \ $(top_srcdir)/lib/blame.c \ $(top_srcdir)/lib/commit_graph.c \ @@ -47,15 +49,6 @@ man1_MANS = tog.1 EXTRA_DIST = tog.1 -AM_CPPFLAGS += -DGOT_VERSION='"@VERSION@"' \ - -DGOT_VERSION_NUMBER='"@VERSION@"' \ - -DGOT_LIBEXECDIR="$(libexecdir)" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/compat \ - -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I. - LDADD = -L$(top_builddir)/compat -lopenbsd-compat -lpthread if HOST_FREEBSD LDADD += -lmd