Skip to content
Snippets Groups Projects
Commit 93a5b868 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard
Browse files

Support for generation of .def files from .spec files.

parent d15ed230
No related branches found
No related tags found
No related merge requests found
......@@ -92,7 +92,7 @@ prog_manext = 1
conf_manext = 5
includedir = @includedir@/wine
CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
*.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
*.flc *.spec.c *.spec.def *.glue.c y.tab.c y.tab.h lex.yy.c core
OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
$(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
......@@ -101,7 +101,7 @@ LINTS = $(C_SRCS:.c=.ln)
# Implicit rules
.SUFFIXES: .mc .rc .mc.rc .res .spec .spec.c .glue.c .pl .ok
.SUFFIXES: .mc .rc .mc.rc .res .spec .spec.c .spec.def .glue.c .pl .ok
.c.o:
$(CC) -c $(ALLCFLAGS) -o $@ $<
......@@ -121,6 +121,9 @@ LINTS = $(C_SRCS:.c=.ln)
.spec.spec.c:
$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -spec $<
.spec.spec.def:
$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -def $<
.c.glue.c:
$(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
......@@ -254,6 +257,8 @@ $(WINETEST):
$(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
$(SPEC_SRCS:.spec=.spec.def): $(WINEBUILD)
$(GLUE:.c=.glue.c): $(WINEBUILD)
$(RC_SRCS:.rc=.res): $(WRC)
......
This diff is collapsed.
......@@ -652,6 +652,34 @@ then
[Define if symbols declared in assembly code need an underscore prefix])
fi
dnl **** Check whether stdcall symbols need to be decorated ****
AC_CACHE_CHECK([whether stdcall symbols need to be decorated],
ac_cv_c_stdcall_decoration,
[saved_libs=$LIBS
LIBS="conftest_asm.s $LIBS"
if test "$ac_cv_c_extern_prefix" = "yes"
then
cat > conftest_asm.s <<EOF
.globl _ac_test@0
_ac_test@0:
EOF
else
cat > conftest_asm.s <<EOF
.globl ac_test@0
ac_test@0:
EOF
fi
AC_TRY_LINK([extern void __attribute__((__stdcall__)) ac_test(void);],
[ac_test(); return 0],
ac_cv_c_stdcall_decoration="yes",ac_cv_c_stdcall_decoration="no")
LIBS=$saved_libs])
if test "$ac_cv_c_stdcall_decoration" = "yes"
then
AC_DEFINE(NEED_STDCALL_DECORATION, 1,
[Define if stdcall symbols need to be decorated])
fi
dnl **** Check for .string in assembler ****
AC_CACHE_CHECK([whether assembler accepts .string],
......
......@@ -502,6 +502,9 @@
/* Define if symbols declared in assembly code need an underscore prefix */
#undef NEED_UNDERSCORE_PREFIX
/* Define if stdcall symbols need to be decorated */
#undef NEED_STDCALL_DECORATION
/* Define to use .string instead of .ascii */
#undef HAVE_ASM_STRING
......
......@@ -153,6 +153,7 @@ extern void BuildRelays16( FILE *outfile );
extern void BuildRelays32( FILE *outfile );
extern void BuildSpec16File( FILE *outfile );
extern void BuildSpec32File( FILE *outfile );
extern void BuildDef32File( FILE *outfile );
extern SPEC_TYPE ParseTopLevel( FILE *file );
/* global variables */
......
......@@ -55,7 +55,15 @@ static FILE *input_file;
static FILE *output_file;
/* execution mode */
static enum { MODE_NONE, MODE_SPEC, MODE_GLUE, MODE_RELAY16, MODE_RELAY32 } exec_mode = MODE_NONE;
static enum
{
MODE_NONE,
MODE_SPEC,
MODE_GLUE,
MODE_DEF,
MODE_RELAY16,
MODE_RELAY32
} exec_mode = MODE_NONE;
/* open the input file */
static void open_input( const char *name )
......@@ -91,6 +99,7 @@ static void do_pic(void);
static void do_output( const char *arg );
static void do_usage(void);
static void do_spec( const char *arg );
static void do_def( const char *arg );
static void do_glue( const char *arg );
static void do_relay16(void);
static void do_relay32(void);
......@@ -105,6 +114,7 @@ static const struct option_descr option_table[] =
{ "-o", 1, do_output, "-o name Set the output file name (default: stdout)" },
{ "-sym", 1, do_sym, "-sym file.o Read the list of undefined symbols from 'file.o'" },
{ "-spec", 1, do_spec, "-spec file.spec Build a .c file from a spec file" },
{ "-def", 1, do_def, "-def file.spec Build a .def file from a spec file" },
{ "-glue", 1, do_glue, "-glue file.c Build the 16-bit glue for a .c file" },
{ "-relay16", 0, do_relay16, "-relay16 Build the 16-bit relay assembly routines" },
{ "-relay32", 0, do_relay32, "-relay32 Build the 32-bit relay assembly routines" },
......@@ -149,6 +159,13 @@ static void do_spec( const char *arg )
open_input( arg );
}
static void do_def( const char *arg )
{
if (exec_mode != MODE_NONE || !arg[0]) do_usage();
exec_mode = MODE_DEF;
open_input( arg );
}
static void do_glue( const char *arg )
{
if (exec_mode != MODE_NONE || !arg[0]) do_usage();
......@@ -244,6 +261,18 @@ int main(int argc, char **argv)
default: assert(0);
}
break;
case MODE_DEF:
switch (ParseTopLevel( input_file ))
{
case SPEC_WIN16:
fatal_error( "Cannot yet build .def file for 16-bit dlls\n" );
break;
case SPEC_WIN32:
BuildDef32File( output_file );
break;
default: assert(0);
}
break;
case MODE_GLUE:
BuildGlue( output_file, input_file );
break;
......
......@@ -510,7 +510,6 @@ SPEC_TYPE ParseTopLevel( FILE *file )
else if (strcmp(token, "file") == 0)
{
strcpy(DLLFileName, GetToken(0));
strupper(DLLFileName);
}
else if (strcmp(token, "type") == 0)
{
......@@ -612,7 +611,12 @@ SPEC_TYPE ParseTopLevel( FILE *file )
if (!DLLFileName[0])
{
if (SpecMode == SPEC_MODE_DLL)
sprintf( DLLFileName, "%s.dll", DLLName );
{
strcpy( DLLFileName, DLLName );
/* Append .dll to name if no extension present */
if (!strrchr( DLLFileName, '.'))
strcat( DLLFileName, ".dll" );
}
else
sprintf( DLLFileName, "%s.exe", DLLName );
}
......
......@@ -759,3 +759,70 @@ void BuildSpec32File( FILE *outfile )
"}\n", DLLName );
}
}
/*******************************************************************
* BuildDef32File
*
* Build a Win32 def file from a spec file.
*/
void BuildDef32File(FILE *outfile)
{
int i;
AssignOrdinals();
fprintf(outfile, "; File generated automatically from %s; do not edit!\n\n",
input_file_name );
fprintf(outfile, "LIBRARY lib%s\n\n", DLLFileName);
fprintf(outfile, "EXPORTS\n");
/* Output the exports and relay entry points */
for(i = 0; i < nb_entry_points; i++)
{
ORDDEF *odp = EntryPoints[i];
if(!odp || !*odp->name || (odp->flags & FLAG_NOIMPORT)) continue;
fprintf(outfile, " %s", odp->name);
switch(odp->type)
{
case TYPE_EXTERN:
case TYPE_VARARGS:
case TYPE_CDECL:
case TYPE_VARIABLE:
/* try to reduce output */
if(strcmp(odp->name, odp->link_name))
fprintf(outfile, "=%s", odp->link_name);
break;
case TYPE_STDCALL:
{
#ifdef NEED_STDCALL_DECORATION
int at_param = strlen(odp->u.func.arg_types) * sizeof(int);
fprintf(outfile, "@%d", at_param);
#endif /* NEED_STDCALL_DECORATION */
/* try to reduce output */
if(strcmp(odp->name, odp->link_name))
{
fprintf(outfile, "=%s", odp->link_name);
#ifdef NEED_STDCALL_DECORATION
fprintf(outfile, "@%d", at_param);
#endif /* NEED_STDCALL_DECORATION */
}
break;
}
case TYPE_STUB:
fprintf(outfile, "=%s", make_internal_name( odp, "stub" ));
break;
case TYPE_FORWARD:
fprintf(outfile, "=lib%s", odp->link_name);
break;
default:
assert(0);
}
fprintf(outfile, " @%d\n", odp->ordinal);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment