forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
177 lines (161 loc) · 5.35 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
include ../global.mk
include config.mk
include ../mk/${COMPILER}.mk
PREFIX?=${PWD}/../prefix
PFX=${DESTDIR}/${PREFIX}
LFX=${DESTDIR}/${LIBDIR}
IFX=${DESTDIR}/${INCLUDEDIR}
PWD=$(shell pwd)
LIBS0=util hash
LIBS1=reg cons db magic lib diff bp search config socket
LIBS2=syscall cmd lang io crypto flags bin
LIBS3=fs anal
LIBS4=parse sign
LIBS5=asm debug
LIBS6=egg
#LIBS6+=print
LIBS7=core
LIBS=$(LIBS0) $(LIBS1) $(LIBS2) $(LIBS3) $(LIBS4) $(LIBS5) $(LIBS6) $(LIBS7)
.PHONY: $(LIBS)
all:
${MAKE} $(LIBS0)
${MAKE} $(LIBS1)
${MAKE} $(LIBS2)
${MAKE} $(LIBS3)
${MAKE} $(LIBS4)
${MAKE} $(LIBS5)
${MAKE} $(LIBS6)
${MAKE} $(LIBS7)
ifeq (${WITHNONPIC},1)
${MAKE} libr.a
endif
# looks hacky :D
#AR=arm-linux-androideabi-ar
libr.a:
rm -rf .libr
mkdir .libr
for a in */libr_*.a ; do \
mkdir -p .libr/$$a ; \
cp -f $$a .libr/$$a ; \
(cd .libr/$$a ; ${AR} x *.a ; rm -f *.a ) ; \
done
${AR} qv libr.a `find .libr/ | grep '\\.o$$'`
rm -rf .libr
gnu_libr.a: $(shell ls */libr_*.a 2>/dev/null)
rm -f libr.a
echo CREATE libr.a > libr.m
for a in */libr_*.a ; do echo ADDLIB $$a >> libr.m ; done
echo SAVE >> libr.m
# ar -M is a gnu-ism .. try to find a proper portable way to do that
${CC_AR} -M < libr.m
rm -f libr.m
$(LIBS):
@echo "DIR $@"
@${MAKE} -C $@
pkgcfg:
@for lib in ${LIBS}; do ( cd $${lib} && ${MAKE} pkgcfg ); done
cd asm && ${MAKE} 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} ${LFX}/pkgconfig
for a in ../pkgcfg/*.pc ; do ${INSTALL_DATA} $$a ${LFX}/pkgconfig ; done
install-includes:
${INSTALL_DIR} ${IFX}/libr
(cd include && for a in *.h ; do ${INSTALL_DATA} $$a ${IFX}/libr ; done)
${INSTALL_DIR} ${IFX}/libr/sflib
(cd include/sflib && for a in * ; do \
${INSTALL_DIR} ${IFX}/libr/sflib/$$a ; \
for b in $$a/*.h ; do \
${INSTALL_DATA} $$b ${IFX}/libr/sflib/$$b ; \
done ; \
done)
${INSTALL_DIR} ${IFX}/libr/sdb
(cd include/sdb && for a in * ; do \
${INSTALL_DATA} $$a ${IFX}/libr/sdb/$$a ; \
done)
symstall install-symlink:
mkdir -p ${PFX}/bin ${IFX} ${LFX}/pkgconfig ${LFX}/radare2/${VERSION}
rm -rf ${IFX}/libr && ln -fs ${PWD}/include ${IFX}/libr
cd ../pkgcfg && for a in *.pc ; do \
if [ -e ${PWD}/../pkgcfg/$${a} ] ; then \
ln -fs ${PWD}/../pkgcfg/$${a} ${LFX}/pkgconfig/$${a} ; \
fi ; \
done
for a in ${LIBS} ; do \
ln -fs ${PWD}/$${a}/libr_$${a}.${EXT_SO} ${LFX}/libr_$${a}.${EXT_SO} ; \
ln -fs ${PWD}/$${a}/libr_$${a}.${EXT_SO} ${LFX}/libr_$${a}.${EXT_SO}.${LIBVERSION} ; \
ln -fs ${PWD}/$${a}/libr_$${a}.${EXT_AR} ${LFX}/libr_$${a}.${EXT_AR} ; \
for b in $${a}/p/*.${EXT_SO} ; do \
if [ -e ${PWD}/$${b} ] ; then \
ln -fs ${PWD}/$${b} ${LFX}/radare2/${VERSION}/ ; \
fi ; \
done ; \
( cd ${LFX}/radare2 ; ln -fs ${VERSION} last ) ; \
done
install: install-includes install-pkgconfig
# TODO :Use INSTALL_DATA_DIR instead of mkdir
# libraries
@${INSTALL_DIR} ${LFX}
@for a in `find * -type f | grep -e '\.${EXT_SO}$$' | grep -v lib/t | grep lib | grep -v /p/` ; do \
b=`echo $$a|cut -d / -f 2`; \
echo " ${LFX}/$$b.${LIBVERSION}"; \
${INSTALL_LIB} $$a ${LFX}/$$b.${LIBVERSION} ; \
( cd ${LFX} ; ln -fs $$b.${LIBVERSION} $$b ) ; \
done
# object archives
@for a in `find * -type f | grep -e '\.a$$' | grep -v fs/p` ; do \
echo " ${LFX}/$$a"; ${INSTALL_DATA} $$a ${LFX} ; done
# plugins
@${INSTALL_DIR} ${LFX}/radare2/${VERSION}
@for a in `find */p -perm -u+x -type f | grep -v exe | grep -v dll | grep ${EXT_SO}`; \
do echo " ${LFX}/radare2/${VERSION}/$$a"; \
${INSTALL_DATA} $$a ${LFX}/radare2/${VERSION} ; done
@echo "lang/p/radare.* ${DESTDIR}/${PFX}/${LIBDIR}/radare2/${VERSION}"
${INSTALL_DATA} lang/p/radare.* ${LFX}/radare2/${VERSION}
cd ${LFX}/radare2 ; ln -fs ${VERSION} last
deinstall uninstall:
# libraries
-@for a in `find * | grep -e '\.${EXT_SO}$$' | grep -v 'lib/t' | grep lib` ; do \
a=`echo $$a | awk -F / '{ print $$NF; }'`; \
echo ${LFX}/$$a ; rm -f ${LFX}/$$a ; done
# object archives
-@for a in `find * | grep -e '\.a$$'` ; do \
a=`echo $$a | awk -F / '{ print $$NF; }'`; \
echo ${LFX}/$$a ; rm -f ${LFX}/$$a ; done
# includes
-if [ -h ${IFX}/libr ]; then \
rm -f ${IFX}/libr ; \
else \
(cd include && for a in * ; do rm -f ${IFX}/libr/$$a ; done) ; \
fi
# programs
-@for a in `find */t -perm -u+x -type f | grep 2`; do \
a=`echo $$a|awk -F / '{ print $$NF; }'`; \
echo ${PFX}/bin/$$a ; rm -f ${PFX}/bin/$$a ; done
# plugins
-@for a in `find */p -perm -u+x -type f`; do \
a="${LFX}/radare2/${VERSION}/`echo $$a|awk -F / '{ print $$NF; }'`"; \
echo $$a ; rm -f $$a ; done
rm -rf ${LFX}/radare2/${VERSION}
rm -f ${LFX}/pkgconfig/libr.pc
rm -f ${LFX}/pkgconfig/r_*.pc
# test programs
rm -rf ${PFX}/bin/libr-test
# TODO: use for a in LIBS (like in binr/Makefile)
rm -rf ${IFX}/libr
rm -rf ${LFX}/libr_*.so.${LIBVERSION}
rm -rf ${LFX}/libr_*.so.0
rm -rf ${LFX}/libr_*.so
rm -rf ${LFX}/libr_*.a
rm -rf ${LFX}/libr2.so*
rm -rf ${LFX}/libr2.a
rm -rf ${LFX}/libr.so*
rm -rf ${LFX}/libr.a
rm -rf ${DESTDIR}${DATADIR}/share/doc/radare2
@echo libr aka radare2 has been uninstalled from PREFIX=${PFX}
clean:
for lib in ${LIBS}; do ( cd $${lib} && ${MAKE} clean ); done
mrproper:
for lib in ${LIBS}; do ( cd $${lib} && ${MAKE} mrproper ); done
.PHONY: sloc mrproper clean pkgcfg install deinstall uninstall libr
.PHONY: install-includes install-pkgconfig install-symlink all