radare2/libr/rules.mk

128 lines
3.3 KiB
Makefile
Raw Normal View History

ifeq ($(_INCLUDE_RULES_MK_),)
2012-08-31 23:06:24 +00:00
_INCLUDE_RULES_MK_=
-include $(LTOP)/config.mk
-include $(LTOP)/../mk/compiler.mk
ifeq ($(DEBUG),1)
export NOSTRIP=1
CFLAGS+=-g
2016-11-29 10:52:24 +00:00
LINK+=-g
endif
2016-04-26 23:08:12 +00:00
LIBR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
2018-05-18 22:07:01 +00:00
# /libr
2016-04-26 23:08:12 +00:00
ALL?=
2017-05-26 01:07:22 +00:00
CFLAGS+=-I$(LIBR)
CFLAGS+=-I$(LIBR)/include
CFLAGS+=-fvisibility=hidden
LDFLAGS+=-fvisibility=hidden
LINK+=-fvisibility=hidden
2018-05-15 22:11:04 +00:00
# for executables (DUP)
2014-07-09 00:08:06 +00:00
LINK+=$(addprefix -L../,$(subst r_,,$(BINDEPS)))
LINK+=$(addprefix -l,$(BINDEPS))
2018-05-15 22:11:04 +00:00
SRC=$(subst .o,.c,$(OBJ))
BEXE=$(BIN)$(EXT_EXE)
ifeq ($(USE_RPATH),1)
LINK+=-Wl,-rpath "${LIBDIR}"
endif
ifeq (${OSTYPE},gnulinux)
2014-05-17 07:59:57 +00:00
ifeq (${HAVE_LIBVERSION},1)
LIBNAME=${LDFLAGS_SONAME}${LIBSO}.${LIBVERSION}
else
2014-05-17 02:27:49 +00:00
LIBNAME=${LDFLAGS_SONAME}${LIBSO}
endif
else
ifeq (${OSTYPE},darwin)
2014-05-17 02:27:49 +00:00
ifeq (${HAVE_LIBVERSION},1)
LIBNAME=${LDFLAGS_SONAME}${LIB}.${LIBVERSION}.${EXT_SO}
else
2014-05-17 02:27:49 +00:00
LIBNAME=${LDFLAGS_SONAME}${LIB}.${EXT_SO}
endif
else
LIBNAME=${LDFLAGS_SONAME}${LIBSO}
endif
endif
2013-06-05 21:58:31 +00:00
ifeq (${OSTYPE},haiku)
2014-07-09 00:08:06 +00:00
LINK+=-lnetwork
2013-06-05 21:58:31 +00:00
endif
ifneq ($(EXTRA_PRE),)
all: $(EXTRA_PRE)
$(MAKE) all2
all2: ${LIBSO} ${LIBAR} ${EXTRA_TARGETS}
else
2012-10-03 23:20:00 +00:00
all: ${LIBSO} ${LIBAR} ${EXTRA_TARGETS}
endif
ifneq ($(SILENT),)
2013-12-20 03:32:38 +00:00
@-if [ -f p/Makefile ]; then (cd p && ${MAKE}) ; fi
else
2013-12-20 03:32:38 +00:00
@-if [ -f p/Makefile ] ; then (echo "DIR ${NAME}/p"; cd p && ${MAKE}) ; fi
endif
$(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
ifeq ($(WITH_LIBR),1)
$(LIBAR): ${OBJS}
[ "${SILENT}" = 1 ] && @echo "CC_AR $(LIBAR)" || true
rm -f $(LIBAR)
${CC_AR} ${OBJS} ${SHARED_OBJ}
${RANLIB} $(LIBAR)
else
# ${LIBSO} $(LIBAR): ;
2012-10-03 23:20:00 +00:00
$(LIBAR): ;
endif
pkgcfg:
@echo Generating pkgconfig stub for ${NAME}
@echo 'prefix=@PREFIX@' > ../../pkgcfg/${NAME}.pc.acr
@echo 'exec_prefix=$${prefix}' >> ../../pkgcfg/${NAME}.pc.acr
2011-07-19 11:19:09 +00:00
@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
2011-07-19 11:19:09 +00:00
@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}
2012-10-11 11:09:33 +00:00
-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
2012-10-03 23:20:00 +00:00
.PHONY: all install pkgcfg clean deinstall uninstall echodir
# autodetect dependencies object
-include $(OBJS:.o=.d)
endif