Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clm
Commits
35611ea3
Commit
35611ea3
authored
Oct 06, 2003
by
John van Groningen
Browse files
add optimized linking, increase clm and abc version numbers
parent
8f2e7a5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
clm/clm.c
View file @
35611ea3
...
...
@@ -4,13 +4,13 @@
At: University of Nijmegen
*/
#define CLM_VERSION "2.
0.
1"
#define CLM_VERSION "2.1"
#define VERSION 91
6
#define VERSION 91
9
#
un
def
NEWBRIDGE
#def
ine OPTIMISE_LINK
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
# define NO_CLEAN_SYSTEM_FILES_FOLDERS
#endif
...
...
@@ -27,7 +27,7 @@
# define NO_CLIB
#endif
#if defined (_WINDOWS_) || defined (OMF) || defined (LINUX)
#if defined (_WINDOWS_) || defined (OMF) || defined (LINUX)
|| defined (SOLARIS)
# define NO_ASSEMBLE
#endif
...
...
@@ -227,7 +227,7 @@ static char *cocl_redirect_stdout,*cocl_redirect_stdout_option;
static
char
*
cocl_redirect_stderr
,
*
cocl_redirect_stderr_option
;
static
int
check_stack_overflow
,
check_indices
;
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
static
int
generate_mc68020_code
=
0
,
show_help
=
0
;
#endif
...
...
@@ -468,7 +468,7 @@ static P_NODE add_dependency (DEP_LIST *dependency_list_p,char *dependent_module
static
char
*
clean_path_list
,
clean_path_list_copy
[
PATH_LIST_STRING_SIZE
];
static
char
*
clean_lib_path
,
clean_lib_path_copy
[
PATH_NAME_STRING_SIZE
];
#ifdef N
EWBRIDGE
#ifdef N
B
char
*
clean_abc_path
;
static
char
*
clean_o_path
;
#else
...
...
@@ -692,7 +692,7 @@ static int silent=0;
*
last_path_p
=
new_path
;
}
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
static
char
*
main_module_path
;
#endif
...
...
@@ -707,7 +707,7 @@ static int silent=0;
if
(
clean_abc_path
)
add_directory_to_path_list
(
clean_abc_path
);
# if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
# if defined (MAKE_MPW_TOOL) && defined (N
B
)
add_directory_to_path_list
(
main_module_path
);
# else
add_directory_to_path_list
(
NULL
);
...
...
@@ -751,7 +751,7 @@ static int silent=0;
# if USE_PATH_CACHE
int
dcl_file
;
# endif
# ifdef N
EWBRIDGE
# ifdef N
B
int
abc_or_obj_file
;
# endif
strcpy
(
complete_file_name
,
file_name
);
...
...
@@ -784,7 +784,7 @@ static int silent=0;
}
# endif
# ifdef N
EWBRIDGE
# ifdef N
B
abc_or_obj_file
=
extension
[
0
]
==
'.'
&&
(
(
extension
[
1
]
==
'a'
&&
extension
[
2
]
==
'b'
&&
extension
[
3
]
==
'c'
&&
extension
[
4
]
==
'\0'
)
||
...
...
@@ -825,7 +825,7 @@ static int silent=0;
}
}
# ifdef N
EWBRIDGE
# ifdef N
B
return
0
;
# endif
}
...
...
@@ -1691,11 +1691,13 @@ static int is_system_file (P_NODE project_node)
extern
int
wait
(
int
*
);
#endif
#include
<errno.h>
static
int
wait_for_child
(
pid_t
pid
,
char
*
child_name
,
int
*
status_p
)
{
int
result
;
result
=
waitpid
(
pid
,
status_p
,
0
);
result
=
waitpid
(
pid
,
status_p
,
0
);
if
(
*
status_p
&
255
)
fprintf
(
stderr
,
"%s exited abnormally
\n
"
,
child_name
);
...
...
@@ -1955,7 +1957,7 @@ static int compile_project_node (P_NODE project_node)
*
arg
++=
"-P"
;
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
{
char
*
cocl_path_list
;
int
path_list_length
;
...
...
@@ -1994,7 +1996,7 @@ static int compile_project_node (P_NODE project_node)
int
path_list_length
;
char
*
cocl_path_list
;
path_list_length
=
strlen
(
clean_path_list
)
+
2
;
path_list_length
=
strlen
(
clean_path_list
)
+
3
;
cocl_path_list
=
memory_allocate
(
path_list_length
);
cocl_path_list
[
0
]
=
'\0'
;
strcat
(
cocl_path_list
,
clean_path_list
);
...
...
@@ -2064,7 +2066,7 @@ static int compile_project_node (P_NODE project_node)
#if MACINTOSH
r
=
CallCompiler
(
arg
-
argv
-
1
,
argv
+
1
);
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
if
(
cocl_path_list
!=
NULL
){
free
(
cocl_path_list
);
cocl_path_list
=
NULL
;
...
...
@@ -2189,7 +2191,7 @@ static int generate_code_for_project_node (P_NODE project_node,char *file_name)
if
(
check_indices
)
*
arg
++=
"-ci"
;
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
*
arg
++=
"-sane"
;
if
(
!
generate_mc68020_code
)
*
arg
++=
"-mc68000"
;
...
...
@@ -2285,6 +2287,7 @@ static int generate_code_for_project_node (P_NODE project_node,char *file_name)
if
(
!
pid
){
strcat
(
cg_file_name
,
"/cg"
);
execv
(
cg_file_name
,
argv
);
error
(
"Can't execute the code generator"
);
...
...
@@ -3189,18 +3192,93 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
# endif
# if defined (_WINDOWS_) || defined (OS2)
char
stack_option
[
32
];
#endif
#if defined (USE_CLEANLINKER)
#endif
#
if defined (USE_CLEANLINKER)
char
kernel32_file_name
[
PATH_NAME_STRING_SIZE
];
char
user32_file_name
[
PATH_NAME_STRING_SIZE
];
char
gdi32_file_name
[
PATH_NAME_STRING_SIZE
];
#endif
#ifdef SOLARIS
#
endif
#
ifdef SOLARIS
char
crt
[
128
],
crti
[
128
],
crtn
[
128
];
#endif
#
endif
if
(
!
silent
)
printf
(
"Linking %s
\n
"
,
main_project_node
->
pro_fname
);
# ifdef OPTIMISE_LINK
arg
=
argv
;
*
arg
++=
"linker"
;
need_file
(
"_startup"
,
OBJECT_FILE_EXTENSION
,
start_up_file_name
);
*
arg
++=
start_up_file_name
;
need_file
(
"_system"
,
OBJECT_FILE_EXTENSION
,
system_file_name
);
*
arg
++=
system_file_name
;
for_l
(
project_node
,
first_project_node
,
pro_next
){
if
(
project_node
->
pro_up_to_date
&&
!
project_node
->
pro_ignore_o
){
char
*
file_name
;
if
(
!
find_clean_system_file
(
project_node
->
pro_fname
,
OBJECT_FILE_EXTENSION
,
o_file_name
,
clean_o_path
!=
NULL
?
clean_o_path
:
clean_abc_path
))
{
error_s
(
"Can't find %s.o"
,
project_node
->
pro_fname
);
}
file_name
=
memory_allocate
(
strlen
(
o_file_name
)
+
1
);
strcpy
(
file_name
,
o_file_name
);
*
arg
++=
file_name
;
}
}
for_l
(
library
,
first_library
,
library_next
){
int
s
;
s
=
strlen
(
library
->
library_file_name
);
if
(
s
>=
2
&&
library
->
library_file_name
[
0
]
!=
':'
&&
library
->
library_file_name
[
s
-
2
]
==
'.'
&&
library
->
library_file_name
[
s
-
1
]
==
'o'
)
*
arg
++=
library
->
library_file_name
;
}
*
arg
=
NULL
;
{
int
pid
,
r
,
status
;
char
**
a
;
a
=
argv
;
while
(
*
a
){
printf
(
"%s
\n
"
,
*
a
);
++
a
;
}
pid
=
fork
();
if
(
pid
<
0
)
error
(
"Fork failed"
);
if
(
!
pid
){
char
linker_file_name_
[
PATH_NAME_STRING_SIZE
];
strcpy
(
linker_file_name_
,
clean_lib_path
);
strcat
(
linker_file_name_
,
"/linker"
);
execv
(
linker_file_name_
,
argv
);
error
(
"Can't execute the linker"
);
}
r
=
wait_for_child
(
pid
,
"Linker"
,
&
status
);
if
(
!
(
r
>=
0
/* && status==0*/
))
return
0
;
}
# endif
arg
=
argv
;
...
...
@@ -3332,13 +3410,16 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
# endif
# endif
# if (defined (_WINDOWS_) && !defined (USE_WLINK)) || defined (OMF)
# ifdef NO_CLIB
# ifdef OPTIMISE_LINK
*
arg
++
=
"a.o"
;
# else
# if (defined (_WINDOWS_) && !defined (USE_WLINK)) || defined (OMF)
# ifdef NO_CLIB
strcpy
(
startup0_file_name
,
clean_lib_path
);
strcat
(
startup0_file_name
,
"
\\
_startup0"
OBJECT_FILE_EXTENSION
);
*
arg
++=
startup0_file_name
;
# endif
# ifdef OS2
#
endif
#
ifdef OS2
{
P_NODE
project_node
;
...
...
@@ -3346,11 +3427,11 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
if
(
!
strcmp
(
project_node
->
pro_fname
,
"_startup1"
))
break
;
if
(
project_node
==
NULL
){
# endif
#
endif
strcpy
(
startup1_file_name
,
clean_lib_path
);
strcat
(
startup1_file_name
,
"
\\
_startup1"
OBJECT_FILE_EXTENSION
);
*
arg
++=
startup1_file_name
;
# ifdef OS2
#
ifdef OS2
}
}
{
...
...
@@ -3360,22 +3441,22 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
if
(
!
strcmp
(
project_node
->
pro_fname
,
"_startup2"
))
break
;
if
(
project_node
==
NULL
){
# endif
#
endif
strcpy
(
startup2_file_name
,
clean_lib_path
);
strcat
(
startup2_file_name
,
"
\\
_startup2"
OBJECT_FILE_EXTENSION
);
*
arg
++=
startup2_file_name
;
# ifdef OS2
}
}
# endif
# else
# if !(!defined (LINUX) && defined (SOLARIS))
#
endif
#
else
#
if !(!defined (LINUX) && defined (SOLARIS))
need_file
(
"_startup"
,
OBJECT_FILE_EXTENSION
,
start_up_file_name
);
# endif
#
endif
*
arg
++=
start_up_file_name
;
# endif
#
endif
# ifdef OS2
#
ifdef OS2
{
P_NODE
project_node
;
...
...
@@ -3383,49 +3464,59 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
if
(
!
strcmp
(
project_node
->
pro_fname
,
"_system"
))
break
;
if
(
project_node
==
NULL
){
# endif
#
endif
need_file
(
"_system"
,
OBJECT_FILE_EXTENSION
,
system_file_name
);
*
arg
++=
system_file_name
;
# ifdef OS2
#
ifdef OS2
}
}
# endif
#
endif
for_l
(
project_node
,
first_project_node
,
pro_next
){
if
(
project_node
->
pro_up_to_date
&&
!
project_node
->
pro_ignore_o
){
char
*
file_name
;
# ifdef _WINDOWS_
#
ifdef _WINDOWS_
FileTime
time
;
# endif
#
endif
# if ! MACINTOSH
#
if ! MACINTOSH
if
(
!
find_clean_system_file
(
project_node
->
pro_fname
,
OBJECT_FILE_EXTENSION
,
o_file_name
,
clean_o_path
!=
NULL
?
clean_o_path
:
clean_abc_path
# ifdef _WINDOWS_
#
ifdef _WINDOWS_
,
&
time
# endif
#
endif
))
{
error_s
(
"Can't find %s.o"
,
project_node
->
pro_fname
);
}
# else
#
else
if
(
!
find_clean_system_file
(
project_node
->
pro_fname
,
OBJECT_FILE_EXTENSION
,
o_file_name
))
error_s
(
"Can't find %s"
OBJECT_FILE_EXTENSION
,
project_node
->
pro_fname
);
# endif
#
endif
file_name
=
memory_allocate
(
strlen
(
o_file_name
)
+
1
);
strcpy
(
file_name
,
o_file_name
);
# ifdef USE_WLINK
#
ifdef USE_WLINK
*
arg
++=
"file"
;
# endif
#
endif
*
arg
++=
file_name
;
}
}
# endif
#ifndef OS2
for_l
(
library
,
first_library
,
library_next
)
for_l
(
library
,
first_library
,
library_next
){
# ifdef OPTIMISE_LINK
int
s
;
if
(
library
->
library_file_name
[
0
]
==
':'
)
*
arg
++=&
library
->
library_file_name
[
1
];
else
if
(
s
=
strlen
(
library
->
library_file_name
),
!
(
s
>=
2
&&
library
->
library_file_name
[
s
-
2
]
==
'.'
&&
library
->
library_file_name
[
s
-
1
]
==
'o'
))
# endif
*
arg
++=
library
->
library_file_name
;
}
#endif
# if MACINTOSH
...
...
@@ -3503,11 +3594,11 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
*
arg
++=
"e:
\\
emx
\\
lib
\\
st
\\
c_app.lib"
;
*
arg
++=
"e:
\\
emx
\\
lib
\\
st
\\
sys.lib"
;
# endif
~
#ifdef OS2
#
ifdef OS2
for_l
(
library
,
first_library
,
library_next
)
*
arg
++=
library
->
library_file_name
;
#endif
#
endif
# ifdef NO_CLIB
strcpy
(
os2lib_file_name
,
clean_lib_path
);
...
...
@@ -3632,7 +3723,7 @@ static void print_version (void)
);
}
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
static
void
print_help
(
void
)
{
print_version
();
...
...
@@ -3688,7 +3779,7 @@ static void print_version_and_variables (void)
static
void
argument_error
(
void
)
{
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
print_help
();
#else
printf
(
"Usage: clm [options] module_name [-o application_name]
\n
"
);
...
...
@@ -3988,7 +4079,7 @@ int main (int argc,char **argv)
get_paths
();
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
main_module_name
=
NULL
;
for
(
arg_n
=
1
;
arg_n
<
argc
;
++
arg_n
){
...
...
@@ -3999,7 +4090,7 @@ int main (int argc,char **argv)
argument
=
argv
[
arg_n
];
#if defined (MAKE_MPW_TOOL) && defined (N
EWBRIDGE
)
#if defined (MAKE_MPW_TOOL) && defined (N
B
)
if
(
argument
[
0
]
!=
'-'
){
if
(
main_module_name
!=
NULL
)
error_s
(
"Error in arguments: only one file name allowed: %s"
,
argument
);
...
...
@@ -4333,7 +4424,7 @@ int main (int argc,char **argv)
unlink
(
options_file_name
);
return
1
;
}
/* RWS debug
unlink (options_file_name);
*/
unlink
(
options_file_name
);
# if defined (OS2) && defined (OMF)
if
(
window_application
&&
!
add_resource_to_application
(
application_file_name
))
return
1
;
...
...
@@ -4345,7 +4436,7 @@ int main (int argc,char **argv)
}
}
#ifdef N
EWBRIDGE
#ifdef N
B
}
#endif
...
...
Write
Preview
Supports
Markdown
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