Skip to content

Commit 3cef676

Browse files
committed
Merge branch 'ab/makefile-help-devs-more'
CFLAGS now can be tweaked when invoking Make while using DEVELOPER=YesPlease; this did not work well before. * ab/makefile-help-devs-more: Makefile: allow for combining DEVELOPER=1 and CFLAGS="..." Makefile: move the setting of *FLAGS closer to "include" Makefile: Move *_LIBS assignment into its own section Makefile: add/remove comments at top and tweak whitespace Makefile: move "strip" assignment down from flags Makefile: remove an out-of-date comment
2 parents 0e94f7a + 6d5d4b4 commit 3cef676

File tree

2 files changed

+55
-52
lines changed

2 files changed

+55
-52
lines changed

Makefile

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,11 @@ all::
479479
#
480480
# Define DEVELOPER to enable more compiler warnings. Compiler version
481481
# and family are auto detected, but could be overridden by defining
482-
# COMPILER_FEATURES (see config.mak.dev)
482+
# COMPILER_FEATURES (see config.mak.dev). You can still set
483+
# CFLAGS="..." in combination with DEVELOPER enables, whether that's
484+
# for tweaking something unrelated (e.g. optimization level), or for
485+
# selectively overriding something DEVELOPER or one of the DEVOPTS
486+
# (see just below) brings in.
483487
#
484488
# When DEVELOPER is set, DEVOPTS can be used to control compiler
485489
# options. This variable contains keywords separated by
@@ -506,17 +510,8 @@ GIT-VERSION-FILE: FORCE
506510
@$(SHELL_PATH) ./GIT-VERSION-GEN
507511
-include GIT-VERSION-FILE
508512

509-
# CFLAGS and LDFLAGS are for the users to override from the command line.
510-
511-
CFLAGS = -g -O2 -Wall
512-
LDFLAGS =
513-
ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
514-
ALL_LDFLAGS = $(LDFLAGS)
515-
STRIP ?= strip
516-
517-
# Create as necessary, replace existing, make ranlib unneeded.
518-
ARFLAGS = rcs
519-
513+
# Set our default configuration.
514+
#
520515
# Among the variables below, these:
521516
# gitexecdir
522517
# template_dir
@@ -561,6 +556,7 @@ perllibdir_relative = $(patsubst $(prefix)/%,%,$(perllibdir))
561556

562557
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
563558

559+
# Set our default programs
564560
CC = cc
565561
AR = ar
566562
RM = rm -f
@@ -573,29 +569,14 @@ TCLTK_PATH = wish
573569
XGETTEXT = xgettext
574570
MSGFMT = msgfmt
575571
CURL_CONFIG = curl-config
576-
PTHREAD_LIBS = -lpthread
577-
PTHREAD_CFLAGS =
578572
GCOV = gcov
573+
STRIP = strip
579574
SPATCH = spatch
580575

581576
export TCL_PATH TCLTK_PATH
582577

583-
# user customisation variable for 'sparse' target
584-
SPARSE_FLAGS ?=
585-
# internal/platform customisation variable for 'sparse'
586-
SP_EXTRA_FLAGS =
587-
588-
SPATCH_FLAGS = --all-includes --patch .
589-
590-
591-
592-
### --- END CONFIGURATION SECTION ---
593-
594-
# Those must not be GNU-specific; they are shared with perl/ which may
595-
# be built by a different compiler. (Note that this is an artifact now
596-
# but it still might be nice to keep that distinction.)
597-
BASIC_CFLAGS = -I.
598-
BASIC_LDFLAGS =
578+
# Set our default LIBS variables
579+
PTHREAD_LIBS = -lpthread
599580

600581
# Guard against environment variables
601582
BUILTIN_OBJS =
@@ -1177,6 +1158,25 @@ ifeq ($(wildcard sha1collisiondetection/lib/sha1.h),sha1collisiondetection/lib/s
11771158
DC_SHA1_SUBMODULE = auto
11781159
endif
11791160

1161+
# Set CFLAGS, LDFLAGS and other *FLAGS variables. These might be
1162+
# tweaked by config.* below as well as the command-line, both of
1163+
# which'll override these defaults.
1164+
CFLAGS = -g -O2 -Wall
1165+
LDFLAGS =
1166+
BASIC_CFLAGS = -I.
1167+
BASIC_LDFLAGS =
1168+
1169+
# library flags
1170+
ARFLAGS = rcs
1171+
PTHREAD_CFLAGS =
1172+
1173+
# For the 'sparse' target
1174+
SPARSE_FLAGS ?=
1175+
SP_EXTRA_FLAGS =
1176+
1177+
# For the 'coccicheck' target
1178+
SPATCH_FLAGS = --all-includes --patch .
1179+
11801180
include config.mak.uname
11811181
-include config.mak.autogen
11821182
-include config.mak
@@ -1185,6 +1185,9 @@ ifdef DEVELOPER
11851185
include config.mak.dev
11861186
endif
11871187

1188+
ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS)
1189+
ALL_LDFLAGS = $(LDFLAGS)
1190+
11881191
comma := ,
11891192
empty :=
11901193
space := $(empty) $(empty)

config.mak.dev

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
ifeq ($(filter no-error,$(DEVOPTS)),)
2-
CFLAGS += -Werror
2+
DEVELOPER_CFLAGS += -Werror
33
endif
44
ifneq ($(filter pedantic,$(DEVOPTS)),)
5-
CFLAGS += -pedantic
5+
DEVELOPER_CFLAGS += -pedantic
66
# don't warn for each N_ use
7-
CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
8-
endif
9-
CFLAGS += -Wall
10-
CFLAGS += -Wdeclaration-after-statement
11-
CFLAGS += -Wformat-security
12-
CFLAGS += -Wno-format-zero-length
13-
CFLAGS += -Wold-style-definition
14-
CFLAGS += -Woverflow
15-
CFLAGS += -Wpointer-arith
16-
CFLAGS += -Wstrict-prototypes
17-
CFLAGS += -Wunused
18-
CFLAGS += -Wvla
7+
DEVELOPER_CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
8+
endif
9+
DEVELOPER_CFLAGS += -Wall
10+
DEVELOPER_CFLAGS += -Wdeclaration-after-statement
11+
DEVELOPER_CFLAGS += -Wformat-security
12+
DEVELOPER_CFLAGS += -Wno-format-zero-length
13+
DEVELOPER_CFLAGS += -Wold-style-definition
14+
DEVELOPER_CFLAGS += -Woverflow
15+
DEVELOPER_CFLAGS += -Wpointer-arith
16+
DEVELOPER_CFLAGS += -Wstrict-prototypes
17+
DEVELOPER_CFLAGS += -Wunused
18+
DEVELOPER_CFLAGS += -Wvla
1919

2020
ifndef COMPILER_FEATURES
2121
COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
2222
endif
2323

2424
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
25-
CFLAGS += -Wtautological-constant-out-of-range-compare
25+
DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare
2626
endif
2727

2828
ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
29-
CFLAGS += -Wextra
29+
DEVELOPER_CFLAGS += -Wextra
3030
# if a function is public, there should be a prototype and the right
3131
# header file should be included. If not, it should be static.
32-
CFLAGS += -Wmissing-prototypes
32+
DEVELOPER_CFLAGS += -Wmissing-prototypes
3333
ifeq ($(filter extra-all,$(DEVOPTS)),)
3434
# These are disabled because we have these all over the place.
35-
CFLAGS += -Wno-empty-body
36-
CFLAGS += -Wno-missing-field-initializers
37-
CFLAGS += -Wno-sign-compare
38-
CFLAGS += -Wno-unused-parameter
35+
DEVELOPER_CFLAGS += -Wno-empty-body
36+
DEVELOPER_CFLAGS += -Wno-missing-field-initializers
37+
DEVELOPER_CFLAGS += -Wno-sign-compare
38+
DEVELOPER_CFLAGS += -Wno-unused-parameter
3939
endif
4040
endif
4141

4242
# uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
4343
# not worth fixing since newer compilers correctly stop complaining
4444
ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
4545
ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
46-
CFLAGS += -Wno-uninitialized
46+
DEVELOPER_CFLAGS += -Wno-uninitialized
4747
endif
4848
endif

0 commit comments

Comments
 (0)