* add evil support and remove evil windows code

* correctly handle alloca include
 * remove trailing spaces


SVN revision: 34072
This commit is contained in:
doursse 2008-03-21 17:18:25 +00:00 committed by doursse
parent 7fe7199a0c
commit 53c0a2d01d
6 changed files with 79 additions and 147 deletions

View File

@ -35,11 +35,14 @@ AC_CHECK_FUNCS(gettimeofday)
create_shared_lib=""
case "$host_os" in
mingw|mingw32)
create_shared_lib="-no-undefined "
mingw|mingw32*|cegcc)
PKG_CHECK_MODULES([EVIL], evil)
AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed])
dnl needed for correct definition of EAPI
AC_DEFINE(EFL_EMBRYO_BUILD, 1, [Define to mention that embryo is built])
create_shared_lib="-no-undefined"
;;
esac
AC_SUBST(create_shared_lib)
AC_CHECK_HEADERS(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))

View File

@ -8,7 +8,8 @@ AM_CPPFLAGS = \
-I$(top_builddir) \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\"
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
@EVIL_CFLAGS@
bin_PROGRAMS = embryo_cc
@ -29,7 +30,7 @@ embryo_cc_scvars.c \
embryo_cc_prefix.c \
embryo_cc_prefix.h
embryo_cc_LDADD = -lm
embryo_cc_LDADD = @EVIL_LIBS@ -lm
embryo_cc_DEPENDENCIES =
EXTRA_DIST = \

View File

@ -17,93 +17,17 @@
#include <ctype.h>
#include <time.h>
#include <dirent.h>
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
# include <stdlib.h>
# include <stdio.h>
# include <errno.h>
#include <dlfcn.h> /* dlopen,dlclose,etc */
#ifdef HAVE_EVIL
# include <evil.h> /* for realpath */
#else
# include <dlfcn.h> /* dlopen,dlclose,etc */
# include <pwd.h>
# include <grp.h>
# include <glob.h>
#endif /* _WIN32 */
#endif /* HAVE_E_WIN32 */
#include "embryo_cc_prefix.h"
/* FIXME: that hack is a temporary one. That code will be in MinGW soon */
#ifdef _WIN32
#define RTLD_LAZY 1 /* lazy function call binding */
#define RTLD_NOW 2 /* immediate function call binding */
#define RTLD_GLOBAL 4 /* symbols in this dlopen'ed obj are visible
to other dlopen'ed objs */
static char *dlerr_ptr;
static char dlerr_data[80];
void *dlopen (const char *file, int mode)
{
HMODULE hmodule;
hmodule = LoadLibrary(file);
if (hmodule == NULL) {
int error;
error = GetLastError();
sprintf(dlerr_data, "LoadLibraryEx returned %d.", error);
dlerr_ptr = dlerr_data;
}
return hmodule;
}
int dlclose (void *handle)
{
if (FreeLibrary(handle)) {
return 0;
}
else {
int error;
error = GetLastError();
sprintf(dlerr_data, "FreeLibrary returned %d.", error);
dlerr_ptr = dlerr_data;
return -1;
}
}
void *dlsym (void *handle, const char *name)
{
FARPROC fp;
fp = GetProcAddress(handle, name);
if (fp == NULL) {
int error;
error = GetLastError();
sprintf(dlerr_data, "GetProcAddress returned %d.", error);
dlerr_ptr = dlerr_data;
}
return fp;
}
char *dlerror (void)
{
if (dlerr_ptr != NULL) {
dlerr_ptr = NULL;
return dlerr_data;
}
else {
return NULL;
}
}
#define realpath(file_name, resolved_name) _fullpath((resolved_name), (file_name), PATH_MAX)
#endif /* _WIN32 */
/* local subsystem functions */
static int _e_prefix_share_hunt(void);
static int _e_prefix_fallbacks(void);

View File

@ -36,12 +36,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef _WIN32
# include <fcntl.h>
# include <io.h>
# include <share.h>
# include <sys/stat.h>
#endif /* _WIN32 */
#ifdef HAVE_EVIL
# include <evil.h>
#endif /* HAVE_EVIL */
#include "embryo_cc_osdefs.h"
#include "embryo_cc_sc.h"
@ -318,30 +315,15 @@ sc_compile(int argc, char *argv[])
/* open the output file */
#ifndef _WIN32
#ifndef HAVE_EVIL
tmpdir = getenv("TMPDIR");
if (!tmpdir) tmpdir = "/tmp";
#else
tmpdir = evil_tmpdir_get();
#endif /* ! HAVE_EVIL */
snprintf(outfname, _MAX_PATH, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir);
fd_out = mkstemp(outfname);
#else
tmpdir = getenv("TMP");
if (!tmpdir) tmpdir = getenv("TEMP");
if (!tmpdir) tmpdir = getenv("USERPROFILE");
if (!tmpdir) tmpdir = getenv("WINDIR");
if (!tmpdir) error(101, "embryo_cc.asm-tmp-XXXXXX (unable to get a valid temp path)");
snprintf(outfname, _MAX_PATH, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir);
# ifdef __MINGW32__
if (!mktemp(outfname))
error(101, outfname);
fd_out = _sopen(outfname, _O_RDWR | _O_BINARY | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE);
# else
if (_mktemp_s(outfname, _MAX_PATH))
error(101, outfname);
_sopen_s(&fd_out, outfname, _O_RDWR | _O_BINARY | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE);
# endif /* __MINGW32__ */
#endif /* _WIN32 */
if (fd_out < 0)
error(101, outfname);

View File

@ -2,14 +2,19 @@
#define _EMBRYO_H
#ifdef EAPI
#undef EAPI
# undef EAPI
#endif
#ifdef _MSC_VER
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
#ifdef _WIN32
# ifdef EFL_EMBRYO_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif
# endif /* ! EFL_EMBRYO_BUILD */
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
@ -20,7 +25,7 @@
# else
# define EAPI
# endif
#endif
#endif /* ! _WIN32 */
#ifdef __cplusplus
extern "C" {

View File

@ -8,12 +8,29 @@
#include <limits.h>
#include <stdarg.h>
#include <string.h>
#if HAVE_ALLOCA_H
#include <alloca.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#elif defined __GNUC__
# define alloca __builtin_alloca
#elif defined _AIX
# define alloca __alloca
#elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
#else
# include <stddef.h>
# ifdef __cplusplus
extern "C"
# endif
void *alloca (size_t);
#endif
#include "Embryo.h"
#include "config.h"
#ifdef __GNUC__
# if __GNUC__ >= 4