radare2/libr/Makefile

282 lines
9.1 KiB
Makefile
Raw Normal View History

include ../global.mk
include config.mk
include ../config-user.mk
include ../mk/platform.mk
include ../mk/${COMPILER}.mk
include ${SHLR}/zip/deps.mk
DESTDIR:=$(DESTDIR)
PREFIX?=${PWD}/../prefix
OBJCOPY?=objcopy
S=$
B=`
PWD=$(shell pwd)
include libs.mk
2012-10-03 23:20:00 +00:00
.PHONY: $(LIBS)
all:
ifneq ($(LIBS0),)
$(MAKE) $(LIBS0)
endif
ifneq ($(LIBS1),)
$(MAKE) $(LIBS1)
endif
ifneq ($(LIBS2),)
$(MAKE) $(LIBS2)
endif
ifneq ($(LIBS3),)
$(MAKE) $(LIBS3)
endif
ifneq ($(LIBS4),)
$(MAKE) $(LIBS4)
endif
ifneq ($(LIBS5),)
$(MAKE) $(LIBS5)
endif
ifneq ($(LIBS6),)
$(MAKE) $(LIBS6)
endif
ifneq ($(LIBS7),)
$(MAKE) $(LIBS7)
endif
ifeq ($(WITH_LIBR),1)
$(MAKE) libr.${EXT_AR}
$(MAKE) libr.${EXT_SO}
endif
2017-10-09 08:53:41 +00:00
ifeq ($(WITH_LIBR),1)
ifeq ($(OSTYPE),darwin)
2018-05-15 22:11:04 +00:00
MLFLAGS+=-install_name @rpath/libr2.dylib
endif
ifeq ($(OSTYPE),ios)
2018-05-15 22:11:04 +00:00
MLFLAGS+=-install_name @rpath/libr2.dylib
MLFLAGS+=-fembed-bitcode
endif
LDFLAGS+=${SSL_LDFLAGS}
# XXX version-script only works with shlib as output
#ifeq ($(OSTYPE),linux)
#PLFLAGS+=--version-script ./ld.script
#endif
2018-05-15 22:11:04 +00:00
# from env: ALFLAGS+=$(ALFLAGS)
.libr: $(wildcard */libr_*.${EXT_AR}) ../shlr/libr_shlr.${EXT_AR}
rm -rf .libr
2018-05-30 16:11:14 +00:00
mkdir -p .libr
for LIB in $^ ; do \
2018-05-15 22:11:04 +00:00
${PARTIALLD} $(ALFLAGS) $(MLFLAGS) $(PLFLAGS) -o .libr/$$(basename $${LIB} .a).o $${LIB} ; \
done
ifeq ($(OSTYPE),linux)
for LIB in .libr/* ; do $(OBJCOPY) --localize-hidden $$LIB ; done
endif
ifeq ($(OSTYPE),gnulinux)
for LIB in .libr/* ; do $(OBJCOPY) --localize-hidden $$LIB ; done
endif
ifeq ($(OSTYPE),android)
for LIB in .libr/* ; do $(OBJCOPY) --localize-hidden $$LIB ; done
endif
ifeq ($(OSTYPE),bsd)
for LIB in .libr/* ; do $(OBJCOPY) --localize-hidden $$LIB ; done
endif
_libr.${EXT_AR}: .libr
${AR} crs $@ .libr/*.o
2012-10-03 23:20:00 +00:00
.libr2: $(wildcard */libr_*.${EXT_AR}) ../shlr/libr_shlr.${EXT_AR}
rm -rf .libr2
mkdir -p .libr2
for LIB in $^ ; do \
BN=`basename $$LIB` ; \
echo $$BN ; \
mkdir -p .libr2/$$BN ; \
( cd .libr2/$$BN ; pwd ; du -hs ../../$$LIB; ar x ../../$$LIB ) ; \
done
libr.${EXT_AR}: .libr2
${AR} crs $@ .libr2/*/*.o
#libr.${EXT_AR}: .libr
# ${AR} crs $@ .libr/*.o
2018-09-26 17:03:32 +00:00
ifeq (1,$(WITH_GPL))
E+=../shlr/grub/libgrubfs.${EXT_AR}
2018-09-26 17:03:32 +00:00
endif
E+=../shlr/ar/libr_ar.${EXT_AR}
E+=../shlr/windbg/libr_windbg.${EXT_AR}
E+=../shlr/qnx/lib/libqnxr.${EXT_AR}
E+=../shlr/bochs/lib/libbochs.${EXT_AR}
#ifeq ($(COMPILER),ios-sdk)
#E+=../shlr/sdb/src/libsdb.${EXT_AR}
#endif
#ifneq ($(OSTYPE),android)
#E+=../shlr/sdb/src/libsdb.${EXT_AR}
#endif
2018-05-22 04:52:12 +00:00
ifeq ($(USE_CAPSTONE),1)
E+=$(CAPSTONE_LDFLAGS)
else
E+=../shlr/capstone/libcapstone.${EXT_AR}
endif
libr.${EXT_SO}: .libr2
$(CC) -fvisibility=hidden $(MLFLAGS) ${LINK} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -shared -dynamiclib -o libr.${EXT_SO} \
.libr2/*/*.o \
../shlr/gdb/lib/libgdbr.${EXT_AR} ../shlr/java/libr_java.${EXT_AR} \
../shlr/libr_shlr.${EXT_AR} $(E)
#libr.${EXT_SO}: .libr
# $(CC) -fvisibility=hidden $(MLFLAGS) ${LINK} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -shared -dynamiclib -o libr.${EXT_SO} \
# .libr/*.o \
# ../shlr/gdb/lib/libgdbr.${EXT_AR} ../shlr/java/libr_java.${EXT_AR} \
# ../shlr/libr_shlr.${EXT_AR} $(E)
else
# WITH_LIBR=0
libr.${EXT_SO}:
$(MAKE) libr.${EXT_SO} WITH_LIBR=1
libr.${EXT_AR}:
$(MAKE) libr.${EXT_AR} WITH_LIBR=1
endif
../shlr/libr_shlr.${EXT_AR}:
$(MAKE) -C ../shlr libr_shlr.${EXT_AR}
2012-10-03 23:20:00 +00:00
$(LIBS):
@echo "DIR $@"
@$(MAKE) -C $@
pkgcfg:
@for lib in ${LIBS}; do $(MAKE) -C $${lib} pkgcfg; done
2017-10-18 15:53:00 +00:00
$(MAKE) -C asm pkgcfg NAME=libr DEPS="r_`echo ${LIBS}|sed -e 's, , r_,g'`"
# TODO: Magically generate libr.pc.acr here using LIBS and so :)
install-pkgconfig:
${INSTALL_DIR} "${DESTDIR}${LIBDIR}/pkgconfig"
for FILE in ../pkgcfg/*.pc ; do \
rm -f "${DESTDIR}${LIBDIR}/pkgconfig/$$FILE" ; \
${INSTALL_DATA} $$FILE "${DESTDIR}${LIBDIR}/pkgconfig" ; done
install-includes:
@-rm -f "${DESTDIR}${INCLUDEDIR}/libr/sflib"
@-rm -f "${DESTDIR}${INCLUDEDIR}/libr"
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr"
(cd include && for FILE in *.h ; do ${INSTALL_DATA} $$FILE "${DESTDIR}${INCLUDEDIR}/libr" ; done)
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr/sflib"
(cd include/sflib && for DIR in * ; do \
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr/sflib/$$DIR" ; \
for FILE in $$DIR/*.h ; do \
${INSTALL_DATA} $$FILE "${DESTDIR}${INCLUDEDIR}/libr/sflib/$$FILE" ; \
2011-12-01 19:17:40 +00:00
done ; \
done)
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr/sdb"
(cd include/sdb && for FILE in * ; do \
${INSTALL_DATA} $$FILE "${DESTDIR}${INCLUDEDIR}/libr/sdb/$$FILE" ; \
2012-10-11 08:44:22 +00:00
done)
2016-07-09 21:04:38 +00:00
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr/r_util"
(cd include/r_util && for FILE in * ; do \
${INSTALL_DATA} $$FILE "${DESTDIR}${INCLUDEDIR}/libr/r_util/$$FILE" ; done)
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr/r_crypto"
(cd include/r_crypto && for FILE in * ; do \
${INSTALL_DATA} $$FILE "${DESTDIR}${INCLUDEDIR}/libr/r_crypto/$$FILE" ; done)
symstall install-symlink:
@cd .. && \
mkdir -p "${DESTDIR}${BINDIR}" \
"${DESTDIR}${INCLUDEDIR}" \
"${DESTDIR}${LIBDIR}/pkgconfig" \
"${DESTDIR}${LIBDIR}/radare2/${VERSION}" ; \
rm -rf "${DESTDIR}${INCLUDEDIR}/libr" && ln -fs "${PWD}/include" "${DESTDIR}${INCLUDEDIR}/libr" ; \
$(MAKE) install-pkgconfig-symlink ; \
2017-10-19 20:01:32 +00:00
$(foreach lib,${LIBS}, \
ln -fs "${PWD}/$(lib)/libr_$(lib).${EXT_SO}" \
"${DESTDIR}${LIBDIR}/libr_$(lib).${EXT_SO}" ; \
ln -fs "${PWD}/$(lib)/libr_$(lib).${EXT_SO}" \
"${DESTDIR}${LIBDIR}/$(call libname-version,libr_$(lib).${EXT_SO},${LIBVERSION})" ; \
ln -fs "${PWD}/$(lib)/libr_$(lib).${EXT_AR}" "${DESTDIR}${LIBDIR}/libr_$(lib).${EXT_AR}" ; \
$(foreach module,$(wildcard $(lib)/p/*.${EXT_SO}), \
ln -fs "${PWD}/$(module)" "${DESTDIR}${LIBDIR}/radare2/${VERSION}/" ; \
) \
) \
cd "${DESTDIR}${LIBDIR}/radare2" ; rm -f last ; ln -fs "${VERSION}" last
install: install-includes install-pkgconfig
# TODO :Use INSTALL_DATA_DIR instead of mkdir
# libraries
@${INSTALL_DIR} "${DESTDIR}${LIBDIR}"
@$(foreach lib,$(shell find * -type f -iname "*.${EXT_SO}" | grep -vE '^libr\.${EXT_SO}$$' | grep -v '(lib|parse)/t/' | grep lib | grep -v /bin/ | grep -v /p/), \
echo " ${DESTDIR}${LIBDIR}/$(call libpath-to-name-version,$(lib),${LIBVERSION})"; \
rm -f "${DESTDIR}${LIBDIR}/$(call libpath-to-name-version,$(lib),${LIBVERSION})"; \
${INSTALL_LIB} "$(lib)" "${DESTDIR}${LIBDIR}/$(call libpath-to-name-version,$(lib),${LIBVERSION})"; \
( cd "${DESTDIR}${LIBDIR}" ; ln -fs "$(call libpath-to-name-version,$(lib),${LIBVERSION})" "$(call libpath-to-name,$(lib))" ) ; \
)
lib=libr.$(EXT_SO) ; if [ -f "$$lib" ]; then \
${INSTALL_LIB} "$$lib" "${DESTDIR}${LIBDIR}/$$lib"; \
fi
# object archives
2017-05-09 12:25:57 +00:00
@for FILE in `find * -type f -iname "*.${EXT_AR}" | grep -v fs/p` ; do \
echo " ${DESTDIR}${LIBDIR}/$$FILE"; ${INSTALL_DATA} $$FILE "${DESTDIR}${LIBDIR}" ; done || true
# plugins
@${INSTALL_DIR} "${DESTDIR}${LIBDIR}/radare2/${VERSION}"
@for FILE in `find */p -perm -u+x -type f | grep -v exe | grep -v dll | grep ${EXT_SO}`; \
do echo " ${DESTDIR}${LIBDIR}/radare2/${VERSION}/$$FILE"; \
${INSTALL_LIB} "$$FILE" "${DESTDIR}${LIBDIR}/radare2/${VERSION}" ; done
cd "${DESTDIR}${LIBDIR}/radare2" ; ln -fs "${VERSION}" last
deinstall uninstall:
# libraries
-@for FILE in `find * | grep -e '\.${EXT_SO}$$' | grep -v 'lib/t' | grep lib` ; do \
FILE=`echo $$FILE | awk -F / '{ print $$NF; }'`; \
echo "${DESTDIR}${LIBDIR}/$$FILE" ; rm -f "${DESTDIR}${LIBDIR}/$$FILE" ; done
# object archives
2017-05-09 12:25:57 +00:00
-@for FILE in `find * | grep -e '\.${EXT_AR}$$'` ; do \
FILE=`echo $$FILE | awk -F / '{ print $$NF; }'`; \
echo "${DESTDIR}${LIBDIR}/$$FILE" ; rm -f "${DESTDIR}${LIBDIR}/$$FILE" ; done
# includes
-if [ -h "${DESTDIR}${INCLUDEDIR}/libr" ]; then \
rm -f "${DESTDIR}${INCLUDEDIR}/libr" ; \
else \
(cd include && for FILE in * ; do rm -f "${DESTDIR}${INCLUDEDIR}/libr/$$FILE" ; done) ; \
fi
# programs
-@for FILE in `find */t -perm -u+x -type f | grep 2`; do \
FILE=`echo $$FILE|awk -F / '{ print $$NF; }'`; \
echo "${DESTDIR}${BINDIR}/$$FILE" ; rm -f "${DESTDIR}${BINDIR}/$$FILE" ; done
# plugins
-@for FILE in `find */p -perm -u+x -type f`; do \
FILE="${DESTDIR}${LIBDIR}/radare2/${VERSION}/`echo $$FILE|awk -F / '{ print $$NF; }'`"; \
echo $$FILE ; rm -f $$FILE ; done
rm -rf "${DESTDIR}${LIBDIR}/radare2/${VERSION}"
rm -f "${DESTDIR}${LIBDIR}/pkgconfig/libr.pc"
rm -f "${DESTDIR}${LIBDIR}/pkgconfig/r_"*.pc
# test programs
rm -rf "${DESTDIR}${BINDIR}/libr-test"
# TODO: use for FILE in LIBS (like in binr/Makefile)
rm -rf "${DESTDIR}${INCLUDEDIR}/libr"
rm -rf "${DESTDIR}${LIBDIR}/libr_*.so.${LIBVERSION}"
rm -rf "${DESTDIR}${LIBDIR}/libr_*.so.0"
rm -rf "${DESTDIR}${LIBDIR}/libr_*.so"
2017-05-09 12:25:57 +00:00
rm -rf "${DESTDIR}${LIBDIR}/libr_*.${EXT_AR}"
rm -rf "${DESTDIR}${LIBDIR}/libr2.so"*
2017-05-09 12:25:57 +00:00
rm -rf "${DESTDIR}${LIBDIR}/libr2.${EXT_AR}"
rm -rf "${DESTDIR}${LIBDIR}/libr.so"*
2017-05-09 12:25:57 +00:00
rm -rf "${DESTDIR}${LIBDIR}/libr.${EXT_AR}"
rm -rf "${DESTDIR}${DATADIR}/doc/radare2"
@echo libr aka radare2 has been uninstalled from PREFIX=${DESTDIR}${PREFIX}
clean:
for LIB in ${LIBS}; do ( cd $${LIB} && $(MAKE) clean ); done
rm -rf .libr libr.${LIB_SO} libr.${LIB_AR}
2009-06-15 02:44:05 +00:00
2010-07-13 09:59:55 +00:00
mrproper:
2017-07-04 00:10:43 +00:00
rm -rf .libr libr.${LIB_SO} libr.${LIB_AR}
for LIB in ${LIBS}; do ( cd $${LIB} && $(MAKE) mrproper ); done
* Initial import of the 'configure-plugins' script - accepts --static and --shared to setup which plugins you want to build statically in the library or dynamically - normalize .mk and plugin file names to adopt a single standard - WARNING: huge commit * Added 'mk/sloc.mk' with 'sloc' target to count lines with sloccount everywhere (yeah!) --HG-- rename : libr/asm/p/x86bea.mk => libr/asm/p/x86_bea.mk rename : libr/asm/p/x86nasm.mk => libr/asm/p/x86_nasm.mk rename : libr/asm/p/x86olly.mk => libr/asm/p/x86_olly.mk rename : libr/config.h => libr/config.h.head rename : libr/config.mk => libr/config.mk.head rename : libr/debug/p/dbg_gdb.c => libr/debug/p/debug_gdb.c rename : libr/debug/p/dbg_ptrace.c => libr/debug/p/debug_ptrace.c rename : libr/debug/p/dbg_libgdbwrap/Makefile => libr/debug/p/libgdbwrap/Makefile rename : libr/debug/p/dbg_libgdbwrap/README => libr/debug/p/libgdbwrap/README rename : libr/debug/p/dbg_libgdbwrap/client.c => libr/debug/p/libgdbwrap/client.c rename : libr/debug/p/dbg_libgdbwrap/gdbwrapper.c => libr/debug/p/libgdbwrap/gdbwrapper.c rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper-internals.h => libr/debug/p/libgdbwrap/include/gdbwrapper-internals.h rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper-stddef.h => libr/debug/p/libgdbwrap/include/gdbwrapper-stddef.h rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper.h => libr/debug/p/libgdbwrap/include/gdbwrapper.h rename : libr/debug/p/dbg_libgdbwrap/include/libaspect.h => libr/debug/p/libgdbwrap/include/libaspect.h rename : libr/debug/p/dbg_libgdbwrap/include/libe2dbg.h => libr/debug/p/libgdbwrap/include/libe2dbg.h rename : libr/debug/p/dbg_libgdbwrap/include/revm.h => libr/debug/p/libgdbwrap/include/revm.h rename : libr/debug/p/dbg_libgdbwrap/interface.c => libr/debug/p/libgdbwrap/interface.c rename : libr/io/p/dbg.mk => libr/io/p/debug.mk rename : libr/io/p/io_dbg.c => libr/io/p/io_debug.c
2010-01-13 22:42:49 +00:00
.PHONY: sloc mrproper clean pkgcfg install deinstall uninstall libr
.PHONY: install-includes install-pkgconfig install-symlink all