Skip to content

Commit 2253788

Browse files
committed
Add STRIP_DEBUG_INFO variable to allow omitting strip during build phase
For example, Arch Linux strips debug information after build during the package creation and producing separate debug info files during the build interferes with the Arch tooling.
1 parent eac807a commit 2253788

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ WITH_NVCGO ?= yes
2121
WITH_LIBELF ?= no
2222
WITH_TIRPC ?= no
2323
WITH_SECCOMP ?= yes
24+
STRIP_DEBUG_INFO ?= yes
2425

2526
##### Global definitions #####
2627

@@ -219,22 +220,28 @@ $(BIN_OBJS): %.o: %.c | shared
219220
-include $(DEPENDENCIES)
220221

221222
$(LIB_SHARED): $(LIB_OBJS)
222-
$(MKDIR) -p $(DEBUG_DIR)
223223
$(CC) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(LIB_LDFLAGS) $(OUTPUT_OPTION) $^ $(LIB_SCRIPT) $(LIB_LDLIBS)
224+
ifeq ($(STRIP_DEBUG_INFO), yes)
225+
$(MKDIR) -p $(DEBUG_DIR)
224226
$(OBJCPY) --only-keep-debug $@ $(LIB_SONAME)
225227
$(OBJCPY) --add-gnu-debuglink=$(LIB_SONAME) $@
226228
$(MV) $(LIB_SONAME) $(DEBUG_DIR)
227229
$(STRIP) --strip-unneeded -R .comment $@
230+
endif
228231

229232
$(LIB_STATIC_OBJ): $(LIB_OBJS)
230233
# FIXME Handle user-defined LDFLAGS and LDLIBS
231234
$(LD) -d -r --exclude-libs ALL -L$(DEPS_DIR)$(libdir) $(OUTPUT_OPTION) $^ $(LIB_LDLIBS_STATIC)
235+
ifeq ($(STRIP_DEBUG_INFO), yes)
232236
$(OBJCPY) --localize-hidden $@
233237
$(STRIP) --strip-unneeded -R .comment $@
238+
endif
234239

235240
$(BIN_NAME): $(BIN_OBJS)
236241
$(CC) $(BIN_CFLAGS) $(BIN_CPPFLAGS) $(BIN_LDFLAGS) $(OUTPUT_OPTION) $^ $(BIN_SCRIPT) $(BIN_LDLIBS)
242+
ifeq ($(STRIP_DEBUG_INFO), yes)
237243
$(STRIP) --strip-unneeded -R .comment $@
244+
endif
238245

239246
##### Public rules #####
240247

@@ -267,7 +274,7 @@ ifeq ($(WITH_TIRPC), yes)
267274
endif
268275

269276
install: all
270-
$(INSTALL) -d -m 755 $(addprefix $(DESTDIR),$(includedir) $(bindir) $(libdir) $(docdir) $(libdbgdir) $(pkgconfdir))
277+
$(INSTALL) -d -m 755 $(addprefix $(DESTDIR),$(includedir) $(bindir) $(libdir) $(docdir) $(pkgconfdir))
271278
# Install header files
272279
$(INSTALL) -m 644 $(LIB_INCS) $(DESTDIR)$(includedir)
273280
# Install library files
@@ -280,7 +287,10 @@ ifeq ($(WITH_NVCGO), yes)
280287
endif
281288
$(LDCONFIG) -n $(DESTDIR)$(libdir)
282289
# Install debugging symbols
290+
ifeq ($(STRIP_DEBUG_INFO), yes)
291+
$(INSTALL) -d -m 755 $(addprefix $(DESTDIR),$(libdbgdir))
283292
$(INSTALL) -m 644 $(DEBUG_DIR)/$(LIB_SONAME) $(DESTDIR)$(libdbgdir)
293+
endif
284294
# Install configuration files
285295
$(MAKE_DIR)/$(LIB_PKGCFG).in "$(strip $(VERSION))" "$(strip $(LIB_LDLIBS_SHARED))" > $(DESTDIR)$(pkgconfdir)/$(LIB_PKGCFG)
286296
# Install binary files
@@ -298,7 +308,9 @@ ifeq ($(WITH_NVCGO), yes)
298308
$(RM) $(addprefix $(DESTDIR)$(libdir)/,$(LIBGO_SHARED) $(LIBGO_SONAME) $(LIBGO_SYMLINK))
299309
endif
300310
# Uninstall debugging symbols
311+
ifeq ($(STRIP_DEBUG_INFO), yes)
301312
$(RM) $(DESTDIR)$(libdbgdir)/$(LIB_SONAME)
313+
endif
302314
# Uninstall configuration files
303315
$(RM) $(DESTDIR)$(pkgconfdir)/$(LIB_PKGCFG)
304316
# Uninstall binary files

0 commit comments

Comments
 (0)