* Fix build on W32

* Added --without-magic flag
This commit is contained in:
pancake 2011-03-10 11:36:16 +01:00
parent 27ecc4bc93
commit 7df412ae25
19 changed files with 44 additions and 24 deletions

9
configure vendored
View File

@ -20,6 +20,7 @@ trap control_c 2
DEBUGGER=1
HAVE_EWF=1
HAVE_GMP=1
HAVE_MAGIC=1
HAVE_OPENSSL=1
[ -z "${USERCC}" ] && USERCC="gcc"
[ -z "${USEROSTYPE}" ] && USEROSTYPE="auto"
@ -147,6 +148,7 @@ printf "\nOptional Features:
--without-debugger disable native debugger features
--without-ewf disable EWF dependency
--without-gmp disable GMP dependency
--without-magic disable magic dependency
--without-ssl disable openssl dependency
--with-compiler Define compiler to use (see mk/) (USERCC=gcc)
--with-ostype Choose OS type ( gnulinux windows darwin ) (USEROSTYPE=auto)
@ -195,7 +197,7 @@ echo "VERSION: 0.7"
echo "LANGS: c"
echo "REQUIRED: libdl"
echo "OPTIONAL: libewf"
echo "FLAGS: --without-debugger --without-ewf --without-gmp --without-ssl --with-compiler=gcc --with-ostype=auto --without-pic --with-nonpic"
echo "FLAGS: --without-debugger --without-ewf --without-gmp --without-magic --without-ssl --with-compiler=gcc --with-ostype=auto --without-pic --with-nonpic"
exit 0
;;
"--cache-file")
@ -240,6 +242,7 @@ echo "FLAGS: --without-debugger --without-ewf --without-gmp --without-ssl --
"--without-debugger") DEBUGGER="0"; ;;
"--without-ewf") HAVE_EWF="0"; ;;
"--without-gmp") HAVE_GMP="0"; ;;
"--without-magic") HAVE_MAGIC="0"; ;;
"--without-ssl") HAVE_OPENSSL="0"; ;;
--with-compiler) if [ -z "${value}" ]; then USERCC="gcc"; else USERCC="${value}" ; fi ;;
--with-ostype) if [ -z "${value}" ]; then USEROSTYPE="auto"; else USEROSTYPE="${value}" ; fi ;;
@ -262,7 +265,7 @@ parse_options $1
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_LIB_EWF HAVE_EWF HAVE_LIB_GMP HAVE_GMP HAVE_LIB_MAGIC HAVE_LIB_SSL HAVE_OPENSSL HAVE_LIB_LUA5_1 HAVE_LIB_TCC USERCC USEROSTYPE WITHPIC WITHNONPIC"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_LIB_EWF HAVE_EWF HAVE_LIB_GMP HAVE_GMP HAVE_LIB_MAGIC HAVE_MAGIC HAVE_LIB_SSL HAVE_OPENSSL HAVE_LIB_LUA5_1 HAVE_LIB_TCC USERCC USEROSTYPE WITHPIC WITHNONPIC"
create_environ
@ -351,6 +354,8 @@ check_library HAVE_LIB_GMP gmp 0
if [ "$HAVE_GMP" = "0" ]; then
HAVE_LIB_GMP="0"; fi
check_library HAVE_LIB_MAGIC magic 0
if [ "$HAVE_MAGIC" = "0" ]; then
HAVE_LIB_MAGIC="0"; fi
check_library HAVE_LIB_SSL ssl 0
if [ "$HAVE_OPENSSL" = "0" ]; then
HAVE_LIB_SSL="0"; fi

View File

@ -19,6 +19,8 @@ ARG_WITHOUT HAVE_GMP gmp disable GMP dependency ;
IFNOT HAVE_GMP { HAVE_LIB_GMP = 0 ; }
CHKLIB magic
ARG_WITHOUT HAVE_MAGIC magic disable magic dependency ;
IFNOT HAVE_MAGIC { HAVE_LIB_MAGIC = 0 ; }
CHKLIB ssl
ARG_WITHOUT HAVE_OPENSSL ssl disable openssl dependency ;

View File

@ -9,7 +9,7 @@ Crosscompilation
ArchLinux
---------
./configure --without-gmp --with-compiler=i486-mingw32-gcc --with-ostype=windows --host=i486-unknown-windows
./configure --without-gmp --with-compiler=i486-mingw32-gcc --with-ostype=windows --host=i486-unknown-windows --without-magic
make
make w32dist
@ -26,7 +26,7 @@ Crosscompilation
Ubuntu
------
sudo apt-get install mingw32
./configure --without-gmp --with-compiler=i586-mingw32msvc-gcc --with-ostype=windows --host=i586-unknown-windows
./configure --without-gmp --with-compiler=i586-mingw32msvc-gcc --with-ostype=windows --host=i586-unknown-windows --without-magic
make
make w32dist

View File

@ -291,7 +291,7 @@ R_API int r_cons_get_size(int *rows) {
}
#else
const char *str = r_sys_getenv ("COLUMNS");
if (str != NULL)
if (str != NULL) {
I.columns = atoi (str);
I.rows = 23; // XXX. windows must get console size
} else {

View File

@ -2,6 +2,7 @@
#include <r_fs.h>
#include <dirent.h>
#include <sys/stat.h>
static RFSFile* fs_posix_open(RFSRoot *root, const char *path) {
FILE *fd;

View File

@ -1,4 +1,7 @@
include ../../../config.mk
CC?=i486-mingw32-gcc
RANLIB?=i486-mingw32-ranlib
#CC?=gcc
OSTYPE=$(shell uname -s)
@ -64,6 +67,7 @@ lib: all libgrubfs.a
libgrubfs.a: ${KERNOBJS}
rm -f libgrubfs.a
ar -q libgrubfs.a ${KERNOBJS}
${RANLIB} libgrubfs.a
clean:
rm -f ${KERNOBJS} ${BIN} main.o

View File

@ -386,7 +386,7 @@ void *grub_zalloc (grub_size_t size)
{
void *ret;
ret = malloc(size);
bzero(ret,size);
memset (ret, 0, size);
return ret;
}

View File

@ -13,7 +13,7 @@ endif
foo: all
ALL_TARGETS=
PLUGINS=ptrace.mk debug.mk gdb.mk malloc.mk shm.mk mach.mk w32dbg.mk procpid.mk
PLUGINS=ptrace.mk debug.mk gdb.mk malloc.mk shm.mk mach.mk w32dbg.mk procpid.mk haret.mk
#PLUGINS=ptrace.mk debug.mk gdb.mk malloc.mk mach.mk w32dbg.mk procpid.mk
include ${PLUGINS}

View File

@ -40,7 +40,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
riog = R_NEW (RIOGdb);
riog->fd = _fd;
riog->desc = gdbwrap_init (_fd);
return r_io_desc_new (&r_io_plugin_shm, _fd, file, rw, mode, riog);
return r_io_desc_new (&r_io_plugin_gdb, _fd, file, rw, mode, riog);
}
static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {

View File

@ -1,7 +1,5 @@
/* radare - LGPL - Copyright 2008-2011 pancake<nopcode.org> */
#if __UNIX__
#include "r_io.h"
#include "r_lib.h"
#include "r_socket.h"
@ -136,5 +134,3 @@ struct r_lib_struct_t radare_plugin = {
.data = &r_io_plugin_haret
};
#endif
#endif

View File

@ -1,10 +1,10 @@
/* radare - LGPL - Copyright 2008-2011 pancake<nopcode.org> */
#if __UNIX__
#include "r_io.h"
#include "r_lib.h"
#include <sys/types.h>
#if __UNIX__
#include <sys/ipc.h>
#include <sys/shm.h>
@ -117,11 +117,17 @@ struct r_io_plugin_t r_io_plugin_shm = {
.write = shm__write,
};
#else
struct r_io_plugin_t r_io_plugin_shm = {
//void *plugin;
.name = "shm",
.desc = "shared memory resources (not for w32)",
};
#endif
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_IO,
.data = &r_io_plugin_shm
};
#endif
#endif

View File

@ -23,7 +23,7 @@ typedef struct {
extern int errno;
static int debug_os_read_at(RIOW32Dbg *dbg, void *buf, int len, ut64 addr) {
PDWORD ret;
DWORD ret;
ReadProcessMemory (dbg->pi.hProcess, (PCVOID)(ULONG)addr, buf, len, &ret);
// if (len != ret)
// eprintf ("Cannot read 0x%08llx\n", addr);
@ -37,9 +37,9 @@ static int __read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int len) {
}
static int w32dbg_write_at(RIODesc *fd, const ut8 *buf, int len, ut64 addr) {
PDWORD ret;
DWORD ret;
RIOW32Dbg *dbg = fd->data;
WriteProcessMemory (dbg->pi.hProcess, (PCVOID)(ULONG)addr, buf, len, &ret);
WriteProcessMemory (dbg->pi.hProcess, (LPVOID)(ULONG)addr, buf, len, &ret);
return (int)ret;
}
@ -55,14 +55,13 @@ static int __plugin_open(struct r_io_t *io, const char *file) {
static int __attach (RIOW32Dbg *dbg) {
eprintf ("---> attach to %d\n", dbg->pid);
dbg->pi.hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
dbg->pi.hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, dbg->pid);
if (dbg->pi.hProcess == NULL)
return -1;
return dbg->pid;
}
static RIODesc *__open(struct r_io_t *io, const char *file, int rw, int mode) {
int ret = -1;
if (__plugin_open (io, file)) {
RIOW32Dbg *dbg = R_NEW (RIOW32Dbg);
if (dbg == NULL)

View File

@ -39,7 +39,7 @@ ${LIBSO}: $(EXTRA_TARGETS) waitfordeps ${OBJ}
test $$a -nt ${LIBSO} && do=1 ; \
if [ $$do = 1 ]; then \
echo "${CC_LIB} ${LIBNAME} ${OBJ} ${LDFLAGS} ${LINK}" ; \
${CC_LIB} ${LIBNAME} ${OBJ} ${LDFLAGS} ${LINK} ; \
${CC_LIB} ${LIBNAME} ${OBJ} ${LDFLAGS} ${LINK}; \
if [ -f "../stripsyms.sh" ]; then sh ../stripsyms.sh ${LIBSO} ${NAME} ; fi ; \
break ; \
fi ; done

View File

@ -199,7 +199,9 @@ R_API int r_socket_listen(int port) {
close (s);
return -1;
}
#if __UNIX_
signal (SIGPIPE, SIG_IGN);
#endif
if (listen (s, 1) < 0) {
close (s);
return -1;

View File

@ -1,5 +1,7 @@
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
#include <sys/types.h>
#include <dirent.h>
#include <r_types.h>
#include <r_util.h>
#if __UNIX__
@ -13,7 +15,6 @@
#elif __WINDOWS__
#include <io.h>
#endif
#include <sys/types.h>
/* TODO: import stuff fron bininfo/p/bininfo_addr2line */
/* TODO: check endianness issues here */

View File

@ -1,5 +1,6 @@
CC?=gcc
LINK=
RANLIB=ranlib
ONELIB=0
CC_AR=ar qf ${LIBAR}
PIC_CFLAGS=-fPIC

View File

@ -1,4 +1,5 @@
CC=i486-mingw32-gcc
RANLIB=i486-mingw32-ranlib
OSTYPE=windows
ONELIB=0
LINK=-shared

View File

@ -1,4 +1,5 @@
CC=i586-mingw32msvc-gcc
RANLIB=i586-mingw32msvc-gcc
ONELIB=0
OSTYPE=windows
LINK=

View File

@ -1,4 +1,5 @@
CC=tcc
RANLIB=ranlib
LINK=
ONELIB=0
CC_AR=ar -r ${LIBAR}