Build file templates: make sure to depend on generated header files
authorRichard Levitte <levitte@openssl.org>
Mon, 13 Jun 2016 20:02:11 +0000 (22:02 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 14 Jun 2016 20:11:38 +0000 (22:11 +0200)
As well as properly generating those that are made from .in files.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Configurations/descrip.mms.tmpl
Configurations/unix-Makefile.tmpl
Configurations/windows-makefile.tmpl

index 3314a1701770702874f238858886c6b0acd5e3c9..66eaeadd6ae6b94b1b6498182f10773c859f99db 100644 (file)
@@ -113,6 +113,8 @@ DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
                     keys %{$unified_info{sources}};
         join(", ", map { "-\n\t".$_ } @deps); -}
 {- output_on() if $disabled{makedepend}; "" -}
+GENERATED_MANDATORY={- join(",", @{$unified_info{depends}->{""}} ) -}
+
 {- output_off() if $disabled{apps}; "" -}
 BIN_SCRIPTS=[.tools]c_rehash.pl
 MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
@@ -221,20 +223,20 @@ NODEBUG=@
 
 # The main targets ###################################################
 
-all : configdata.pm, -
+all : $(GENERATED_MANDATORY), -
       build_libs_nodep, build_engines_nodep, build_apps_nodep, -
       depend
 
-build_libs : configdata.pm, build_libs_nodep, depend
+build_libs : $(GENERATED_MANDATORY), build_libs_nodep, depend
 build_libs_nodep : $(LIBS)
-build_engines : configdata.pm, build_engines_nodep, depend
+build_engines : $(GENERATED_MANDATORY), build_engines_nodep, depend
 build_engines_nodep : $(ENGINES)
-build_apps : configdata.pm, build_apps_nodep, depend
+build_apps : $(GENERATED_MANDATORY), build_apps_nodep, depend
 build_apps_nodep : $(PROGRAMS), $(SCRIPTS)
-build_tests : configdata.pm, build_tests_nodep, depend
+build_tests : $(GENERATED_MANDATORY), build_tests_nodep, depend
 build_tests_nodep : $(TESTPROGS)
 
-test tests : configdata.pm, -
+test tests : $(GENERATED_MANDATORY), -
              build_apps_nodep, build_engines_nodep, build_tests_nodep, -
              depend
         @ ! {- output_off() if $disabled{tests}; "" -}
@@ -292,6 +294,7 @@ install : install_sw install_docs
 uninstall : uninstall_docs uninstall_sw
 
 clean : libclean
+        - DELETE {- join(",", map { "$_;*" } @{$unified_info{depends}->{""}} ) -}
         - DELETE []OSSL$LIB*.EXE;*,OSSL$LIB*.MAP;*,OSSL$LIB*.OPT;*
         - DELETE [.engines...]LIB*.EXE;*,LIB*.MAP;*,LIB*.OPT;*
         - DELETE [.apps]*.EXE;*,*.MAP;*,*.OPT;*
@@ -301,6 +304,10 @@ clean : libclean
         - DELETE [.test]*.LOG;*
         - DELETE []*.MAP;*
 
+distclean : clean
+        - DELETE configdata.pm;*
+        - DELETE descrip.mms;*
+
 depend : descrip.mms
 descrip.mms : FORCE
        @ ! {- output_off() if $disabled{makedepend}; "" -}
@@ -464,10 +471,21 @@ configdata.pm : {- join(" ", sourcefile("Configurations", "descrip.mms.tmpl"), s
       my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
 
       if ($args{src} !~ /\.[sS]$/) {
-          return <<"EOF";
+          if ($args{generator}->[0] =~ m|^.*\.in$|) {
+             my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
+                                                   "util", "dofile.pl")),
+                                   rel2abs($config{builddir}));
+              return <<"EOF";
+$args{src} : $args{generator}->[0] $deps
+       \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
+           "-o$target{build_file}" $generator > \$@
+EOF
+         } else {
+              return <<"EOF";
 $args{src} : $args{generator}->[0] $deps
        \$(PERL)$generator_incs $generator > \$@
 EOF
+         }
       } else {
           die "No method to generate assembler source present.\n";
       }
index c595fd84e5ceee6a76502359bf78b6bcd8796aa0..2e5dd68b4851694177f817c865703c1cff8c92e7 100644 (file)
@@ -84,6 +84,7 @@ DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
                   keys %{$unified_info{sources}}); -}
 {- output_on() if $disabled{makedepend}; "" -}
+GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
 GENERATED={- join(" ",
                   ( map { (my $x = $_) =~ s|\.S$|\.s|; $x }
                     grep { defined $unified_info{generate}->{$_} }
@@ -209,20 +210,22 @@ PROCESSOR= {- $config{processor} -}
 
 # The main targets ###################################################
 
-all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
+all: $(GENERATED_MANDATORY) \
+     build_libs_nodep build_engines_nodep build_apps_nodep \
      depend link-utils
 
-build_libs: configdata.pm build_libs_nodep depend
+build_libs: $(GENERATED_MANDATORY) build_libs_nodep depend
 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
-build_engines: configdata.pm build_engines_nodep depend
+build_engines: $(GENERATED_MANDATORY) build_engines_nodep depend
 build_engines_nodep: $(ENGINES)
-build_apps: configdata.pm build_apps_nodep depend
+build_apps: $(GENERATED_MANDATORY) build_apps_nodep depend
 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
-build_tests: configdata.pm build_tests_nodep depend
+build_tests: $(GENERATED_MANDATORY) build_tests_nodep depend
 build_tests_nodep: $(TESTPROGS)
 
 test: tests
-tests: build_tests_nodep build_apps_nodep build_engines_nodep \
+tests: $(GENERATED_MANDATORY) \
+       build_tests_nodep build_apps_nodep build_engines_nodep \
        depend link-utils
        @ : {- output_off() if $disabled{tests}; "" -}
        ( cd test; \
@@ -267,6 +270,10 @@ clean: libclean
        -rm -f `find . -type l -a \! -path "./.git/*"`
        rm -f $(TARFILE)
 
+distclean: clean
+       rm -f configdata.pm
+       rm -f Makefile
+
 # This exists solely for those who still type 'make depend'
 #
 # We check if any depfile is newer than Makefile and decide to
@@ -829,10 +836,21 @@ configdata.pm: $(SRCDIR)/Configurations/unix-Makefile.tmpl $(SRCDIR)/Configurati
       my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
 
       if ($args{src} !~ /\.[sS]$/) {
-          return <<"EOF";
+          if ($args{generator}->[0] =~ m|^.*\.in$|) {
+              my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
+                                                   "util", "dofile.pl")),
+                                   rel2abs($config{builddir}));
+              return <<"EOF";
+$args{src}: $args{generator}->[0] $deps
+       \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
+           "-o$target{build_file}" $generator > \$@
+EOF
+         } else {
+              return <<"EOF";
 $args{src}: $args{generator}->[0] $deps
        \$(PERL)$generator_incs $generator > \$@
 EOF
+         }
       } else {
           if ($args{generator}->[0] =~ /\.pl$/) {
               $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
index 081e20b3f3019160e39595c35addf8d7587e7e61..b1c5554f6b77447bfc6b361582b9a19656a3520f 100644 (file)
@@ -77,6 +77,7 @@ DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
                   keys %{$unified_info{sources}}); -}
 {- output_on() if $disabled{makedepend}; "" -}
+GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
 GENERATED={- join(" ",
                   ( map { (my $x = $_) =~ s|\.[sS]$|\.asm|; $x }
                     grep { defined $unified_info{generate}->{$_} }
@@ -144,19 +145,21 @@ PROCESSOR= {- $config{processor} -}
 
 # The main targets ###################################################
 
-all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
+all: $(GENERATED_MANDATORY) \
+     build_libs_nodep build_engines_nodep build_apps_nodep depend
 
-build_libs: configdata.pm build_libs_nodep depend
+build_libs: $(GENERATED_MANDATORY) build_libs_nodep depend
 build_libs_nodep: $(LIBS)
-build_engines: configdata.pm build_engines_nodep depend
+build_engines: $(GENERATED_MANDATORY) build_engines_nodep depend
 build_engines_nodep: $(ENGINES)
-build_apps: configdata.pm build_apps_nodep depend
+build_apps: $(GENERATED_MANDATORY) build_apps_nodep depend
 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
-build_tests: configdata.pm build_tests_nodep depend
+build_tests: $(GENERATED_MANDATORY) build_tests_nodep depend
 build_tests_nodep: $(TESTPROGS)
 
 test: tests
-tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
+tests: $(GENERATED_MANDATORY) \
+       build_tests_nodep build_apps_nodep build_engines_nodep depend
        @rem {- output_off() if $disabled{tests}; "" -}
        set SRCTOP=$(SRCDIR)
        set BLDTOP=$(BLDDIR)
@@ -196,6 +199,10 @@ clean: libclean
        -del /Q /S /F apps\*.manifest
        -del /Q /S /F test\*.manifest
 
+distclean: clean
+       -del /Q /F configdata.pm
+       -del /Q /F makefile
+
 depend:
 
 # Install helper targets #############################################
@@ -301,10 +308,21 @@ configdata.pm: "{- $config{build_file_template} -}" "$(SRCDIR)\Configure"
           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
 
       if ($target !~ /\.asm$/) {
-          return <<"EOF";
+          if ($args{generator}->[0] =~ m|^.*\.in$|) {
+              my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
+                                                   "util", "dofile.pl")),
+                                   rel2abs($config{builddir}));
+              return <<"EOF";
+$target: "$args{generator}->[0]" $deps
+       "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
+           "-o$target{build_file}" $generator > \$@
+EOF
+         } else {
+              return <<"EOF";
 $target: "$args{generator}->[0]" $deps
        "\$(PERL)"$generator_incs $generator > \$@
 EOF
+         }
       } else {
           if ($args{generator}->[0] =~ /\.pl$/) {
               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;