diff --git a/libexec/trick/make_makefile_src b/libexec/trick/make_makefile_src index c1a705ff..5eb9d21b 100755 --- a/libexec/trick/make_makefile_src +++ b/libexec/trick/make_makefile_src @@ -239,8 +239,8 @@ LIB_DIR = build/lib ifndef TRICK_VERBOSE_BUILD PRINT_COMPILE = \$(info \$(call COLOR,Compiling) \$<) - PRINT_INC_LINK = \$(info \$(call COLOR,Linking) Contents of \$(dir \$<)) - PRINT_EXE_LINK = \$(info \$(call COLOR,Linking) \$(S_MAIN)) + PRINT_INC_LINK = \$(info \$(call COLOR,Linking) model objects) + PRINT_EXE_LINK = \$(info \$(call COLOR,Linking) \$@) ifeq (\$(MAKECMDGOALS), all) \$(info \$(call COLOR,Building with the following compilation flags:)) \$(info TRICK_CFLAGS = \$(TRICK_CFLAGS)) @@ -255,123 +255,51 @@ S_OBJECT_FILES = build/S_source.o my %object_files_by_type ; my %model_build_dirs ; $num_inc_objs = 0 ; -# list out all of the source and object files +# List out all of the object files and put the list in a file that we can pass to the linker. +# Passing all of them directly to the linker in the command line can exceed the line limit. +open LINK_MODEL_OBJS, ">build/link_model_objs" or die "Could not open build/link_model_objs" ; +print MAKEFILE "MODEL_OBJECTS =" ; foreach $k ( sort keys %files_by_dir ) { - foreach my $ext ( qw{ c C cc cxx cpp c++ l y} ) { - my $print_ext ; - if ( $ext eq "c++" ) { - $print_ext = "CPLUSPLUS" ; - } else { - $print_ext = $ext ; - } + foreach my $ext ( qw{ c C cc cxx cpp c++ } ) { if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) { - print MAKEFILE "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num} =" ; foreach $f ( @{$files_by_dir{$k}{$ext}} ) { print MAKEFILE " \\\n build$k/$files_by_dir{$k}{src_dir}$f" . "o" ; + print LINK_MODEL_OBJS "build$k/$files_by_dir{$k}{src_dir}$f" . "o\n" ; } - push @{$object_files_by_type{$ext}}, "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}" ; - - print MAKEFILE "\n\n\$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}): | build$k/$files_by_dir{$k}{src_dir}\n" ; - if ( ! exists $model_build_dirs{"build$k/$files_by_dir{$k}{src_dir}"}) { - $model_build_dirs{"build$k/$files_by_dir{$k}{src_dir}"} = 1 ; - print MAKEFILE "\nbuild$k/$files_by_dir{$k}{src_dir}:\n" ; - print MAKEFILE "\t\@mkdir -p \$\@\n\n" ; - } - - print MAKEFILE "build/lib/o_${print_ext}_$files_by_dir{$k}{dir_num}.o: \$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num})\n" ; - print MAKEFILE "\t\$(PRINT_INC_LINK)\n" ; - print MAKEFILE "\t\$(ECHO_CMD)\$(LD) \$(LD_PARTIAL) -o \$\@ \$^\n\n" ; $num_inc_objs++ ; } } - if ( scalar @{$files_by_dir{$k}{l}} ne 0 ) { - print MAKEFILE "MODEL_clex_SRC_$files_by_dir{$k}{dir_num} =" ; - foreach $f ( @{$files_by_dir{$k}{l}} ) { - print MAKEFILE " \\\n build$k/$files_by_dir{$k}{src_dir}$f" . "clex" ; - } - print MAKEFILE "\n\n" ; - } - if ( scalar @{$files_by_dir{$k}{y}} ne 0 ) { - print MAKEFILE "MODEL_y_c_SRC_$files_by_dir{$k}{dir_num} =" ; - foreach $f ( @{$files_by_dir{$k}{y}} ) { - print MAKEFILE " \\\n build$k/$files_by_dir{$k}{src_dir}$f" . "y.c" ; - } - print MAKEFILE "\n\n" ; - } -} - -foreach my $ext ( sort keys %object_files_by_type ) { - my $print_ext ; - if ( $ext eq "c++" ) { - $print_ext = "CPLUSPLUS" ; - } else { - $print_ext = $ext ; - } - print MAKEFILE "MODEL_${print_ext}_OBJ =" ; - foreach $f ( @{$object_files_by_type{$ext}} ) { - print MAKEFILE " \\\n \$($f)" ; - } - print MAKEFILE "\n\n" ; } +close LINK_MODEL_OBJS ; # Write out the compile rules for each type of file. -print MAKEFILE -"\${MODEL_c_OBJ}: build\%.o : \%.c +print MAKEFILE " + +# These targets should have an order-only dependency on their directories, which would require +# moving them to a .SECONDEXPANSION section and would complicate the rules. However, these +# directories appear to be created as part of the read_lib_deps function, so I'm leaving it out +# for now. + +build/%.o : /%.c \t\$(PRINT_COMPILE) \t\$(ECHO_CMD)\$(TRICK_CC) \$(TRICK_CFLAGS) \$(TRICK_SYSTEM_CFLAGS) -I\$(build/link_objs" or die "Could not open build/link_objs" ; -foreach $k ( sort keys %files_by_dir ) { - foreach my $ext ( qw{ c C cc cxx cpp c++ l y} ) { - my $print_ext ; - if ( $ext eq "c++" ) { - $print_ext = "CPLUSPLUS" ; - } else { - $print_ext = $ext ; - } - if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) { - print LINKOBJS "build/lib/o_${print_ext}_$files_by_dir{$k}{dir_num}.o\n" ; - } - } -} -close LINKOBJS ; - # write out all of files we processed as dependencies to Makefile_src open MAKEFILEDEPS, ">build/Makefile_src_deps" or die "Could not open build/Makefile_src_deps" ; print MAKEFILEDEPS "build/Makefile_src:" ;