radare2/libr/rules.mk
whitequark 0f97fdd228 Fix numerous issues with pkgconfig files.
* Modifications like adding @SSL_CFLAGS@ to .pc.acr files that
    would be overwritten by `make pkgcfg` have been moved to
    Makefiles proper.
  * Missing .pc.acr files for libraries r_egg and r_crypto were
    added to the tree as well as the configure script.
  * Instead of explicitly listing every -lr_* library in every
    .pc file in the Libs: section, r_* libraries are now listed
    in the Requires: section, which ensures that flags get
    transitively propagated. This gets rid of the MAGICSED hack.
2018-01-11 23:09:22 +01:00

132 lines
3.3 KiB
Makefile

ifeq ($(_INCLUDE_RULES_MK_),)
_INCLUDE_RULES_MK_=
-include $(LTOP)/config.mk
-include $(LTOP)/../mk/compiler.mk
ifeq ($(DEBUG),1)
export NOSTRIP=1
CFLAGS+=-g
LINK+=-g
endif
LIBR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
ifeq (${LIBR},)
ifeq ($(R2DIR),)
$(error R2DIRis not defined)
else
LIBR:=$(R2DIR)/libr
endif
endif
ALL?=
CFLAGS+=-I$(LIBR)
CFLAGS+=-I$(LIBR)/include
LINK+=$(addprefix -L../,$(subst r_,,$(BINDEPS)))
LINK+=$(addprefix -l,$(BINDEPS))
SRC=$(subst .o,.c,$(OBJ))
BEXE=$(BIN)$(EXT_EXE)
ifeq ($(USE_RPATH),1)
LINK+=-Wl,-rpath "${LIBDIR}"
endif
ifeq (${OSTYPE},gnulinux)
ifeq (${HAVE_LIBVERSION},1)
LIBNAME=${LDFLAGS_SONAME}${LIBSO}.${LIBVERSION}
else
LIBNAME=${LDFLAGS_SONAME}${LIBSO}
endif
else
ifeq (${OSTYPE},darwin)
ifeq (${HAVE_LIBVERSION},1)
LIBNAME=${LDFLAGS_SONAME}${LIB}.${LIBVERSION}.${EXT_SO}
else
LIBNAME=${LDFLAGS_SONAME}${LIB}.${EXT_SO}
endif
else
LIBNAME=${LDFLAGS_SONAME}${LIBSO}
endif
endif
ifeq (${OSTYPE},haiku)
LINK+=-lnetwork
endif
ifneq ($(EXTRA_PRE),)
all: $(EXTRA_PRE)
$(MAKE) all2
all2: ${LIBSO} ${LIBAR} ${EXTRA_TARGETS}
else
all: ${LIBSO} ${LIBAR} ${EXTRA_TARGETS}
endif
ifneq ($(SILENT),)
@-if [ -f p/Makefile ]; then (cd p && ${MAKE}) ; fi
else
@-if [ -f p/Makefile ] ; then (echo "DIR ${NAME}/p"; cd p && ${MAKE}) ; fi
endif
ifeq ($(WITHPIC),1)
$(LIBSO): $(EXTRA_TARGETS) ${WFD} ${OBJS} ${SHARED_OBJ}
@for a in ${OBJS} ${SHARED_OBJ} ${SRC}; do \
do=0 ; [ ! -e ${LIBSO} ] && do=1 ; \
test $$a -nt ${LIBSO} && do=1 ; \
if [ $$do = 1 ]; then \
[ -n "${SILENT}" ] && \
echo "LD $(LIBSO)" || \
echo "\"${CC_LIB} ${LIBNAME} ${OBJS} ${SHARED_OBJ} ${LINK} ${LDFLAGS}\"" ; \
${CC_LIB} ${LIBNAME} ${CFLAGS} ${OBJS} ${SHARED_OBJ} ${LINK} ${LDFLAGS} || exit 1; \
[ -f "$(LIBR)/stripsyms.sh" ] && sh $(LIBR)/stripsyms.sh ${LIBSO} ${NAME} ; \
break ; \
fi ; done
else
${LIBSO}: ;
endif
ifeq ($(WITHNONPIC),1)
$(LIBAR): ${OBJS}
ifneq ($(SILENT),)
echo "CC_AR $(LIBAR)"
endif
rm -f $(LIBAR)
${CC_AR} ${OBJS} ${SHARED_OBJ}
${RANLIB} $(LIBAR)
else
$(LIBAR): ;
endif
pkgcfg:
@echo Generating pkgconfig stub for ${NAME}
@echo 'prefix=@PREFIX@' > ../../pkgcfg/${NAME}.pc.acr
@echo 'exec_prefix=$${prefix}' >> ../../pkgcfg/${NAME}.pc.acr
@echo 'libdir=@LIBDIR@' >> ../../pkgcfg/${NAME}.pc.acr
@echo 'includedir=$${prefix}/include' >> ../../pkgcfg/${NAME}.pc.acr
@echo >> ../../pkgcfg/${NAME}.pc.acr
@echo 'Name: ${NAME}' >> ../../pkgcfg/${NAME}.pc.acr
@echo 'Description: radare foundation libraries' >> ../../pkgcfg/${NAME}.pc.acr
@echo 'Version: @VERSION@' >> ../../pkgcfg/${NAME}.pc.acr
@echo 'Requires: $(filter r_%,${DEPS})' >> ../../pkgcfg/${NAME}.pc.acr
@if [ "${NAME}" = "libr" ]; then NAME=''; else NAME=${NAME}; fi ;\
echo 'Libs: -L$${libdir} -l${NAME} $(filter-out r_%,${DEPS}) ${PCLIBS}' >> ../../pkgcfg/${NAME}.pc.acr
@echo 'Cflags: -I$${includedir}/libr ${PCCFLAGS}' >> ../../pkgcfg/${NAME}.pc.acr
clean:: ${EXTRA_CLEAN}
-rm -f *.${EXT_EXE} *.${EXT_SO} *.${EXT_AR} *.d */*.d */*/*.d */*/*/*.d
-rm -f ${LIBSO} ${LIBAR} ${OBJS} ${BIN} *.exe a.out
-@if [ -e p/Makefile ]; then (cd p && ${MAKE} clean) ; fi
@true
mrproper: clean
-@if [ -e p/Makefile ]; then (cd p && ${MAKE} mrproper) ; fi
-rm -f *.d
@true
.PHONY: all install pkgcfg clean deinstall uninstall echodir
# autodetect dependencies object
-include $(OBJS:.o=.d)
endif