Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fbeaaa3b
Commit
fbeaaa3b
authored
Jan 03, 2003
by
Dimitrie O. Paun
Committed by
Alexandre Julliard
Jan 03, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly link agains .a files using the -l switch.
Support more verbose output.
parent
850a9429
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
16 deletions
+63
-16
winewrap.c
tools/winewrap.c
+63
-16
No files found.
tools/winewrap.c
View file @
fbeaaa3b
...
@@ -329,26 +329,41 @@ int is_resource(const char* file)
...
@@ -329,26 +329,41 @@ int is_resource(const char* file)
return
!
memcmp
(
buf
,
res_sig
,
sizeof
(
buf
));
return
!
memcmp
(
buf
,
res_sig
,
sizeof
(
buf
));
}
}
/* open the
.def library for a given dll in a specified path
*/
/* open the
file for a given name, in a specified path, with the given extension
*/
static
char
*
try_
dll_path
(
const
char
*
path
,
const
char
*
name
)
static
char
*
try_
path
(
const
char
*
path
,
const
char
*
name
,
const
char
*
ext
)
{
{
char
*
fullname
;
char
*
fullname
;
int
fd
;
int
fd
;
fullname
=
strmake
(
"%s/lib%s.def"
,
path
,
name
);
fullname
=
strmake
(
"%s/lib%s.%s"
,
path
,
name
,
ext
);
if
(
verbose
>
1
)
fprintf
(
stderr
,
"Try %s..."
,
fullname
);
/* check if the file exists */
/* check if the file exists */
if
((
fd
=
open
(
fullname
,
O_RDONLY
))
!=
-
1
)
if
((
fd
=
open
(
fullname
,
O_RDONLY
))
!=
-
1
)
{
{
close
(
fd
);
close
(
fd
);
if
(
verbose
>
1
)
fprintf
(
stderr
,
"FOUND!
\n
"
);
return
fullname
;
return
fullname
;
}
}
free
(
fullname
);
free
(
fullname
);
if
(
verbose
>
1
)
fprintf
(
stderr
,
"
\n
"
);
return
NULL
;
return
NULL
;
}
}
/* open the .def library for a given dll in a specified path */
static
char
*
try_dll_path
(
const
char
*
path
,
const
char
*
name
)
{
return
try_path
(
path
,
name
,
"def"
);
}
/* open the .a library for a given lib in a specified path */
static
char
*
try_lib_path
(
const
char
*
path
,
const
char
*
name
)
{
return
try_path
(
path
,
name
,
"a"
);
}
/* open the .def library for a given dll */
/* open the .def library for a given dll */
static
char
*
open_dll
(
const
char
*
name
)
static
char
*
open_dll
(
const
char
*
name
)
{
{
char
*
fullname
;
char
*
fullname
;
int
i
;
int
i
;
...
@@ -360,34 +375,55 @@ static char *open_dll( const char *name )
...
@@ -360,34 +375,55 @@ static char *open_dll( const char *name )
return
try_dll_path
(
"."
,
name
);
return
try_dll_path
(
"."
,
name
);
}
}
/* find a static library */
static
char
*
find_lib
(
const
char
*
name
)
{
static
const
char
*
std_paths
[]
=
{
"."
,
"/usr/lib"
,
"/usr/local/lib"
};
char
*
fullname
;
int
i
;
for
(
i
=
0
;
i
<
nb_lib_paths
;
i
++
)
{
if
((
fullname
=
try_lib_path
(
lib_paths
[
i
],
name
)))
return
fullname
;
}
for
(
i
=
0
;
i
<
sizeof
(
std_paths
)
/
sizeof
(
std_paths
[
0
]);
i
++
)
{
if
((
fullname
=
try_lib_path
(
std_paths
[
i
],
name
)))
return
fullname
;
}
return
0
;
}
void
add_lib_path
(
const
char
*
path
)
void
add_lib_path
(
const
char
*
path
)
{
{
lib_paths
=
realloc
(
lib_paths
,
(
nb_lib_paths
+
1
)
*
sizeof
(
*
lib_paths
)
);
lib_paths
=
realloc
(
lib_paths
,
(
nb_lib_paths
+
1
)
*
sizeof
(
*
lib_paths
)
);
lib_paths
[
nb_lib_paths
++
]
=
strdup
(
path
);
lib_paths
[
nb_lib_paths
++
]
=
strdup
(
path
);
dll_files
=
realloc
(
dll_files
,
(
nb_dll_files
+
1
)
*
sizeof
(
*
dll_files
)
);
dll_files
=
realloc
(
dll_files
,
(
nb_dll_files
+
1
)
*
sizeof
(
*
dll_files
)
);
dll_files
[
nb_dll_files
++
]
=
strmake
(
"-L%s"
,
path
);
dll_files
[
nb_dll_files
++
]
=
strmake
(
"-L%s"
,
path
);
lib_files
=
realloc
(
lib_files
,
(
nb_lib_files
+
1
)
*
sizeof
(
*
lib_files
)
);
lib_files
[
nb_lib_files
++
]
=
strmake
(
"-L%s"
,
path
);
}
}
void
add_lib_file
(
const
char
*
library
)
void
add_lib_file
(
const
char
*
library
)
{
{
char
*
lib
;
if
(
open_dll
(
library
))
if
(
open_dll
(
library
))
{
{
dll_files
=
realloc
(
dll_files
,
(
nb_dll_files
+
1
)
*
sizeof
(
*
dll_files
)
);
dll_files
=
realloc
(
dll_files
,
(
nb_dll_files
+
1
)
*
sizeof
(
*
dll_files
)
);
dll_files
[
nb_dll_files
++
]
=
strmake
(
"-l%s"
,
library
);
dll_files
[
nb_dll_files
++
]
=
strmake
(
"-l%s"
,
library
);
}
}
else
else
if
((
lib
=
find_lib
(
library
)))
{
{
lib_files
=
realloc
(
lib_files
,
(
nb_lib_files
+
1
)
*
sizeof
(
*
lib_files
)
);
lib_files
=
realloc
(
lib_files
,
(
nb_lib_files
+
1
)
*
sizeof
(
*
lib_files
)
);
lib_files
[
nb_lib_files
++
]
=
strmake
(
"-l%s"
,
library
)
;
lib_files
[
nb_lib_files
++
]
=
lib
;
}
}
else
error
(
"Can not find library %s"
,
library
);
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
char
*
library
=
0
,
*
path
=
0
;
char
*
library
=
0
,
*
path
=
0
;
int
i
,
j
,
len
,
cpp
=
0
,
no_opt
=
0
,
gui_mode
=
0
,
create_wrapper
=
1
;
int
i
,
j
,
len
,
cpp
=
0
,
no_opt
=
0
,
gui_mode
=
0
,
create_wrapper
=
-
1
;
char
*
base_name
,
*
base_file
,
*
app_temp_name
,
*
wrp_temp_name
;
char
*
base_name
,
*
base_file
,
*
app_temp_name
,
*
wrp_temp_name
;
char
*
spec_name
,
*
spec_c_name
,
*
spec_o_name
;
char
*
spec_name
,
*
spec_c_name
,
*
spec_o_name
;
char
*
wspec_name
,
*
wspec_c_name
,
*
wspec_o_name
;
char
*
wspec_name
,
*
wspec_c_name
,
*
wspec_o_name
;
...
@@ -430,7 +466,7 @@ int main(int argc, char **argv)
...
@@ -430,7 +466,7 @@ int main(int argc, char **argv)
else
error
(
"Unknown option %s
\n
"
,
argv
[
i
]);
else
error
(
"Unknown option %s
\n
"
,
argv
[
i
]);
break
;
break
;
case
'v'
:
/* verbose */
case
'v'
:
/* verbose */
if
(
argv
[
i
][
2
]
==
0
)
verbose
=
1
;
if
(
argv
[
i
][
2
]
==
0
)
verbose
++
;
break
;
break
;
case
'V'
:
case
'V'
:
printf
(
"winewrap v0.40
\n
"
);
printf
(
"winewrap v0.40
\n
"
);
...
@@ -439,6 +475,12 @@ int main(int argc, char **argv)
...
@@ -439,6 +475,12 @@ int main(int argc, char **argv)
case
'C'
:
case
'C'
:
cpp
=
1
;
cpp
=
1
;
break
;
break
;
case
'w'
:
create_wrapper
=
1
;
break
;
case
'W'
:
create_wrapper
=
0
;
break
;
case
'-'
:
case
'-'
:
if
(
argv
[
i
][
2
])
error
(
"No long option supported."
);
if
(
argv
[
i
][
2
])
error
(
"No long option supported."
);
no_opt
=
1
;
no_opt
=
1
;
...
@@ -454,6 +496,9 @@ int main(int argc, char **argv)
...
@@ -454,6 +496,9 @@ int main(int argc, char **argv)
obj_files
[
nb_obj_files
++
]
=
strdup
(
argv
[
i
]);
obj_files
[
nb_obj_files
++
]
=
strdup
(
argv
[
i
]);
}
}
/* create wrapper only in C++ by default */
if
(
create_wrapper
==
-
1
)
create_wrapper
=
cpp
;
/* link in by default the big three */
/* link in by default the big three */
add_lib_file
(
"user32"
);
add_lib_file
(
"user32"
);
add_lib_file
(
"gdi32"
);
add_lib_file
(
"gdi32"
);
...
@@ -502,10 +547,12 @@ int main(int argc, char **argv)
...
@@ -502,10 +547,12 @@ int main(int argc, char **argv)
spec_args
[
j
++
]
=
strmake
(
"%s.exe"
,
base_name
);
spec_args
[
j
++
]
=
strmake
(
"%s.exe"
,
base_name
);
spec_args
[
j
++
]
=
gui_mode
?
"-mgui"
:
"-mcui"
;
spec_args
[
j
++
]
=
gui_mode
?
"-mgui"
:
"-mcui"
;
}
}
for
(
i
=
0
;
i
<
nb_obj_files
;
i
++
)
spec_args
[
j
++
]
=
obj_files
[
i
];
for
(
i
=
0
;
i
<
nb_dll_files
;
i
++
)
for
(
i
=
0
;
i
<
nb_dll_files
;
i
++
)
spec_args
[
j
++
]
=
dll_files
[
i
];
spec_args
[
j
++
]
=
dll_files
[
i
];
for
(
i
=
0
;
i
<
nb_obj_files
;
i
++
)
spec_args
[
j
++
]
=
obj_files
[
i
];
for
(
i
=
0
;
i
<
nb_lib_files
;
i
++
)
spec_args
[
j
++
]
=
lib_files
[
i
];
spec_args
[
j
]
=
0
;
spec_args
[
j
]
=
0
;
/* build gcc's argument list */
/* build gcc's argument list */
...
@@ -520,13 +567,11 @@ int main(int argc, char **argv)
...
@@ -520,13 +567,11 @@ int main(int argc, char **argv)
comp_args
[
j
]
=
0
;
comp_args
[
j
]
=
0
;
/* build ld's argument list */
/* build ld's argument list */
link_args
=
malloc
(
(
nb_obj_files
+
20
)
*
sizeof
(
char
*
)
);
link_args
=
malloc
(
(
nb_
lib_files
+
nb_
obj_files
+
20
)
*
sizeof
(
char
*
)
);
j
=
0
;
j
=
0
;
link_args
[
j
++
]
=
cpp
?
"g++"
:
"gcc"
;
link_args
[
j
++
]
=
cpp
?
"g++"
:
"gcc"
;
link_args
[
j
++
]
=
"-shared"
;
link_args
[
j
++
]
=
"-shared"
;
link_args
[
j
++
]
=
"-Wl,-Bsymbolic,-z,defs"
;
link_args
[
j
++
]
=
"-Wl,-Bsymbolic,-z,defs"
;
for
(
i
=
0
;
i
<
nb_lib_files
;
i
++
)
link_args
[
j
++
]
=
lib_files
[
i
];
link_args
[
j
++
]
=
"-lwine"
;
link_args
[
j
++
]
=
"-lwine"
;
link_args
[
j
++
]
=
"-lm"
;
link_args
[
j
++
]
=
"-lm"
;
link_args
[
j
++
]
=
"-o"
;
link_args
[
j
++
]
=
"-o"
;
...
@@ -534,6 +579,8 @@ int main(int argc, char **argv)
...
@@ -534,6 +579,8 @@ int main(int argc, char **argv)
link_args
[
j
++
]
=
spec_o_name
;
link_args
[
j
++
]
=
spec_o_name
;
for
(
i
=
0
;
i
<
nb_obj_files
;
i
++
)
for
(
i
=
0
;
i
<
nb_obj_files
;
i
++
)
if
(
!
is_resource
(
obj_files
[
i
]))
link_args
[
j
++
]
=
obj_files
[
i
];
if
(
!
is_resource
(
obj_files
[
i
]))
link_args
[
j
++
]
=
obj_files
[
i
];
for
(
i
=
0
;
i
<
nb_lib_files
;
i
++
)
link_args
[
j
++
]
=
lib_files
[
i
];
link_args
[
j
]
=
0
;
link_args
[
j
]
=
0
;
/* build wrapper compile argument list */
/* build wrapper compile argument list */
...
@@ -549,7 +596,7 @@ int main(int argc, char **argv)
...
@@ -549,7 +596,7 @@ int main(int argc, char **argv)
wwrap_args
[
j
]
=
0
;
wwrap_args
[
j
]
=
0
;
/* build wrapper winebuild's argument list */
/* build wrapper winebuild's argument list */
wspec_args
=
malloc
(
(
nb_
lib_files
+
nb_
dll_files
+
20
)
*
sizeof
(
char
*
)
);
wspec_args
=
malloc
(
(
nb_dll_files
+
20
)
*
sizeof
(
char
*
)
);
j
=
0
;
j
=
0
;
wspec_args
[
j
++
]
=
BINDIR
"/winebuild"
;
wspec_args
[
j
++
]
=
BINDIR
"/winebuild"
;
wspec_args
[
j
++
]
=
"-o"
;
wspec_args
[
j
++
]
=
"-o"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment