Skip to contentSkip to conversation

fsverity-utils Makefile fixes

PATCH Superseded Jes Sorensen 3 participants 6 messages May 15, 2020 – May 20, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover fsverity-utils Makefile fixes

From: Jes Sorensen <[email protected]>

Hi,

This set goes on top of the libfsverity changes from Eric.

One deals with the Makefile not cleaning up the library when running 'make clean'.

The second removes the forced override of CFLAGS and CPPFLAGS. This really shouldn't be forced like it was, since package managers and builders should be able to specify their preferred flags.

With these applied, I am able to build an rpm of fsverity-utils which provides fsverity-utils and fsverity-utils-devel.

Should we bump the version to 1.1 or 1.0.1 or something too?

Once this is pushed to the official branch, I'll do an updated package for Fedora Rawhide and do another pull-request for the RPM code.

Cheers,
Jes

Jes Sorensen (2):
Fix Makefile to delete objects from the library on make clean Let package manager override CFLAGS and CPPFLAGS

 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 Fix Makefile to delete objects from the library on make clean

From: Jes Sorensen <[email protected]>

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 1a7be53..c5f46f4 100644
@@ -81,6 +81,7 @@ LIB_SRC         := $(wildcard lib/*.c)
 LIB_HEADERS     := $(wildcard lib/*.h) $(COMMON_HEADERS)
 STATIC_LIB_OBJ  := $(LIB_SRC:.c=.o)
 SHARED_LIB_OBJ  := $(LIB_SRC:.c=.shlib.o)
+LIB_OBJS        := $(SHARED_LIB_OBJ) $(STATIC_LIB_OBJ)
 
 # Compile static library object files
 $(STATIC_LIB_OBJ): %.o: %.c $(LIB_HEADERS) .build-config
Signature · 1 line
2.26.2
maintainer
#2 lore raw

Re: [PATCH 1/2] Fix Makefile to delete objects from the library on make clean

Quoted 13 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +0 -0
index 1a7be53..c5f46f4 100644

Makefile LIB_SRC := $(wildcard lib/*.c) · line 87

Quoted 7 lines
Makefile +1 -0
@@ -81,6 +81,7 @@ LIB_SRC         := $(wildcard lib/*.c)
 LIB_HEADERS     := $(wildcard lib/*.h) $(COMMON_HEADERS)
 STATIC_LIB_OBJ  := $(LIB_SRC:.c=.o)
 SHARED_LIB_OBJ  := $(LIB_SRC:.c=.shlib.o)
+LIB_OBJS        := $(SHARED_LIB_OBJ) $(STATIC_LIB_OBJ)
 
 # Compile static library object files
 $(STATIC_LIB_OBJ): %.o: %.c $(LIB_HEADERS) .build-config

Thanks for pointing this out. I think it would be a bit easier to just use a wildcard in the clean target, though.

Makefile +2 -2
index 1a7be53..e7fb5cf 100644
@@ -180,8 +180,8 @@ help:
 	done
 
 clean:
-	rm -f $(DEFAULT_TARGETS) $(TEST_PROGRAMS) $(LIB_OBJS) $(ALL_PROG_OBJ) \
-		.build-config
+	rm -f $(DEFAULT_TARGETS) $(TEST_PROGRAMS) \
+		lib/*.o programs/*.o .build-config
 
 FORCE:
 
#3 lore raw

PATCH 2/2 Let package manager override CFLAGS and CPPFLAGS

In reply to Jes Sorensen

From: Jes Sorensen <[email protected]>

Package managers such as RPM wants to build everything with their preferred flags, and we shouldn't hard override flags.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index c5f46f4..0c2a621 100644
@@ -32,7 +32,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \
 #### Common compiler flags.  You can add additional flags by defining CFLAGS
 #### and/or CPPFLAGS in the environment or on the 'make' command line.
 
-override CFLAGS := -O2 -Wall -Wundef				\
+CFLAGS := -O2 -Wall -Wundef				\
 	$(call cc-option,-Wdeclaration-after-statement)		\
 	$(call cc-option,-Wmissing-prototypes)			\
 	$(call cc-option,-Wstrict-prototypes)			\
@@ -40,7 +40,7 @@ override CFLAGS := -O2 -Wall -Wundef				\
 	$(call cc-option,-Wimplicit-fallthrough)		\
 	$(CFLAGS)
 
-override CPPFLAGS := -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)
+CPPFLAGS := -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)
 
 #### Other user settings
 
Signature · 1 line
2.26.2
maintainer
#4 lore raw

Re: [PATCH 2/2] Let package manager override CFLAGS and CPPFLAGS

Quoted 15 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

Package managers such as RPM wants to build everything with their preferred flags, and we shouldn't hard override flags.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +0 -0
index c5f46f4..0c2a621 100644

Makefile cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \ · line 33

Quoted 2 lines
Makefile +0 -0
@@ -32,7 +32,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \
 #### Common compiler flags.  You can add additional flags by defining CFLAGS
 #### and/or CPPFLAGS in the environment or on the 'make' command line.

The above comment needs to be updated.

Makefile override CFLAGS := -O2 -Wall -Wundef \ · line 41

Quoted 9 lines
Makefile +1 -1
-override CFLAGS := -O2 -Wall -Wundef				\
+CFLAGS := -O2 -Wall -Wundef				\
 	$(call cc-option,-Wdeclaration-after-statement)		\
 	$(call cc-option,-Wmissing-prototypes)			\
 	$(call cc-option,-Wstrict-prototypes)			\
@@ -40,7 +40,7 @@ override CFLAGS := -O2 -Wall -Wundef				\
 	$(call cc-option,-Wimplicit-fallthrough)		\
 	$(CFLAGS)

The user's $(CFLAGS) is already added at the end, so the -O2 can already be overridden, e.g. with -O0. Is your concern just that this is bad practice?

Also, did you intentionally leave $(CFLAGS) at the end, rather than remove it as might be expected?

Makefile override CFLAGS := -O2 -Wall -Wundef \ · line 43

Quoted 2 lines
Makefile +1 -1
-override CPPFLAGS := -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)
+CPPFLAGS := -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)

-D_FILE_OFFSET_BITS=64 is required for correctness. So I think this part is good as-is.

- Eric

#5 lore raw

Re: [PATCH 2/2] Let package manager override CFLAGS and CPPFLAGS

Quoted 11 lines · Eric Biggers
Quoted 10 lines · Jes Sorensen

From: Jes Sorensen <[email protected]>

Package managers such as RPM wants to build everything with their preferred flags, and we shouldn't hard override flags.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 9 lines

Makefile cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \ · line 33

Quoted 7 lines
Makefile +0 -0
index c5f46f4..0c2a621 100644
@@ -32,7 +32,7 @@ cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \
 #### Common compiler flags.  You can add additional flags by defining CFLAGS
 #### and/or CPPFLAGS in the environment or on the 'make' command line.

The above comment needs to be updated.

I'll fix that

Quoted 11 lines

Makefile override CFLAGS := -O2 -Wall -Wundef \ · line 41

Quoted 8 lines
Makefile +1 -1
-override CFLAGS := -O2 -Wall -Wundef				\
+CFLAGS := -O2 -Wall -Wundef				\
 	$(call cc-option,-Wdeclaration-after-statement)		\
 	$(call cc-option,-Wmissing-prototypes)			\
 	$(call cc-option,-Wstrict-prototypes)			\
@@ -40,7 +40,7 @@ override CFLAGS := -O2 -Wall -Wundef				\
 	$(call cc-option,-Wimplicit-fallthrough)		\
 	$(CFLAGS)

The user's $(CFLAGS) is already added at the end, so the -O2 can already be overridden, e.g. with -O0. Is your concern just that this is bad practice?

I do think it's bad practice to hard add them, we should make recommendations, but not policy. However, more importantly rpm fails the build. It uses specific CFLAGS to do debug builds, and if the binary ends up with build flags that do not match, it fails.

Quoted 2 lines

Also, did you intentionally leave $(CFLAGS) at the end, rather than remove it as might be expected?

That was an oversight, I'll fix that.

Quoted 5 lines

Makefile override CFLAGS := -O2 -Wall -Wundef \ · line 43

Quoted 2 lines
Makefile +1 -1
-override CPPFLAGS := -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)
+CPPFLAGS := -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)

-D_FILE_OFFSET_BITS=64 is required for correctness. So I think this part is good as-is.

Sounds good!

I'll send out an updated patchset shortly.

Cheers,
Jes