commit d328e5f0b2ca8dc7e7aafeb446966f1b01d6893d from: Thomas Adam date: Fri Oct 08 22:18:12 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 - dc2a05aa2111fe14be0f0c3e025337dc9340b111 commit + d328e5f0b2ca8dc7e7aafeb446966f1b01d6893d blob - 4a60c0c27b40897050d7c154b573305a91654071 blob + 26a79f2d8ee0b6894c5181832f3fd4850d89de29 --- .gitignore +++ .gitignore @@ -4,3 +4,37 @@ **/Makefile.linux **/obj **/tags +**/*.core +**/*.o +**/*.Po +*~ +.ccls-cache/* +.deps/* +Makefile.common +aclocal.m4 +autom4te.cache/* +compat/.dirstamp +compat/libopenbsd-compat.a +config.log +config.status +configure +core +etc/* +got/got +gotadmin/gotadmin +lib/.dirstamp +lib/.deps/* +libexec/got-fetch-pack/got-fetch-pack +libexec/got-index-pack/got-index-pack +libexec/got-read-blob/got-read-blob +libexec/got-read-commit/got-read-commit +libexec/got-read-gitconfig/got-read-gitconfig +libexec/got-read-gotconfig/got-read-gotconfig +libexec/got-read-gotconfig/parse.c +libexec/got-read-object/got-read-object +libexec/got-read-pack/got-read-pack +libexec/got-read-tag/got-read-tag +libexec/got-read-tree/got-read-tree +libexec/got-send-pack/got-send-pack +tags +tog/tog 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 + 7f93819e7c81cad6a3fae4ea38c5564ff61ae6cf (mode 644) --- /dev/null +++ Makefile.common.in @@ -0,0 +1,19 @@ +AM_CFLAGS += \ + @AM_CFLAGS@ \ + -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 - 8f6a703fe3bed4e8f46ce4343765e35659f87c26 blob + 857e0e23d5392ef0f579ad2e436f82e46e786f79 --- 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