Skip to content

Commit

Permalink
build cleanup focused on possibility to control the lib directories w…
Browse files Browse the repository at this point in the history
…ith the build parameters

needed mainly for RedHat/Fedora builds
  • Loading branch information
xambroz authored and radare committed Oct 27, 2015
1 parent 13fd1d0 commit d448260
Show file tree
Hide file tree
Showing 26 changed files with 390 additions and 392 deletions.
249 changes: 122 additions & 127 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
-include config-user.mk
include global.mk

DESTDIR:=$(call rmbdlslash,$(DESTDIR))
WWWROOT:=$(call rmbdlslash,$(WWWROOT))
R2R=radare2-regressions
R2R_URL=$(shell doc/repo REGRESSIONS)
DLIBDIR=$(call rmdblslash,$(DESTDIR)/$(LIBDIR))
WWWROOT=${DATADIR}/radare2/${VERSION}/www
R2BINS=$(shell cd binr ; echo r*2 r2agent r2pm)
DATADIRS=libr/cons/d libr/bin/d libr/asm/d libr/syscall/d libr/magic/d
R2VC=$(shell git rev-list --all --count)
Expand Down Expand Up @@ -77,52 +73,52 @@ R=$(shell printf "\033[0m")
windist:
@echo "${C}[WINDIST] Installing binaries and libraries${R}"
[ -n "${WINBITS}" ] || exit 1
rm -rf radare2-${WINBITS}-${VERSION} ${WINDIST}
mkdir ${WINDIST}
for a in `find libr | grep -e dll$$`; do cp $$a ${WINDIST} ; done
for a in `find binr | grep -e exe$$`; do cp $$a ${WINDIST} ; done
rm -f ${WINDIST}/plugin.dll
rm -rf "radare2-${WINBITS}-${VERSION}" "${WINDIST}"
mkdir "${WINDIST}"
for FILE in `find libr | grep -e dll$$`; do cp "$$FILE" "${WINDIST}" ; done
for FILE in `find binr | grep -e exe$$`; do cp "$$FILE" "${WINDIST}" ; done
rm -f "${WINDIST}/plugin.dll"
@echo "${C}[WINDIST] Picking plugins from libraries${R}"
mkdir -p ${WINDIST}/libs
mv ${WINDIST}/lib*.dll ${WINDIST}/libs
mkdir -p ${WINDIST}/plugins
mv ${WINDIST}/*.dll ${WINDIST}/plugins
mv ${WINDIST}/libs/* ${WINDIST}
mkdir -p "${WINDIST}/libs"
mv "${WINDIST}/lib*.dll ${WINDIST}/libs"
mkdir -p "${WINDIST}/plugins"
mv ${WINDIST}/*.dll "${WINDIST}/plugins"
mv ${WINDIST}/libs/* "${WINDIST}"
@echo "${C}[WINDIST] Do not include plugins for now${R}"
rm -rf ${WINDIST}/libs
rm -rf "${WINDIST}/libs"
rm -rf ${WINDIST}/plugins/*
@echo "${C}[WINDIST] Copying web interface${R}"
mkdir -p ${WINDIST}/www
cp -rf shlr/www/* ${WINDIST}/www
mkdir -p ${WINDIST}/share/radare2/${VERSION}/magic
cp -f libr/magic/d/default/* ${WINDIST}/share/radare2/${VERSION}/magic
mkdir -p ${WINDIST}/share/radare2/${VERSION}/syscall
cp -f libr/syscall/d/*.sdb ${WINDIST}/share/radare2/${VERSION}/syscall
mkdir -p ${WINDIST}/share/radare2/${VERSION}/opcodes
cp -f libr/asm/d/*.sdb ${WINDIST}/share/radare2/${VERSION}/opcodes
mkdir -p ${WINDIST}/share/doc/radare2
mkdir -p ${WINDIST}/include/libr/sdb
mkdir -p "${WINDIST}/www"
cp -rf shlr/www/* "${WINDIST}/www"
mkdir -p "${WINDIST}/share/radare2/${VERSION}/magic"
cp -f libr/magic/d/default/* "${WINDIST}/share/radare2/${VERSION}/magic"
mkdir -p "${WINDIST}/share/radare2/${VERSION}/syscall"
cp -f libr/syscall/d/*.sdb "${WINDIST}/share/radare2/${VERSION}/syscall"
mkdir -p "${WINDIST}/share/radare2/${VERSION}/opcodes"
cp -f libr/asm/d/*.sdb "${WINDIST}/share/radare2/${VERSION}/opcodes"
mkdir -p "${WINDIST}/share/doc/radare2"
mkdir -p "${WINDIST}/include/libr/sdb"
@echo "${C}[WINDIST] Copying development files${R}"
cp -f libr/include/sdb/*.h ${WINDIST}/include/libr/sdb/
cp -f libr/include/*.h ${WINDIST}/include/libr
#mkdir -p ${WINDIST}/include/libr/sflib
@cp -f doc/fortunes.* ${WINDIST}/share/doc/radare2
@mkdir -p ${WINDIST}/share/radare2/${VERSION}/cons
@cp -f libr/cons/d/* ${WINDIST}/share/radare2/${VERSION}/cons
@mkdir -p ${WINDIST}/share/radare2/${VERSION}/hud
@cp -f doc/hud ${WINDIST}/share/radare2/${VERSION}/hud/main
@mv ${WINDIST} radare2-${WINBITS}-${VERSION}
@rm -f radare2-${WINBITS}-${VERSION}.zip
cp -f libr/include/sdb/*.h "${WINDIST}/include/libr/sdb/"
cp -f libr/include/*.h "${WINDIST}/include/libr"
#mkdir -p "${WINDIST}/include/libr/sflib"
@cp -f doc/fortunes.* "${WINDIST}/share/doc/radare2"
@mkdir -p "${WINDIST}/share/radare2/${VERSION}/cons"
@cp -f libr/cons/d/* "${WINDIST}/share/radare2/${VERSION}/cons"
@mkdir -p "${WINDIST}/share/radare2/${VERSION}/hud"
@cp -f doc/hud "${WINDIST}/share/radare2/${VERSION}/hud/main"
@mv "${WINDIST}" "radare2-${WINBITS}-${VERSION}"
@rm -f "radare2-${WINBITS}-${VERSION}.zip"
ifneq ($(USE_ZIP),NO)
$(ZIP) -r radare2-${WINBITS}-${VERSION}.zip radare2-${WINBITS}-${VERSION}
$(ZIP) -r "radare2-${WINBITS}-${VERSION}.zip" "radare2-${WINBITS}-${VERSION}"
endif

clean: rmd
for a in shlr libr binr ; do (cd $$a ; ${MAKE} clean) ; done
for DIR in shlr libr binr ; do (cd "$$DIR" ; ${MAKE} clean) ; done

distclean mrproper:
-rm -f `find . -type f -name *.d`
for a in libr binr shlr ; do ( cd $$a ; ${MAKE} mrproper) ; done
-rm -f `find . -type f -name '*.d'`
for DIR in libr binr shlr ; do ( cd "$$DIR" ; ${MAKE} mrproper) ; done
rm -f config-user.mk plugins.cfg libr/config.h
rm -f libr/include/r_userconf.h libr/config.mk
rm -f pkgcfg/*.pc
Expand All @@ -131,98 +127,97 @@ pkgcfg:
cd libr && ${MAKE} pkgcfg

install-man:
mkdir -p "${MDR}/man1"
for a in man/*.1 ; do ${INSTALL_MAN} "$$a" "${MDR}/man1" ; done
cd "${MDR}/man1" && ln -fs radare2.1 r2.1
mkdir -p "${DESTDIR}${MANDIR}/man1"
for FILE in man/*.1 ; do ${INSTALL_MAN} "$$FILE" "${DESTDIR}${MANDIR}/man1" ; done
cd "${DESTDIR}${MANDIR}/man1" && ln -fs radare2.1 r2.1

install-man-symlink:
mkdir -p "${MDR}/man1"
cd man && for a in *.1 ; do \
ln -fs "${PWD}/man/$$a" "${MDR}/man1/$$a" ; done
cd "${MDR}/man1" && ln -fs radare2.1 r2.1
mkdir -p "${DESTDIR}${MANDIR}/man1"
cd man && for FILE in *.1 ; do \
ln -fs "${PWD}/man/$$FILE" "${DESTDIR}${MANDIR}/man1/$$FILE" ; done
cd "${DESTDIR}${MANDIR}/man1" && ln -fs radare2.1 r2.1

install-doc:
${INSTALL_DIR} "${PFX}/share/doc/radare2"
for a in doc/* ; do ${INSTALL_DATA} $$a "${PFX}/share/doc/radare2" ; done
${INSTALL_DIR} "${DESTDIR}${DATADIR}/doc/radare2"
for FILE in doc/* ; do ${INSTALL_DATA} $$FILE "${DESTDIR}${DATADIR}/doc/radare2" ; done

install-doc-symlink:
${INSTALL_DIR} "${PFX}/share/doc/radare2"
cd doc ; for a in * ; do \
ln -fs "${PWD}/doc/$$a" "${PFX}/share/doc/radare2" ; done
${INSTALL_DIR} "${DESTDIR}${DATADIR}/doc/radare2"
cd doc ; for FILE in * ; do \
ln -fs "${PWD}/doc/$$FILE" "${DESTDIR}${DATADIR}/doc/radare2" ; done

install love: install-doc install-man install-www
cd libr && ${MAKE} install PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" PARENT=1
cd binr && ${MAKE} install PREFIX="${PREFIX}" DESTDIR="${DESTDIR}"
cd shlr && ${MAKE} install PREFIX="${PREFIX}" DESTDIR="${DESTDIR}"
for a in ${DATADIRS} ; do \
(cd $$a ; ${MAKE} install LIBDIR="${LIBDIR}" PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" ); \
cd libr && ${MAKE} install PARENT=1
cd binr && ${MAKE} install
cd shlr && ${MAKE} install
for DIR in ${DATADIRS} ; do \
(cd "$$DIR" ; ${MAKE} install ); \
done
rm -rf "${DLIBDIR}/radare2/${VERSION}/hud"
mkdir -p "${DLIBDIR}/radare2/${VERSION}/hud"
cp -f doc/hud "${DLIBDIR}/radare2/${VERSION}/hud/main"
mkdir -p $(call rmdblslash,${DESTDIR}/${PREFIX}/share/radare2/${VERSION}/)
rm -rf "${DESTDIR}${LIBDIR}/radare2/${VERSION}/hud"
mkdir -p "${DESTDIR}${LIBDIR}/radare2/${VERSION}/hud"
cp -f doc/hud "${DESTDIR}${LIBDIR}/radare2/${VERSION}/hud/main"
mkdir -p "${DESTDIR}${DATADIR}/radare2/${VERSION}/"
sys/ldconfig.sh

# Remove make .d files. fixes build when .c files are removed
rmd:
rm -f `find . -type f -iname *.d`
rm -f `find . -type f -iname '*.d'`

install-www:
rm -rf $(call rmdblslash,${DESTDIR}/${WWWROOT})
rm -rf ${DLIBDIR}/radare2/${VERSION}/www # old dir
mkdir -p $(call rmdblslash,${DESTDIR}/${WWWROOT})
cp -rf shlr/www/* $(call rmdblslash,${DESTDIR}/${WWWROOT})
rm -rf "${DESTDIR}${WWWROOT}"
rm -rf "${DESTDIR}${LIBDIR}/radare2/${VERSION}/www" # old dir
mkdir -p "${DESTDIR}${WWWROOT}"
cp -rf shlr/www/* "${DESTDIR}${WWWROOT}"


WWWDIR=$(call rmdblslash,${DESTDIR}/${DATADIR}/radare2/${VERSION}/www)
symstall-www:
rm -rf $(call rmdblslash,${DESTDIR}/${WWWROOT})
rm -rf ${DLIBDIR}/radare2/${VERSION}/www # old dir
mkdir -p "$(call rmdblslash,${DESTDIR}/${WWWROOT})"
cd $(call rmdblslash,${DESTDIR}/${WWWROOT}) ; \
for a in "${PWD}/shlr/www/"* ; do \
ln -fs $$a "$(WWWDIR)" ; done
rm -rf "${DESTDIR}${WWWROOT}"
rm -rf "${DESTDIR}${LIBDIR}/radare2/${VERSION}/www" # old dir
mkdir -p "${DESTDIR}${WWWROOT}"
cd "${DESTDIR}${WWWROOT}" ; \
for FILE in "${PWD}/shlr/www/"* ; do \
ln -fs "$$FILE" "$(DESTDIR)$(WWWROOT)" ; done

install-pkgconfig-symlink:
@${INSTALL_DIR} "${DLIBDIR}/pkgconfig"
cd pkgcfg ; for a in *.pc ; do \
ln -fs "$${PWD}/$$a" "${DLIBDIR}/pkgconfig/$$a" ; done
@${INSTALL_DIR} "${DESTDIR}${LIBDIR}/pkgconfig"
cd pkgcfg ; for FILE in *.pc ; do \
ln -fs "$${PWD}/$$FILE" "${DESTDIR}${LIBDIR}/pkgconfig/$$FILE" ; done


symstall install-symlink: install-man-symlink install-doc-symlink install-pkgconfig-symlink symstall-www
cd libr && ${MAKE} install-symlink PREFIX=${PREFIX} DESTDIR="${DESTDIR}"
cd binr && ${MAKE} install-symlink PREFIX=${PREFIX} DESTDIR="${DESTDIR}"
cd shlr && ${MAKE} install-symlink PREFIX=${PREFIX} DESTDIR="${DESTDIR}"
for a in ${DATADIRS} ; do (\
cd $$a ; \
echo $$a ; \
${MAKE} install-symlink LIBDIR="${LIBDIR}" \
PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" ); \
cd libr && ${MAKE} install-symlink
cd binr && ${MAKE} install-symlink
cd shlr && ${MAKE} install-symlink
for DIR in ${DATADIRS} ; do (\
cd "$$DIR" ; \
echo "$$DIR" ; \
${MAKE} install-symlink ); \
done
mkdir -p "${DLIBDIR}/radare2/${VERSION}/hud"
cd "$(call rmdblslash,$(DESTDIR)/$(PREFIX)/lib/radare2/)" ;\
mkdir -p "${DESTDIR}${LIBDIR}/radare2/${VERSION}/hud"
cd "$(DESTDIR)$(LIBDIR)/radare2/" ;\
rm -f last ; ln -fs $(VERSION) last
cd "$(call rmdblslash,$(DESTDIR)/$(PREFIX)/share/radare2/)" ;\
cd "$(DESTDIR)$(PREFIX)/share/radare2/" ;\
rm -f last ; ln -fs $(VERSION) last
ln -fs "${PWD}/doc/hud" "${DLIBDIR}/radare2/${VERSION}/hud/main"
mkdir -p "$(call rmdblslash,${DESTDIR}/${PREFIX}/share/radare2/${VERSION}/)"
ln -fs "${PWD}/doc/hud" "${DESTDIR}${LIBDIR}/radare2/${VERSION}/hud/main"
mkdir -p "${DESTDIR}${DATADIR}/radare2/${VERSION}/"
sys/ldconfig.sh

deinstall uninstall:
cd libr && ${MAKE} uninstall PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR}
cd binr && ${MAKE} uninstall PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR}
cd shlr && ${MAKE} uninstall PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR}
cd libr/syscall/d && ${MAKE} uninstall PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR} LIBDIR=${LIBDIR}
cd libr && ${MAKE} uninstall PARENT=1
cd binr && ${MAKE} uninstall PARENT=1
cd shlr && ${MAKE} uninstall PARENT=1
cd libr/syscall/d && ${MAKE} uninstall PARENT=1
@echo
@echo "Run 'make purge' to also remove installed files from previous versions of r2"
@echo

purge-doc:
rm -rf ${DESTDIR}/${PREFIX}/share/doc/radare2
cd man ; for a in *.1 ; do rm -f "${MDR}/man1/$$a" ; done
rm -f ${MDR}/man1/r2.1
rm -rf "${DESTDIR}${DATADIR}/doc/radare2"
cd man ; for FILE in *.1 ; do rm -f "${DESTDIR}${MANDIR}/man1/$$FILE" ; done
rm -f "${DESTDIR}${MANDIR}/man1/r2.1"

user-wrap=echo "\#!/bin/sh" > ~/bin/$1 \
; echo "${PWD}/env.sh ${PREFIX} $1 \$$@" >> ~/bin/$1 \
user-wrap=echo "\#!/bin/sh" > ~/bin/"$1" \
; echo "${PWD}/env.sh '${PREFIX}' '$1' \$$@" >> ~/bin/"$1" \
; chmod +x ~/bin/"$1" ;

user-install:
Expand All @@ -231,57 +226,57 @@ user-install:
cd ~/bin ; ln -fs radare2 r2

user-uninstall:
$(foreach mod,$(R2BINS),rm -f ~/bin/$(mod))
$(foreach mod,$(R2BINS),rm -f ~/bin/"$(mod)")
rm -f ~/bin/r2
-rmdir ~/bin

purge-dev:
rm -f ${DESTDIR}/${LIBDIR}/libr_*.${EXT_AR}
rm -f ${DESTDIR}/${LIBDIR}/pkgconfig/r_*.pc
rm -rf ${DESTDIR}/${INCLUDEDIR}/libr
rm -f ${DESTDIR}/${LIBDIR}/radare2/${VERSION}/-*
rm -f "${DESTDIR}${LIBDIR}/libr_"*".${EXT_AR}"
rm -f "${DESTDIR}${LIBDIR}/pkgconfig/r_"*.pc
rm -rf "${DESTDIR}${INCLUDEDIR}/libr"
rm -f "${DESTDIR}${LIBDIR}/radare2/${VERSION}/-"*

strip:
-for a in ${R2BINS} ; do ${STRIP} -s ${DESTDIR}/${BINDIR}/$$a 2> /dev/null ; done
-for a in ${DESTDIR}/${LIBDIR}/libr_*.${EXT_SO} \
${DESTDIR}/${LIBDIR}/libr2.${EXT_SO} ; do ${STRIP} -s $$a ; done
-for FILE in ${R2BINS} ; do ${STRIP} -s "${DESTDIR}${BINDIR}/$$FILE" 2> /dev/null ; done
-for FILE in "${DESTDIR}${LIBDIR}/libr_"*".${EXT_SO}" "${DESTDIR}${LIBDIR}/libr2.${EXT_SO}" ; do \
${STRIP} -s "$$FILE" ; done

purge: purge-doc purge-dev
for a in ${R2BINS} ; do rm -f ${DESTDIR}/${BINDIR}/$$a ; done
rm -f ${DESTDIR}/${BINDIR}/ragg2-cc
rm -f ${DESTDIR}/${BINDIR}/r2
rm -f ${DESTDIR}/${LIBDIR}/libr_*
rm -f ${DESTDIR}/${LIBDIR}/libr2.${EXT_SO}
rm -rf ${DESTDIR}/${LIBDIR}/radare2
rm -rf ${DESTDIR}/${INCLUDEDIR}/libr
for FILE in ${R2BINS} ; do rm -f "${DESTDIR}${BINDIR}/$$FILE" ; done
rm -f "${DESTDIR}${BINDIR}/ragg2-cc"
rm -f "${DESTDIR}${BINDIR}/r2"
rm -f "${DESTDIR}${LIBDIR}/libr_"*
rm -f "${DESTDIR}${LIBDIR}/libr2.${EXT_SO}"
rm -rf "${DESTDIR}${LIBDIR}/radare2"
rm -rf "${DESTDIR}${INCLUDEDIR}/libr"

dist:
-[ configure -nt config-user.mk ] && ./configure --prefix=${PREFIX}
-[ configure -nt config-user.mk ] && ./configure "--prefix=${PREFIX}"
git log $$(git show-ref `git tag |tail -n1`)..HEAD > ChangeLog
cd shlr && ${MAKE} capstone-sync
DIR=`basename $$PWD` ; \
FILES=`git ls-files | sed -e s,^,radare2-${VERSION}/,` ; \
CS_FILES=`cd shlr/capstone ; git ls-files | grep -v pdf | grep -v xcode | grep -v msvc | grep -v suite | grep -v bindings | grep -v tests | sed -e s,^,radare2-${VERSION}/shlr/capstone/,` ; \
cd .. && mv $${DIR} radare2-${VERSION} && \
${TAR} radare2-${VERSION}.tar $${FILES} $${CS_FILES} radare2-${VERSION}/ChangeLog ;\
${CZ} radare2-${VERSION}.tar ; \
mv radare2-${VERSION} $${DIR}
DIR=`basename "$$PWD"` ; \
FILES=`git ls-files | sed -e "s,^,radare2-${VERSION}/,"` ; \
CS_FILES=`cd shlr/capstone ; git ls-files | grep -v pdf | grep -v xcode | grep -v msvc | grep -v suite | grep -v bindings | grep -v tests | sed -e "s,^,radare2-${VERSION}/shlr/capstone/,"` ; \
cd .. && mv "$${DIR}" "radare2-${VERSION}" && \
${TAR} "radare2-${VERSION}.tar" $${FILES} $${CS_FILES} "radare2-${VERSION}/ChangeLog" ;\
${CZ} "radare2-${VERSION}.tar" ; \
mv "radare2-${VERSION}" "$${DIR}"

shot:
DATE=`date '+%Y%m%d'` ; \
FILES=`git ls-files | sed -e s,^,radare2-${DATE}/,` ; \
cd .. && mv radare2 radare2-$${DATE} && \
${TAR} radare2-$${DATE}.tar $${FILES} ;\
${CZ} radare2-$${DATE}.tar ;\
mv radare2-$${DATE} radare2 && \
scp radare2-$${DATE}.${TAREXT} \
FILES=`git ls-files | sed -e "s,^,radare2-${DATE}/,"` ; \
cd .. && mv radare2 "radare2-$${DATE}" && \
${TAR} "radare2-$${DATE}.tar" $${FILES} ;\
${CZ} "radare2-$${DATE}.tar" ;\
mv "radare2-$${DATE}" radare2 && \
scp "radare2-$${DATE}.${TAREXT}" \
radare.org:/srv/http/radareorg/get/shot

tests:
@if [ -d $(R2R) ]; then \
cd $(R2R) ; git clean -xdf ; git pull ; \
else \
git clone --depth 1 ${R2R_URL} $(R2R); \
git clone --depth 1 "${R2R_URL}" "$(R2R)"; \
fi
cd $(R2R) ; ${MAKE}

Expand Down
Loading

0 comments on commit d448260

Please sign in to comment.