radare2/libr/rules.mk

149 lines
3.6 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
WITH_LIBS?=1
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?=
CFLAGS:=-I$(LIBR) -I$(LIBR)/include $(CFLAGS)
-include $(SHLR)/sdb.mk
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)
2021-06-17 15:32:57 +00:00
ifeq ($(OSTYPE),android)
2021-06-17 15:36:04 +00:00
LINK+=-Wl,--enable-new-dtags
2021-06-17 15:32:57 +00:00
endif
2021-06-17 15:36:04 +00:00
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
ifeq (${OSTYPE},solaris)
LINK+=-lproc
endif
ifeq ($(EXTRA_PRE),)
all: $(LIBSO) ${LIBAR} ${EXTRA_TARGETS}
else
all: $(EXTRA_PRE)
$(MAKE) all2
all2: ${LIBSO} ${LIBAR}
$(MAKE) ${EXTRA_TARGETS}
endif
ifneq ($(SILENT),)
@-if [ -f p/Makefile ]; then ${MAKE} -C p ; fi
@-if [ -f d/Makefile ]; then ${MAKE} -C d ; fi
else
@-if [ -f p/Makefile ] ; then (echo "DIR ${NAME}/p"; ${MAKE} -C p) ; fi
@-if [ -f d/Makefile ] ; then (echo "DIR ${NAME}/d"; ${MAKE} -C d) ; fi
endif
prelib-build: $(EXTRA_TARGETS)
$(MAKE) $(OBJS)
ifeq ($(WITH_LIBS),1)
$(LIBSO): prelib-build ${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 ($(WITH_LIBR),1)
$(LIBAR): prelib-build
2019-08-01 02:39:40 +00:00
@[ "${SILENT}" = 1 ] && echo "CC_AR $(LIBAR)" || true
rm -f $(LIBAR)
${CC_AR} ${OBJS} ${SHARED_OBJ}
${RANLIB} $(LIBAR)
else
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_%,${R2DEPS})' >> ../../pkgcfg/${NAME}.pc.acr
@if [ "${NAME}" = "libr" ]; then NAME=''; else NAME=${NAME}; fi ;\
echo 'Libs: -L$${libdir} -l${NAME} $(filter-out r_%,${R2DEPS}) ${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
.PHONY: all install pkgcfg clean deinstall uninstall echodir prelib-build
2012-10-03 23:20:00 +00:00
# autodetect dependencies object
-include $(OBJS:.o=.d)
endif