[m-rev.] diff: fix `mmc --make' library bug

Simon Taylor stayl at cs.mu.OZ.AU
Wed Apr 24 18:42:50 AEST 2002


Estimated hours taken: 0.25
Branches: main

compiler/compile_target_code.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Put the `lib' prefix on the filenames for `.a' and `.so' files.

Index: compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.5
diff -u -u -r1.5 compile_target_code.m
--- compile_target_code.m	19 Apr 2002 14:59:23 -0000	1.5
+++ compile_target_code.m	24 Apr 2002 07:50:38 -0000
@@ -778,7 +778,8 @@
 	maybe_write_string(Verbose, "% Linking...\n"),
 	( { LinkTargetType = static_library } ->
 	    	globals__io_lookup_string_option(library_extension, LibExt),
-		module_name_to_file_name(ModuleName, LibExt, yes, LibName),
+		module_name_to_lib_file_name("lib", ModuleName, LibExt,
+			yes, LibName),
 		create_archive(ErrorStream, LibName, ObjectsList, ArCmdOK),
 		maybe_report_stats(Stats),
 		( { ArCmdOK = no } ->
@@ -787,16 +788,19 @@
 			{ Succeeded = yes }
 		)
 	;
-		{ LinkTargetType = shared_library ->
-			SharedLibOpt = "--make-shared-lib ",
-			FileExtOpt = shared_library_extension
+		( { LinkTargetType = shared_library } ->
+			{ SharedLibOpt = "--make-shared-lib " },
+			globals__io_lookup_string_option(
+				shared_library_extension, SharedLibExt),
+			module_name_to_lib_file_name("lib", ModuleName,
+				SharedLibExt, yes, OutputFileName)
 		;
-			SharedLibOpt = "",
-			FileExtOpt = executable_file_extension
-		},
-		globals__io_lookup_string_option(FileExtOpt, OutputFileExt),
-		module_name_to_file_name(ModuleName, OutputFileExt,
-			yes, OutputFileName),
+			{ SharedLibOpt = "" },
+			globals__io_lookup_string_option(
+				executable_file_extension, ExeExt),
+			module_name_to_file_name(ModuleName, ExeExt,
+				yes, OutputFileName)
+		),
 		globals__io_lookup_bool_option(target_debug, Target_Debug),
 		{ Target_Debug = yes ->
 			Target_Debug_Opt = "--no-strip "
Index: make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.2
diff -u -u -r1.2 make.program_target.m
--- make.program_target.m	18 Mar 2002 04:44:09 -0000	1.2
+++ make.program_target.m	24 Apr 2002 07:44:24 -0000
@@ -51,10 +51,7 @@
 		{ ObjModules = set__to_sorted_list(AllModules) }
 	),
 
-	globals__io_get_globals(Globals),
-	module_name_to_file_name(MainModuleName,
-		linked_target_extension(Globals, FileType),
-		no, OutputFileName),
+	linked_target_file_name(MainModuleName, FileType, OutputFileName),
 	get_file_timestamp([dir__this_directory], OutputFileName,
 		MaybeTimestamp, Info4, Info5),
 	
@@ -387,12 +384,12 @@
 		aditi_code, c_header
 		],
 		Info1, Info2),
-	globals__io_lookup_string_option(executable_file_extension, ExeExt),
-	globals__io_lookup_string_option(library_extension, LibExt),
-	globals__io_lookup_string_option(shared_library_extension,
-		SharedLibExt),
-	list__foldl2(remove_file(ModuleName),
-		[module_dep_file_extension, ExeExt, LibExt, SharedLibExt],
-		Info2, Info).
+	remove_file(ModuleName, module_dep_file_extension, Info2, Info3),
+	linked_target_file_name(ModuleName, executable, ExeFileName),
+	linked_target_file_name(ModuleName, static_library, LibFileName),
+	linked_target_file_name(ModuleName, shared_library, SharedLibFileName),
+	list__foldl2(remove_file,
+		[ExeFileName, LibFileName, SharedLibFileName],
+		Info3, Info).
 
 %-----------------------------------------------------------------------------%
Index: make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.3
diff -u -u -r1.3 make.util.m
--- make.util.m	7 Apr 2002 10:22:34 -0000	1.3
+++ make.util.m	24 Apr 2002 07:45:07 -0000
@@ -135,9 +135,9 @@
 :- mode target_extension(in, in) = out is det.
 :- mode target_extension(in, out) = in is nondet.
 
-:- func linked_target_extension(globals, linked_target_type) = string.
-:- mode linked_target_extension(in, in) = out is det.
-:- mode linked_target_extension(in, out) = in is nondet.
+:- pred linked_target_file_name(module_name, linked_target_type, file_name,
+		io__state, io__state).
+:- mode linked_target_file_name(in, in, out, di, uo) is det.
 
 	% Find the extension for the timestamp file for the
 	% given target type, if one exists.
@@ -568,12 +568,15 @@
 target_extension(Globals, object_code(pic)) = Ext :-
 	globals__lookup_string_option(Globals, pic_object_file_extension, Ext).
 
-linked_target_extension(Globals, executable) = Ext :-
-	globals__lookup_string_option(Globals, executable_file_extension, Ext).
-linked_target_extension(Globals, static_library) = Ext :-
-	globals__lookup_string_option(Globals, library_extension, Ext).
-linked_target_extension(Globals, shared_library) = Ext :-
-	globals__lookup_string_option(Globals, shared_library_extension, Ext).
+linked_target_file_name(ModuleName, executable, FileName) -->
+	globals__io_lookup_string_option(executable_file_extension, Ext),
+	module_name_to_file_name(ModuleName, Ext, no, FileName).
+linked_target_file_name(ModuleName, static_library, FileName) -->
+	globals__io_lookup_string_option(library_extension, Ext),
+	module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName).
+linked_target_file_name(ModuleName, shared_library, FileName) -->
+	globals__io_lookup_string_option(shared_library_extension, Ext),
+	module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName).
 
 	% Note that we need a timestamp file for `.err' files because
 	% errors are written to the `.err' file even when writing interfaces.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list