build: harden and make it possible to build with -fPIE
This commit is contained in:
parent
30c3a8d70f
commit
f395468612
@ -2,7 +2,9 @@ CC=@CC@
|
|||||||
CXX=@CXX@
|
CXX=@CXX@
|
||||||
|
|
||||||
CFLAGS=@CFLAGS@
|
CFLAGS=@CFLAGS@
|
||||||
CFLAGS+=-fPIC -Wall -Wformat=2 -Wstrict-prototypes -Wshadow -D_GNU_SOURCE
|
CFLAGS+=-Wall -Wformat=2 -Wstrict-prototypes -Wshadow -D_GNU_SOURCE
|
||||||
|
CXXFLAGS=@CXXFLAGS@
|
||||||
|
CXXFLAGS+=-Wall -Wformat=2 -Wstrict-prototypes -Wshadow -D_GNU_SOURCE
|
||||||
|
|
||||||
LEX=@LEX@
|
LEX=@LEX@
|
||||||
YACC=@YACC@
|
YACC=@YACC@
|
||||||
|
@ -24,7 +24,7 @@ INCLUDES=-I../include `nss-config --cflags` `nspr-config --cflags` \
|
|||||||
`xml2-config --cflags`
|
`xml2-config --cflags`
|
||||||
|
|
||||||
# nss sucks in way too much stuff
|
# nss sucks in way too much stuff
|
||||||
LIBS+=-lnss3 `xml2-config --libs`
|
LIBS+=-lnss3 `xml2-config --libs` -Wl,-z,now
|
||||||
|
|
||||||
TARGETS=${TARGET}
|
TARGETS=${TARGET}
|
||||||
|
|
||||||
@ -40,7 +40,16 @@ fence_xvm: ${TARGET}
|
|||||||
ln -snf $^ $@
|
ln -snf $^ $@
|
||||||
|
|
||||||
fence_virt: ${fence_virt_SOURCES:.c=.o}
|
fence_virt: ${fence_virt_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -L../common -lfence_virt
|
$(CC) $(CFLAGS) -o $@ $^ -shared $(LIBS) -L../common -lfence_virt
|
||||||
|
|
||||||
|
mcast.o: mcast.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
options.o: options.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
serial.o: serial.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
||||||
|
@ -24,6 +24,18 @@ all: ${TARGETS}
|
|||||||
libfence_virt.a: ${libfence_virt_a_SOURCE:.c=.o}
|
libfence_virt.a: ${libfence_virt_a_SOURCE:.c=.o}
|
||||||
ar rc $@ $^
|
ar rc $@ $^
|
||||||
|
|
||||||
|
fdops.o: fdops.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
ip_lookup.o: ip_lookup.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
mcast.o: mcast.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
tcp.o: tcp.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ config.c: y.tab.h config.l
|
|||||||
$(LEX) -oconfig.c config.l
|
$(LEX) -oconfig.c config.l
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
$(CC) $(CFLAGS) -fPIE -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f ${TARGETS} *~ *.o testprog config.tab.c config.tab.h config.c
|
rm -f ${TARGETS} *~ *.o testprog config.tab.c config.tab.h config.c
|
||||||
|
@ -32,7 +32,7 @@ NSS_LIBS=-lnss3
|
|||||||
XML_LIBS=`xml2-config --libs`
|
XML_LIBS=`xml2-config --libs`
|
||||||
INCLUDES=-I../include `nss-config --cflags` `nspr-config --cflags` `xml2-config --cflags`
|
INCLUDES=-I../include `nss-config --cflags` `nspr-config --cflags` `xml2-config --cflags`
|
||||||
|
|
||||||
LIBS+=-L../common -lfence_virt -Wl,-wrap,syslog,-wrap,closelog -lpthread -luuid
|
LIBS+=-L../common -lfence_virt -Wl,-z,now,-wrap,syslog,-wrap,closelog -lpthread -luuid
|
||||||
|
|
||||||
MODULE_PATH=${libdir}/${PACKAGE_NAME}
|
MODULE_PATH=${libdir}/${PACKAGE_NAME}
|
||||||
|
|
||||||
@ -159,40 +159,49 @@ endif
|
|||||||
all: ${TARGETS} ${MODULES}
|
all: ${TARGETS} ${MODULES}
|
||||||
|
|
||||||
fence_virtd: ${fence_virtd_SOURCES:.c=.o} ${fence_virtd_cxx_SOURCES:.cpp=.opp}
|
fence_virtd: ${fence_virtd_SOURCES:.c=.o} ${fence_virtd_cxx_SOURCES:.cpp=.opp}
|
||||||
$(CXX) -o $@ $^ $(MAIN_LIBS) $(LIBS)
|
$(CXX) $(CXXFLAGS) -o $@ $^ $(MAIN_LIBS) $(LIBS)
|
||||||
|
|
||||||
multicast.so: ${multicast_so_SOURCES:.c=.o}
|
multicast.so: ${multicast_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
|
||||||
|
|
||||||
libvirt.so: ${libvirt_so_SOURCES:.c=.o}
|
libvirt.so: ${libvirt_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS) $(UUID_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS) $(UUID_LIBS)
|
||||||
|
|
||||||
libvirt-qmf.so: ${libvirt_qmf_so_SOURCES:.c=.o} ${libvirt_qmf_cxx_so_SOURCES:.cpp=.opp}
|
libvirt-qmf.so: ${libvirt_qmf_so_SOURCES:.c=.o} ${libvirt_qmf_cxx_so_SOURCES:.cpp=.opp}
|
||||||
$(CXX) -o $@ $^ $(LIBS) -shared $(VIRT_QPID)
|
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) -shared $(VIRT_QPID)
|
||||||
|
|
||||||
pm-fence.so: ${pm_fence_so_SOURCES:.c=.o}
|
pm-fence.so: ${pm_fence_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(PACEMAKER_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(PACEMAKER_LIBS)
|
||||||
|
|
||||||
cpg.so: ${cpg_so_SOURCES:.c=.o}
|
cpg.so: ${cpg_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS) $(UUID_LIBS) $(XML_LIBS) $(COROSYNC_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS) $(UUID_LIBS) $(XML_LIBS) $(COROSYNC_LIBS)
|
||||||
|
|
||||||
null.so: ${null_so_SOURCES:.c=.o}
|
null.so: ${null_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared
|
||||||
|
|
||||||
serial.so: ${serial_so_SOURCES:.c=.o}
|
serial.so: ${serial_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS) $(UUID_LIBS) $(XML_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS) $(UUID_LIBS) $(XML_LIBS)
|
||||||
|
|
||||||
tcp.so: ${tcp_so_SOURCES:.c=.o}
|
tcp.so: ${tcp_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
|
||||||
|
|
||||||
vsock.so: ${vsock_so_SOURCES:.c=.o}
|
vsock.so: ${vsock_so_SOURCES:.c=.o}
|
||||||
$(CC) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
|
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
|
||||||
|
|
||||||
|
cpg-virt.o: cpg-virt.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
virt.o: virt.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
|
virt-serial.o: virt-serial.c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
%.opp: %.cpp
|
%.opp: %.cpp
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
|
$(CXX) $(CXXFLAGS) -c -o $@ $^ $(INCLUDES)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
if [ ! -d ${DESTDIR}/${sbindir} ]; then \
|
if [ ! -d ${DESTDIR}/${sbindir} ]; then \
|
||||||
|
Loading…
Reference in New Issue
Block a user