################################################## # Print a Unix style makefile # ################################################## sub print_unix_makefile { my ($makefile, $os, $cc, $lib_opt, $check_opt, $mach_opt, $lang_flags, $warn_flags, $make_shared, $so_obj, $so_link, $obj_suffix, $so_suffix, $static_lib_suffix, $ar_command, $use_ranlib, $src_hash, $check_hash, $include_hash, $docs, $install_root, $header_dir, $lib_dir, $doc_dir, $lib_list) = @_; ################################################## # Some constants # ################################################## my $__TAB__ = "\t"; my $COMMENT_CHAR = '#'; ################################################## # Convert the references to hashes # ################################################## my %src = %{ $src_hash }; my %includes = %{ $include_hash }; my %check = %{ $check_hash }; my %docs = %{ $docs }; ################################################## # Make the library linking list # ################################################## my $link_to = "-lm"; foreach my $lib (@{ $lib_list }) { $link_to .= " -l" . $lib; } ################################################## # Generate a few variables # ################################################## my $lib_flags = '$(LIB_OPT) $(MACH_OPT) $(LANG_FLAGS) $(WARN_FLAGS)'; my $libs = '$(STATIC_LIB)'; if($make_shared) { $lib_flags .= ' $(SO_OBJ_FLAGS)'; $libs .= ' $(SHARED_LIB)'; } my $install_user = os_install_info($os, 'user'); my $install_group = os_install_info($os, 'group'); my $install_cmd_exec = os_install_info($os, 'command'); my $install_cmd_data = os_install_info($os, 'command'); $install_cmd_exec =~ s/OWNER/\$(OWNER)/; $install_cmd_data =~ s/OWNER/\$(OWNER)/; $install_cmd_exec =~ s/GROUP/\$(GROUP)/; $install_cmd_data =~ s/GROUP/\$(GROUP)/; $install_cmd_exec =~ s/MODE/\$(EXEC_MODE)/; $install_cmd_data =~ s/MODE/\$(DATA_MODE)/; ##################### COMMON CODE (PARTIALLY) ###################### sub file_list { my ($spaces, $put_in, $from, $to, %files) = @_; my $len = $spaces; my $list; foreach (sort keys %files) { my $file = $_; my $dir = $put_in; if(!defined($dir)) { $dir = $files{$_}; } if($len > 60) { $list .= "\\\n" . ' 'x$spaces; $len = $spaces; } if(defined($from) and defined($to)) { $file =~ s/$from/$to/; } if(defined($dir)) { $list .= catfile ($dir, $file) . ' '; $len += length($file) + length($dir); } else { $list .= $file . ' '; $len += length($file); } } return $list; } my $includes = file_list(16, undef, undef, undef, %includes); my $lib_obj = file_list(16, $BUILD_LIB_DIR, '(\.cpp$|\.s$|\.S$)', '.'.$obj_suffix, %src, %added_src); my $check_obj = file_list(16, $BUILD_CHECK_DIR, '.cpp', '.'.$obj_suffix, %check); my $doc_list = file_list(16, undef, undef, undef, %docs); ##################### / COMMON CODE (PARTIALLY) ###################### print_header($makefile, $COMMENT_CHAR, 'Compiler Options'); print $makefile <