mirror of
https://github.com/vale981/spectrwm
synced 2025-03-04 17:31:40 -05:00
linux: Enable PIE
PIE (position-independent executables) is a security feature that has been made reasonably cheap by recent improvements in GCC; as a result, more and more Linux distributions are pushing for its adoption. Unfortunately, PIE and PIC are not compatible, so we have to manage the CFLAGS and LDFLAGS used to compile the library and the executable indipendently.
This commit is contained in:
parent
2c2034e3bf
commit
092e5c269f
1 changed files with 9 additions and 5 deletions
|
@ -17,27 +17,31 @@ ifneq ("${BUILDVERSION}", "")
|
|||
MAINT_CPPFLAGS += -DSPECTRWM_BUILDSTR=\"$(BUILDVERSION)\"
|
||||
endif
|
||||
|
||||
BIN_CFLAGS = -fPIE
|
||||
BIN_LDFLAGS = -fPIE -pie
|
||||
BIN_CPPFLAGS = $(shell pkg-config --cflags x11 x11-xcb xcb-icccm xcb-keysyms xcb-randr xcb-util xcb-xtest xcursor xft)
|
||||
BIN_LDLIBS = $(shell pkg-config --libs x11 x11-xcb xcb-icccm xcb-keysyms xcb-randr xcb-util xcb-xtest xcursor xft)
|
||||
LIB_CFLAGS = -fPIC
|
||||
LIB_LDFLAGS = -fPIC -shared
|
||||
LIB_CPPFLAGS = $(shell pkg-config --cflags x11)
|
||||
LIB_LDLIBS = $(shell pkg-config --libs x11) -ldl
|
||||
|
||||
all: spectrwm libswmhack.so.$(LIBVERSION)
|
||||
|
||||
spectrwm: spectrwm.o linux.o
|
||||
$(CC) $(MAINT_LDFLAGS) $(LDFLAGS) -o $@ $+ $(BIN_LDLIBS) $(LDLIBS)
|
||||
$(CC) $(MAINT_LDFLAGS) $(BIN_LDFLAGS) $(LDFLAGS) -o $@ $+ $(BIN_LDLIBS) $(LDLIBS)
|
||||
|
||||
spectrwm.o: ../spectrwm.c ../version.h tree.h util.h
|
||||
$(CC) $(MAINT_CFLAGS) $(CFLAGS) $(MAINT_CPPFLAGS) $(BIN_CPPFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
$(CC) $(MAINT_CFLAGS) $(BIN_CFLAGS) $(CFLAGS) $(MAINT_CPPFLAGS) $(BIN_CPPFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
||||
linux.o: linux.c util.h
|
||||
$(CC) $(MAINT_CFLAGS) $(CFLAGS) $(MAINT_CPPFLAGS) $(BIN_CPPFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
$(CC) $(MAINT_CFLAGS) $(BIN_CFLAGS) $(CFLAGS) $(MAINT_CPPFLAGS) $(BIN_CPPFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
||||
libswmhack.so.$(LIBVERSION): swm_hack.so
|
||||
$(CC) $(MAINT_LDFLAGS) $(LDFLAGS) -Wl,-soname,$@ -shared -fPIC -o $@ $+ $(LIB_LDLIBS) $(LDLIBS)
|
||||
$(CC) $(MAINT_LDFLAGS) $(LIB_LDFLAGS) $(LDFLAGS) -Wl,-soname,$@ -o $@ $+ $(LIB_LDLIBS) $(LDLIBS)
|
||||
|
||||
swm_hack.so: ../lib/swm_hack.c
|
||||
$(CC) $(MAINT_CFLAGS) $(CFLAGS) $(MAINT_CPPFLAGS) $(LIB_CPPFLAGS) $(CPPFLAGS) -fPIC -c -o $@ $<
|
||||
$(CC) $(MAINT_CFLAGS) $(LIB_CFLAGS) $(CFLAGS) $(MAINT_CPPFLAGS) $(LIB_CPPFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f spectrwm *.o libswmhack.so.* *.so
|
||||
|
|
Loading…
Add table
Reference in a new issue