Allow building without shared library.

This commit is contained in:
Roger A. Light 2018-10-07 00:56:42 +01:00
parent e492a61cd8
commit e5eb03b2e6
3 changed files with 35 additions and 6 deletions

View File

@ -2,7 +2,19 @@ include ../config.mk
.PHONY: all install uninstall reallyclean clean static static_pub static_sub
all : mosquitto_pub mosquitto_sub
ifeq ($(WITH_SHARED_LIBRARIES),yes)
SHARED_DEP:=../lib/libmosquitto.so.${SOVERSION}
endif
ifeq ($(WITH_SHARED_LIBRARIES),yes)
ALL_DEPS:= mosquitto_pub mosquitto_sub
else
ifeq ($(WITH_STATIC_LIBRARIES),yes)
ALL_DEPS:= static_pub static_sub
endif
endif
all : ${ALL_DEPS}
static : static_pub static_sub
# This makes mosquitto_pub/sub versions that are statically linked with
@ -20,13 +32,13 @@ mosquitto_pub : pub_client.o client_shared.o
mosquitto_sub : sub_client.o sub_client_output.o client_shared.o
${CROSS_COMPILE}${CC} $^ -o $@ ${CLIENT_LDFLAGS}
pub_client.o : pub_client.c ../lib/libmosquitto.so.${SOVERSION}
pub_client.o : pub_client.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}
sub_client.o : sub_client.c ../lib/libmosquitto.so.${SOVERSION}
sub_client.o : sub_client.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}
sub_client_output.o : sub_client_output.c ../lib/libmosquitto.so.${SOVERSION}
sub_client_output.o : sub_client_output.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}
client_shared.o : client_shared.c client_shared.h

View File

@ -86,6 +86,9 @@ WITH_STRIP:=no
# Build static libraries
WITH_STATIC_LIBRARIES:=no
# Build shared libraries
WITH_SHARED_LIBRARIES:=yes
# Build with async dns lookup support for bridges (temporary). Requires glibc.
#WITH_ADNS:=yes
@ -146,7 +149,10 @@ ifeq ($(UNAME),Linux)
LIB_LIBS:=$(LIB_LIBS) -lrt
endif
CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib ../lib/libmosquitto.so.${SOVERSION}
CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib
ifeq ($(WITH_SHARED_LIBRARIES),yes)
CLIENT_LDFLAGS:=${CLIENT_LDFLAGS} ../lib/libmosquitto.so.${SOVERSION}
endif
ifeq ($(UNAME),SunOS)
ifeq ($(CC),cc)

View File

@ -38,19 +38,28 @@ MOSQ_OBJS=mosquitto.o \
util_mosq.o \
will_mosq.o
ALL_DEPS=libmosquitto.so.${SOVERSION}
ALL_DEPS:=
ifeq ($(WITH_SHARED_LIBRARIES),yes)
ALL_DEPS+=libmosquitto.so.${SOVERSION}
endif
ifeq ($(WITH_STATIC_LIBRARIES),yes)
ALL_DEPS+=libmosquitto.a
endif
all : ${ALL_DEPS}
ifeq ($(WITH_SHARED_LIBRARIES),yes)
$(MAKE) -C cpp
endif
install : all
$(INSTALL) -d "${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/"
ifeq ($(WITH_SHARED_LIBRARIES),yes)
$(INSTALL) ${STRIP_OPTS} libmosquitto.so.${SOVERSION} "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so.${SOVERSION}"
ln -sf libmosquitto.so.${SOVERSION} "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so"
endif
ifeq ($(WITH_STATIC_LIBRARIES),yes)
$(INSTALL) libmosquitto.a "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.a"
${CROSS_COMPILE}${STRIP} -g --strip-unneeded "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.a"
@ -60,7 +69,9 @@ endif
$(INSTALL) -d "${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/pkgconfig"
$(INSTALL) -m644 ../libmosquitto.pc.in "${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/pkgconfig/libmosquitto.pc"
sed -i -e "s#@CMAKE_INSTALL_PREFIX@#$(prefix)#" -e "s#@VERSION@#$(VERSION)#" "${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/pkgconfig/libmosquitto.pc"
ifeq ($(WITH_SHARED_LIBRARIES),yes)
$(MAKE) -C cpp install
endif
uninstall :
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so.${SOVERSION}"