Fix #3051 - Honor CFLAGS everywhere and fix some windows/android warnings

This commit is contained in:
pancake 2015-09-14 19:21:57 +02:00
parent cf514233bb
commit b86bf19c85
26 changed files with 103 additions and 41 deletions

View File

@ -3,7 +3,8 @@ include ../../libr/config.mk
include ../../shlr/zip/deps.mk
CFLAGS+=-DLIBDIR=\"${LIBDIR}\" -I$(LTOP)/include
CFLAGS+=-DR2_BIRTH=\"`date +%Y-%m-%d`\"
BIRTH=$(shell date +%y-%m-%d)
CFLAGS+=-DR2_BIRTH=\"$(BIRTH)\"
CFLAGS+=-DR2_GITTIP=\"$(GIT_TIP)\"
CFLAGS+=-DR2_GITTAP=\"$(GIT_TAP)\"
@ -65,7 +66,7 @@ ${BEXE}: ${OBJ} ${SHARED_OBJ}
ifneq ($(SILENT),)
@echo LD $@
endif
${CC} $+ -L.. -o $@ $(REAL_LDFLAGS)
${CC} ${CFLAGS} $+ -L.. -o $@ $(REAL_LDFLAGS)
endif
# Dummy myclean rule that can be overriden by the t/ Makefile

View File

@ -41,7 +41,7 @@ endif
.c.o:
ifneq ($(SILENT),)
@echo CC $(shell basename $<)
@echo "CC $(shell basename $<)"
endif
$(CC) -c $(CFLAGS) -o $@ $<

View File

@ -49,9 +49,6 @@ static const char *mnemonics[] = {
"seek", NULL
};
/* number of errors seen so far */
static int errors = 0;
/* current line, address and file */
static int addr = 0, file;
/* current number of characters in list file, for indentation */

View File

@ -28,11 +28,11 @@ static int tms320_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
return op->size;
}
static int tms320_init(void * user) {
static _Bool tms320_init(void * user) {
return tms320_dasm_init (&engine);
}
static int tms320_fini(void * user) {
static _Bool tms320_fini(void * user) {
return tms320_dasm_fini (&engine);
}

View File

@ -1,6 +1,6 @@
include ../../config.mk
CFLAGS=-I$(LTOP)/include -I$(LTOP)/bin/format/ -Wall -fPIC
CFLAGS+=-I$(LTOP)/include -I$(LTOP)/bin/format/ -Wall -fPIC
LDFLAGS+=-L$(LTOP)/util -lr_util
LDFLAGS+=-L$(LTOP)/bin -lr_bin
SHLR=$(LTOP)/../shlr

View File

@ -1,7 +1,7 @@
include ../../config.mk
ifeq ($(WITHPIC),1)
CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC ${LDFLAGS_LIB}
CFLAGS+=-I../../include -I../arch/ -I../arch/include -Wall -fPIC ${LDFLAGS_LIB}
CFLAGS+=-DLIL_ENDIAN=1 -D__UNIX__
foo: all

View File

@ -127,7 +127,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
if (align) {
if (addr % align) {
matches = false;
eprintf ("NOT VALID %llx\n", addr);
eprintf ("Address not valid 0x%"PFMT64x"\n", addr);
}
}
if (matches) {

View File

@ -1,7 +1,7 @@
include ../../config.mk
include ../../../shlr/zip/deps.mk
CFLAGS=-I../../include -Wall -shared -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
CFLAGS+=-I../../include -Wall -shared -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
# XXX
CFLAGS+=-DLIL_ENDIAN=1
CFLAGS+=-L../../util -lr_util -L../../reg -lr_reg -L.. -lr_core

View File

@ -293,7 +293,7 @@ R_API int r_core_rtr_http_stop(RCore *u) {
const int timeout = 1; // 1 second
RCore *core = (RCore*)u;
#if __WINDOWS__
r_socket_http_server_set_breaked(1);
r_socket_http_server_set_breaked (&r_cons_singleton()->breaked);
#endif
if (((size_t)u)>0xff) {
port = listenport? listenport: r_config_get (

View File

@ -1,6 +1,6 @@
include ../../config.mk
# XXX
CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -shared -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
CFLAGS+=-I../../include -I../arch/ -I../arch/include -Wall -shared -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
LDFLAGS+=${LINK}
caca:

View File

@ -33,6 +33,12 @@ static int r_debug_native_reg_write (RDebug *dbg, int type, const ut8* buf, int
#include <windows.h>
#define R_DEBUG_REG_T CONTEXT
#include "native/w32.c"
#ifdef NTSTATUS
#undef NTSTATUS
#endif
#ifndef NTSTATUS
#define NTSTATUS int
#endif
#elif __BSD__
#include <sys/ptrace.h>

View File

@ -5,6 +5,14 @@
#include <psapi.h>
#include <tchar.h>
#ifndef NTSTATUS
#define NTSTATUS
#endif
#ifndef WINAPI
#define WINAPI
#endif
// XXX remove
#define WIN32_PI(x) x
#if 0
@ -151,7 +159,6 @@ typedef struct _OBJECT_TYPE_INFORMATION
ULONG NonPagedPoolUsage;
} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;
static void (*gmbn)(HANDLE, HMODULE, LPTSTR, int) = NULL;
static int (*gmi)(HANDLE, HMODULE, LPMODULEINFO, int) = NULL;
static BOOL WINAPI (*w32_detach)(DWORD) = NULL;

View File

@ -1,6 +1,6 @@
include ../../config.mk
CFLAGS=-I../../include -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
CFLAGS+=-I../../include -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
# XXX
CFLAGS+=-DLIL_ENDIAN=1
# -D__UNIX__

View File

@ -63,7 +63,7 @@ ${LIBSO}: $(EXTRA_TARGETS) ${WFD} ${OBJS} ${SHARED_OBJ}
[ -n "${SILENT}" ] && \
echo "LD $(LIBSO)" || \
echo "${CC_LIB} ${LIBNAME} ${OBJS} ${SHARED_OBJ} ${LINK} ${LDFLAGS}" ; \
${CC_LIB} ${LIBNAME} ${OBJS} ${SHARED_OBJ} ${LINK} ${LDFLAGS} || exit 1; \
${CC_LIB} ${LIBNAME} ${CFLAGS} ${OBJS} ${SHARED_OBJ} ${LINK} ${LDFLAGS} || exit 1; \
[ -f "$(LIBR)/stripsyms.sh" ] && sh $(LIBR)/stripsyms.sh ${LIBSO} ${NAME} ; \
break ; \
fi ; done

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2011-2013 - pancake */
/* radare - LGPL - Copyright 2011-2015 - pancake */
#include <r_socket.h>
#include <r_util.h>

View File

@ -1,7 +1,7 @@
#CC=arm-linux-androideabi-gcc
CC=ndk-gcc -fPIC -pie -fPIE
CC=ndk-gcc -fPIC -fPIE
#RANLIB=ndk-ranlib
USERCC=ndk-gcc -fPIC -pie -fPIE
USERCC=ndk-gcc -fPIC -fPIE
ARCH=arm
ifeq (${NDK_ARCH},x86)
@ -42,7 +42,7 @@ ONELIB=0
OSTYPE=android
LINK=
#CC_AR=ndk-ar -r ${LIBAR}
PICFLAGS=-fPIC -pie -fpic
PICFLAGS=-fPIC -fpic
CFLAGS+=${PICFLAGS}
CC_LIB=${CC} -shared -o
CFLAGS_INCLUDE=-I

View File

@ -49,7 +49,7 @@ $(LIB):
mkdir -p $(LIB)
$(LIB)/$(LIBNAME).a: $(LIB) $(SRC_O)
$(LD) -fPIC -shared -o $(LIB)/$(LIBFILE) $(SRC_O) $(LDFLAGS) $(LINK)
$(LD) -fPIC -shared -o $(LIB)/$(LIBFILE) $(CFLAGS) $(SRC_O) $(LDFLAGS) $(LINK)
$(AR) rvs $(LIB)/$(LIBNAME).a $(SRC_O)
# required for solaris and w32
$(RANLIB) $(LIB)/$(LIBNAME).a

View File

@ -205,8 +205,8 @@ grub_cpio_dir (grub_device_t device, const char *path,
void *closure)
{
struct grub_cpio_data *data;
grub_uint32_t ofs;
char *prev, *name;
grub_uint32_t ofs = 0;
char *prev, *name = NULL;
const char *np;
int len;
@ -280,8 +280,8 @@ fail:
static grub_err_t
grub_cpio_open (grub_file_t file, const char *name)
{
struct grub_cpio_data *data;
grub_uint32_t ofs;
struct grub_cpio_data *data = NULL;
grub_uint32_t ofs = 0;
char *fn = NULL;
int i, j;

View File

@ -47,7 +47,7 @@ grub_fbfs_mount (grub_disk_t disk)
m = (struct fb_mbr *) buf;
d = (struct fb_data *) buf;
if (*((grub_uint32_t *) &buf[0]) == FB_AR_MAGIC_LONG)
if (*((grub_uint32_t *) &buf) == FB_AR_MAGIC_LONG)
{
ofs = 0;
boot_base = 0;

View File

@ -312,8 +312,7 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{
struct grub_hfsplus_extkey *key;
struct grub_hfsplus_extkey_internal extoverflow;
int blk;
int ptr;
int blk, ptr = 0;
/* Try to find this block in the current set of extents. */
blk = grub_hfsplus_find_block (extents, &blksleft);
@ -831,8 +830,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
void *closure)
{
struct grub_hfsplus_key_internal intern;
struct grub_hfsplus_btnode *node;
int ptr;
struct grub_hfsplus_btnode *node = NULL;
int ptr = 0;
struct grub_hfsplus_iterate_dir_closure c;
/* Create a key that points to the first entry in the directory. */

View File

@ -657,7 +657,6 @@ R_API DsoJsonObj * dso_json_num_new_from_num (ut64 num) {
R_API char * dso_json_convert_string (const char * bytes, ut32 len) {
ut32 idx = 0, pos = 1;
ut32 str_sz = 4*len+1+2;
int end = 0;
char *cpy_buffer = len > 0 ? calloc (1, str_sz): NULL;
if (!cpy_buffer) return cpy_buffer;
// 4x is the increase from byte to \xHH where HH represents hexed byte

View File

@ -63,7 +63,7 @@ ${LIBNAME}: ${OBJS}
ifneq ($(SILENT),)
@echo LIB ${LIBNAME}
endif
${CC} ${LDFLAGS} $(LDFLAGS_SHARED) -o $@ ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} $(LDFLAGS_SHARED) -o $@ ${OBJS}
libr_z.a: ${OFILES}
${CC_AR} ${OFILES}

48
sys/build-m32.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
MAKE_JOBS=8
[ -z "${PREFIX}" ] && PREFIX=/usr
case "$1" in
-h)
echo "Usage: sys/build.sh [/usr]"
exit 0
;;
'')
:
;;
*)
PREFIX="$1"
;;
esac
[ ! "${PREFIX}" = /usr ] && \
CFGARG=--with-rpath
if [ -z "${MAKE}" ]; then
MAKE=make
gmake --help >/dev/null 2>&1
[ $? = 0 ] && MAKE=gmake
fi
# find root
cd `dirname $PWD/$0` ; cd ..
ccache --help > /dev/null 2>&1
if [ $? = 0 ]; then
[ -z "${CC}" ] && CC=gcc
CC="ccache ${CC}"
export CC
fi
# build
echo "Cleaning up the whole thing..."
${MAKE} mrproper > /dev/null 2>&1
[ "`uname`" = Linux ] && export LDFLAGS="-Wl,--as-needed"
rm -f plugins.cfg
# STATIC BUILD
CFLAGS="${CFLAGS} -m32"
export CFLAGS
./configure ${CFGARG} --prefix=${PREFIX} || exit 1
exec ${MAKE} -s -j ${MAKE_JOBS}

View File

@ -27,7 +27,9 @@ type sudo || NOSUDO=1
[ "$(id -u)" = 0 ] || SUDO=sudo
[ -n "${NOSUDO}" ] && SUDO=
if [ "${HARDEN}" = 1 ]; then
if [ "${M32}" = 1 ]; then
./sys/build-m32.sh $* && ${SUDO} ${MAKE} ${INSTALL_TARGET}
elif [ "${HARDEN}" = 1 ]; then
# shellcheck disable=SC2048
# shellcheck disable=SC2086
./sys/build-harden.sh $* && ${SUDO} ${MAKE} ${INSTALL_TARGET}

View File

@ -77,9 +77,9 @@ if [ -z "${NDK_BINS}" ]; then
echo "Cant find NDK_BINS"
exit 1
fi
CFLAGS="--sysroot=${PLATFORM_ROOT}"
CFLAGS="${CFLAGS} --sysroot=${PLATFORM_ROOT}"
CFLAGS="${CFLAGS} -I${PLATFORM_PATH}/include"
CFLAGS="${CFLAGS} -pie -fPIC"
CFLAGS="${CFLAGS} -fPIC -fPIE"
case "${ARCH}" in
mips64)
@ -98,13 +98,14 @@ LDFLAGS="${LDFLAGS} --sysroot=${PLATFORM_ROOT}"
#if [ -z "`echo $*" | grep shared`" ]; then
#LDFLAGS="${LDFLAGS} ${PLATFORM_PATH}/lib/crtbegin_dynamic.o"
#fi
CC=${NDKPFX}-gcc
AR=${NDKPFX}-ar
CC="${NDKPFX}-gcc"
AR="${NDKPFX}-ar"
EXT_SO=so
export PATH=${NDK_BINS}:$PATH
export PATH="${NDK_BINS}:$PATH"
export EXT_SO AR CC CFLAGS LDFLAGS PATH
#shellcheck disable=SC2048
#shellcheck disable=SC2086
${CC} ${CFLAGS} ${LDFLAGS} $*
echo ${CC} ${LDFLAGS} ${CFLAGS} $*
${CC} ${LDFLAGS} ${CFLAGS} $*

View File

@ -33,7 +33,9 @@ fi
ROOT="${HOME}/bin/prefix/radare2/"
mkdir -p "${ROOT}/lib"
if [ "${HARDEN}" = 1 ]; then
if [ "${M32}" = 1 ]; then
./sys/build-m32.sh "${ROOT}" && ${MAKE} symstall
elif [ "${HARDEN}" = 1 ]; then
./sys/build-harden.sh "${ROOT}" && ${MAKE} symstall
else
./sys/build.sh "${ROOT}" && ${MAKE} symstall