forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
221 lines (199 loc) · 7.51 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
include ../global.mk
include config.mk
include ../config-user.mk
include ../mk/platform.mk
include ../mk/${COMPILER}.mk
DESTDIR:=$(DESTDIR)
PREFIX?=${PWD}/../prefix
PWD=$(shell pwd)
LIBS0=util hash
LIBS1=socket reg cons magic bp search config
LIBS2=syscall lang io crypto flag
LIBS3=fs anal bin
LIBS4=parse
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
S=$
B=`
libr.a:
rm -rf .libr
mkdir .libr
for FILE in */libr_*.a ../shlr/*/*.a ; do \
F=${B}basename $$FILE${B} ; \
Q=${B}dirname $$FILE${B} ; \
D=${B}basename $$Q${B} ; \
mkdir -p .libr/$$D ; \
cp -f $$FILE .libr/$$D/$$F ; \
ls -l .libr/$$D/$$F ; \
(cd .libr/$$D && ${AR} x $$F || true ) ; \
done
echo lets ar
cd .libr ; ${AR} qv libr.a `find * -iname *.o 2> /dev/null`
echo lets m
mv .libr/libr.a libr.a
echo ranlibin
${RANLIB} libr.a
rm -rf .libr
__AR=xcrun --sdk iphoneos ar
__RANLIB=xcrun --sdk iphoneos ranlib
a:
rm -rf .libr
mkdir .libr
for FILE in */libr_*.a ; do \
mkdir -p .libr/$$FILE ; \
cp -f $$FILE .libr/$$FILE ; \
(cd .libr/$$FILE ; ${__AR} x *.a ; rm -f *.a ) ; \
done
cd .libr ; ${__AR} qv libr.a `find * -iname *.o`
mv .libr/libr.a libr.a
${__RANLIB} libr.a
lipo -info libr.a
rm -rf .libr
gnu_libr.a: $(shell ls */libr_*.a 2>/dev/null)
rm -f libr.a
echo CREATE libr.a > libr.m
for FILE in */libr_*.a ; do echo ADDLIB $$FILE >> 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} "${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" ; \
done ; \
done)
${INSTALL_DIR} "${DESTDIR}${INCLUDEDIR}/libr/sdb"
(cd include/sdb && for FILE in * ; do \
${INSTALL_DATA} $$FILE "${DESTDIR}${INCLUDEDIR}/libr/sdb/$$FILE" ; \
done)
${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)
symstall install-symlink:
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"
cd ../pkgcfg && for FILE in *.pc ; do \
if [ -e "${PWD}/../pkgcfg/$${FILE}" ] ; then \
ln -fs "${PWD}/../pkgcfg/$${FILE}" \
"${DESTDIR}${LIBDIR}/pkgconfig/$${FILE}" ; \
fi ; \
done
@$(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 -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))" ) ; \
)
# object archives
@for FILE in `find * -type f -iname "*.a" | 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
#@echo "lang/p/radare.* ${DESTDIR}${DESTDIR}${PREFIX}/${LIBDIR}/radare2/${VERSION}"
#${INSTALL_DATA} lang/p/radare.* ${DESTDIR}${LIBDIR}/radare2/${VERSION}
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
-@for FILE in `find * | grep -e '\.a$$'` ; 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"
rm -rf "${DESTDIR}${LIBDIR}/libr_*.a"
rm -rf "${DESTDIR}${LIBDIR}/libr2.so"*
rm -rf "${DESTDIR}${LIBDIR}/libr2.a"
rm -rf "${DESTDIR}${LIBDIR}/libr.so"*
rm -rf "${DESTDIR}${LIBDIR}/libr.a"
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
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