Commit 76e23395 authored by Marat Safin's avatar Marat Safin

make osx support

parent c97d0ffc
......@@ -44,6 +44,17 @@ UNAME := $(shell uname -s)
ifeq ($(UNAME), Darwin)
SONAME_FLAG = -install_name
SHARED_FLAG = -dynamiclib
SOFILE = lib${PROJECT}.dylib
SOVERSIONFILE = lib${PROJECT}.${SOVERSION}.dylib
SOMAJORFILE = lib${PROJECT}.${SOMAJOR}.dylib
BUILDSOMAJORFILE = ${LIBDIR}/${SOMAJORFILE}
PLATFORMFLAGS = -current_version ${SOVERSION} -compatibility_version ${SOMAJOR}
else
SOFILE = lib${PROJECT}.so
SOVERSIONFILE = ${SOFILE}.${SOVERSION}
SOMAJORFILE = ${SOFILE}.${SOMAJOR}
BUILDSOMAJORFILE = ${SOMAJORFILE}
PLATFORMFLAGS =
endif
all: ${PROJECTNV} ${BUILDDIR}/${PROJECT}.pc po
......@@ -60,10 +71,11 @@ all: ${PROJECTNV} ${BUILDDIR}/${PROJECT}.pc po
options:
@echo ${PROJECTNV} build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "DFLAGS = ${DFLAGS}"
@echo "CC = ${CC}"
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "DFLAGS = ${DFLAGS}"
@echo "CC = ${CC}"
@echo "PLATFORMFLAGS = ${PLATFORMFLAGS}"
# generated files
......@@ -115,16 +127,16 @@ ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.a: ${OBJECTS}
@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
$(QUIET)${AR} rcs $@ ${OBJECTS}
${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}: ${OBJECTS}
${BUILDDIR_RELEASE}/${BINDIR}/${SOVERSIONFILE}: ${OBJECTS}
$(call colorecho,LD,$@)
@mkdir -p ${BUILDDIR_RELEASE}/${BINDIR}
$(QUIET)${CC} -Wl,${SONAME_FLAG},lib${PROJECT}.so.${SOMAJOR} \
${SHARED_FLAG} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
$(QUIET)${CC} -Wl,${SONAME_FLAG},${BUILDSOMAJORFILE} \
${SHARED_FLAG} ${PLATFORMFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
${PROJECT}: static shared
${PROJECTNV}: ${PROJECT}
static: ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.a
shared: ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}
shared: ${BUILDDIR_RELEASE}/${BINDIR}/${SOVERSIONFILE}
release: ${PROJECT}
# debug build
......@@ -146,14 +158,14 @@ ${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.a: ${OBJECTS_DEBUG}
@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
$(QUIET)${AR} rcs $@ ${OBJECTS_DEBUG}
${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}: ${OBJECTS_DEBUG}
${BUILDDIR_DEBUG}/${BINDIR}/${SOVERSIONFILE}: ${OBJECTS_DEBUG}
$(call colorecho,LD,$@)
@mkdir -p ${BUILDDIR_DEBUG}/${BINDIR}
$(QUIET)${CC} -Wl,${SONAME_FLAG},lib${PROJECT}.so.${SOMAJOR} ${SHARED_FLAG} ${LDFLAGS} -o $@ ${OBJECTS_DEBUG} ${LIBS}
$(QUIET)${CC} -Wl,${SONAME_FLAG},${BUILDSOMAJORFILE} ${SHARED_FLAG} ${PLATFORMFLAGS} ${LDFLAGS} -o $@ ${OBJECTS_DEBUG} ${LIBS}
${PROJECT}-debug: \
${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.a \
${BUILDDIR_DEBUG}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}
${BUILDDIR_DEBUG}/${BINDIR}/${SOVERSIONFILE}
debug: ${PROJECT}-debug
# gcov build
......@@ -175,11 +187,11 @@ ${BUILDDIR_GCOV}/${BINDIR}/lib${PROJECT}.a: ${OBJECTS_GCOV}
@mkdir -p ${BUILDDIR_GCOV}/${BINDIR}
$(QUIET)${AR} rcs $@ ${OBJECTS_GCOV}
${BUILDDIR_GCOV}/${BINDIR}/lib${PROJECT}.so.${SOVERSION}: ${OBJECTS_GCOV}
${BUILDDIR_GCOV}/${BINDIR}/${SOVERSIONFILE}: ${OBJECTS_GCOV}
$(call colorecho,LD,$@)
@mkdir -p ${BUILDDIR_GCOV}/${BINDIR}
$(QUIET)${CC} -Wl,${SONAME_FLAG},lib${PROJECT}.so.${SOMAJOR} ${SHARED_FLAG} \
${GCOV_LDFLAGS} -o $@ ${OBJECTS_GCOV} ${LIBS}
$(QUIET)${CC} -Wl,${SONAME_FLAG},${BUILDSOMAJORFILE} ${SHARED_FLAG} \
${PLATFORMFLAGS} ${GCOV_LDFLAGS} -o $@ ${OBJECTS_GCOV} ${LIBS}
${PROJECT}-gcov: ${BUILDDIR_GCOV}/${BINDIR}/lib${PROJECT}.a
gcov: ${PROJECT}-gcov
......@@ -249,11 +261,11 @@ install-static: static
install-shared: shared
$(call colorecho,INSTALL,"Install shared library")
$(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}
$(QUIET)install -m 644 ${BUILDDIR_RELEASE}/${BINDIR}/lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}
$(QUIET)ln -sf lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}/lib${PROJECT}.so.${SOMAJOR} || \
echo "Failed to create lib${PROJECT}.so.${SOMAJOR}. Please check if it exists and points to the correct version of lib${PROJECT}.so."
$(QUIET)ln -sf lib${PROJECT}.so.${SOVERSION} ${DESTDIR}${LIBDIR}/lib${PROJECT}.so || \
echo "Failed to create lib${PROJECT}.so. Please check if it exists and points to the correct version of lib${PROJECT}.so."
$(QUIET)install -m 644 ${BUILDDIR_RELEASE}/${BINDIR}/${SOVERSIONFILE} ${DESTDIR}${LIBDIR}
$(QUIET)ln -sf ${SOVERSIONFILE} ${DESTDIR}${LIBDIR}/${SOMAJORFILE} || \
echo "Failed to create ${SOMAJORFILE}. Please check if it exists and points to the correct version of ${SOFILE}."
$(QUIET)ln -sf ${SOVERSIONFILE} ${DESTDIR}${LIBDIR}/${SOFILE} || \
echo "Failed to create ${SOFILE}. Please check if it exists and points to the correct version of ${SOFILE}."
install-headers: ${PROJECTNV}/version.h ${BUILDDIR}/${PROJECT}.pc
$(call colorecho,INSTALL,"Install pkg-config file")
......@@ -272,8 +284,8 @@ install: install-po install-static install-shared install-headers
uninstall: uninstall-headers
$(call colorecho,UNINSTALL,"Remove library files")
$(QUIET)rm -f ${LIBDIR}/lib${PROJECT}.a ${LIBDIR}/lib${PROJECT}.so.${SOVERSION} \
${LIBDIR}/lib${PROJECT}.so.${SOMAJOR} ${LIBDIR}/lib${PROJECT}.so
$(QUIET)rm -f ${LIBDIR}/lib${PROJECT}.a ${LIBDIR}/${SOVERSIONFILE} \
${LIBDIR}/${SOMAJORFILE} ${LIBDIR}/${SOFILE}
$(QUIET)${MAKE} -C po uninstall
uninstall-headers:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment