Don't distribute team internal config targets
[openssl.git] / Configurations / unix-Makefile.tmpl
index 5d30fae92739c580d0e72d8abd74310520ab2a56..799eaa88059265aec2397b8b2ab573f4701c3422 100644 (file)
@@ -12,6 +12,7 @@
      our $shlibextsimple = $target{shared_extension_simple} || ".so";
      our $shlibextimport = $target{shared_import_extension} || "";
      our $dsoext = $target{dso_extension} || ".so";
+     our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
 
      sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
 
@@ -105,13 +106,9 @@ 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}->{$_} }
-                    map { @{$unified_info{sources}->{$_}} }
-                    grep { /\.o$/ } keys %{$unified_info{sources}} ),
-                  ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
+GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
+GENERATED={- # common0.tmpl provides @generated
+             join(" ", @generated ) -}
 
 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
@@ -254,15 +251,18 @@ CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
 # Variables starting with BIN_ are used to build programs and their object
 # files.
 
-LIB_CPPFLAGS={- join(' ', $target{lib_cppflags} || (),
+LIB_CPPFLAGS={- our $lib_cppflags =
+                join(' ', $target{lib_cppflags} || (),
                           $target{shared_cppflag} || (),
                           (map { '-D'.$_ }
                                @{$config{lib_defines}},
-                               @{$config{shared_defines}},
+                               @{$config{shared_defines}}),
+                          @{$config{lib_cppflags}},
+                          @{$config{shared_cppflag}});
+                join(' ', $lib_cppflags,
+                          (map { '-D'.$_ }
                                'OPENSSLDIR="\"$(OPENSSLDIR)\""',
                                'ENGINESDIR="\"$(ENGINESDIR)\""'),
-                          @{$config{lib_cppflags}},
-                          @{$config{shared_cppflag}},
                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
                         $target{shared_cflag} || (),
@@ -316,7 +316,9 @@ BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
               $cppflags2 =~ s|([\\"])|\\$1|g;
-              join(' ', $cppflags1 || (), $cppflags2 || ()) -}
+              $lib_cppflags =~ s|([\\"])|\\$1|g;
+              join(' ', $lib_cppflags || (), $cppflags2 || (),
+                        $cppflags1 || ()) -}
 
 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
 
@@ -351,6 +353,11 @@ build_apps build_tests: build_programs
 # Convenience target to prebuild all generated files, not just the mandatory
 # ones
 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
+       @ : {- output_off() if $disabled{makedepend}; "" -}
+       @echo "Warning: consider configuring with no-makedepend, because if"
+       @echo "         target system doesn't have $(PERL),"
+       @echo "         then make will fail..."
+       @ : {- output_on() if $disabled{makedepend}; "" -}
 
 test: tests
 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
@@ -383,9 +390,13 @@ uninstall: uninstall_docs uninstall_sw
 
 libclean:
        @set -e; for s in $(SHLIB_INFO); do \
+               if [ "$$s" = ";" ]; then continue; fi; \
                s1=`echo "$$s" | cut -f1 -d";"`; \
                s2=`echo "$$s" | cut -f2 -d";"`; \
-               $(ECHO) $(RM) $$s1; \
+               $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
+               $(RM) apps/$$s1; \
+               $(RM) test/$$s1; \
+               $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
                $(RM) $$s1; \
                if [ "$$s1" != "$$s2" ]; then \
                        $(ECHO) $(RM) $$s2; \
@@ -397,7 +408,7 @@ libclean:
 
 clean: libclean
        $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
-       $(RM) $(GENERATED)
+       $(RM) $(GENERATED_MANDATORY) $(GENERATED)
        -$(RM) `find . -name '*{- $depext -}' -a \! -path "./.git/*"`
        -$(RM) `find . -name '*{- $objext -}' -a \! -path "./.git/*"`
        $(RM) core
@@ -415,19 +426,9 @@ distclean: clean
 # concatenate only if that is true.
 depend:
        @: {- output_off() if $disabled{makedepend}; "" -}
-       @if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
-         ( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
-           echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
-           echo; \
-           for f in $(DEPS); do \
-             if [ -f $$f ]; then cat $$f; fi; \
-           done ) > Makefile.new; \
-         if cmp Makefile.new Makefile >/dev/null 2>&1; then \
-           rm -f Makefile.new; \
-         else \
-           mv -f Makefile.new Makefile; \
-         fi; \
-       fi
+       @$(PERL) $(SRCDIR)/util/add-depends.pl {-
+                defined $makedepprog  && $makedepprog =~ /\/makedepend/
+                 ? 'makedepend' : 'gcc' -}
        @: {- output_on() if $disabled{makedepend}; "" -}
 
 # Install helper targets #############################################
@@ -787,7 +788,7 @@ tags TAGS: FORCE
 
 # If your tar command doesn't support --owner and --group, make sure to
 # use one that does, for example GNU tar
-TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cvf -
+TAR_COMMAND=$(TAR) $(TARFLAGS) --owner 0 --group 0 -cf -
 PREPARE_CMD=:
 tar:
        set -e; \
@@ -796,7 +797,7 @@ tar:
        mkdir -p $$TMPDIR/$$DISTDIR; \
        (cd $(SRCDIR); \
         excl_re=`git submodule status | sed -e 's/^.//' | cut -d' ' -f2`; \
-        excl_re="^(fuzz/corpora|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
+        excl_re="^(fuzz/corpora|Configurations/.*\.norelease\.conf|`echo $$excl_re | sed -e 's/ /$$|/g'`\$$)"; \
         echo "$$excl_re"; \
         git ls-tree -r --name-only --full-tree HEAD \
         | egrep -v "$$excl_re" \
@@ -952,20 +953,6 @@ EOF
               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
           } -> {$args{intent}};
           if (defined($generator)) {
-              # If the target is named foo.S in build.info, we want to
-              # end up generating foo.s in two steps.
-              if ($args{src} =~ /\.S$/) {
-                   (my $target = $args{src}) =~ s|\.S$|.s|;
-                   return <<"EOF";
-$target: $args{generator}->[0] $deps
-       ( trap "rm -f \$@.*" INT 0; \\
-         $generator \$@.S; \\
-         \$(CPP) $incs $cppflags \$@.S | \\
-         \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@.i && \\
-         mv -f \$@.i \$@ )
-EOF
-              }
-              # Otherwise....
               return <<"EOF";
 $args{src}: $args{generator}->[0] $deps
        $generator \$@
@@ -973,7 +960,7 @@ EOF
           }
           return <<"EOF";
 $args{src}: $args{generator}->[0] $deps
-       \$(CPP) $incs $cppflags $args{generator}->[0] | \\
+       \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
        \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
 EOF
       }
@@ -985,24 +972,17 @@ EOF
   sub src2obj {
       my %args = @_;
       (my $obj = $args{obj}) =~ s|\.o$||;
-      my @srcs = map { if ($unified_info{generate}->{$_}) {
-                           (my $x = $_) =~ s/\.S$/.s/; $x
-                       } else {
-                           $_
-                       }
-                     } ( @{$args{srcs}} );
+      my @srcs = @{$args{srcs}};
       my $srcs = join(" ",  @srcs);
       my $deps = join(" ", @srcs, @{$args{deps}});
       my $incs = join("", map { " -I".$_ } @{$args{incs}});
       my $cmd;
       my $cmdflags;
       my $cmdcompile;
-      my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
       if (grep /\.rc$/, @srcs) {
           $cmd = '$(RC)';
           $cmdflags = '$(RCFLAGS)';
           $cmdcompile = '';
-          $makedepprog = undef;
       } elsif (grep /\.(cc|cpp)$/, @srcs) {
           $cmd = '$(CXX)';
           $cmdcompile = ' -c';
@@ -1020,12 +1000,27 @@ EOF
               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
           } -> {$args{intent}};
       }
-      $cmdflags .= $cmdcompile;
-      my $recipe = <<"EOF";
+      my $recipe;
+      # extension-specific rules
+      if (grep /\.s$/, @srcs) {
+          $recipe .= <<"EOF";
+$obj$objext: $deps
+       $cmd $cmdflags -c -o \$\@ $srcs
+EOF
+      } elsif (grep /\.S$/, @srcs) {
+          # Originally there was mutli-step rule with $(CC) -E file.S
+          # followed by $(CC) -c file.s. It compensated for one of
+          # legacy platform compiler's inability to handle .S files.
+          # The platform is long discontinued by vendor so there is
+          # hardly a point to drag it along...
+          $recipe .= <<"EOF";
 $obj$objext: $deps
+       $cmd $incs $cmdflags -c -o \$\@ $srcs
 EOF
-      if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
+      } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
+               && !grep /\.rc$/, @srcs) {
           $recipe .= <<"EOF";
+$obj$objext: $deps
        $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
        \@touch $obj$depext.tmp
        \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
@@ -1036,18 +1031,13 @@ EOF
 EOF
       } else {
           $recipe .= <<"EOF";
-       $cmd $incs $cmdflags -o \$\@ $srcs
+$obj$objext: $deps
+       $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
 EOF
           if (defined $makedepprog  && $makedepprog =~ /\/makedepend/) {
               $recipe .= <<"EOF";
-       -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $srcs \\
-           >$obj$depext.tmp 2>/dev/null
-       -\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
-       \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
-               rm -f $obj$depext.tmp; \\
-       else \\
-               mv $obj$depext.tmp $obj$depext; \\
-       fi
+       \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
+           > $obj$depext
 EOF
           }
       }
@@ -1072,10 +1062,10 @@ EOF
       my $linklibs = join("", map { my $f = basename($_);
                                     (my $l = $f) =~ s/^lib//;
                                     " -l$l" } @{$args{deps}});
-      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
-                 grep { $_ =~ m|\.o$| }
+      my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
+                 grep { $_ !~ m/\.(?:def|map)$/ }
                  @{$args{objs}};
-      my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
+      my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
       my @deps = compute_lib_depends(@{$args{deps}});
       die "More than one exported symbol map" if scalar @defs > 1;
       my $objs = join(" ", @objs);
@@ -1100,7 +1090,7 @@ EOF
 $target: $deps
        \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
                -o $target_full$shared_def $objs \\
-                \$(PLIB_LDFLAGS) $linklibs \$(LIB_EX_LIBS)
+                $linklibs \$(LIB_EX_LIBS)
 EOF
       if (windowsdll()) {
           $recipe .= <<"EOF";
@@ -1134,7 +1124,9 @@ EOF
       my $linklibs = join("", map { my $f = basename($_);
                                     (my $l = $f) =~ s/^lib//;
                                     " -l$l" } @{$args{deps}});
-      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
+      my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
+                 grep { $_ !~ m/\.(?:def|map)$/ }
+                 @{$args{objs}};
       my @deps = compute_lib_depends(@{$args{deps}});
       my $objs = join(" ", @objs);
       my $deps = join(" ", @deps);
@@ -1143,7 +1135,7 @@ EOF
 $target: $objs $deps
        \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
                -o $target $objs \\
-                \$(PLIB_LDFLAGS) $linklibs \$(DSO_EX_LIBS)
+                $linklibs \$(DSO_EX_LIBS)
 EOF
   }
   sub obj2lib {
@@ -1162,7 +1154,7 @@ EOF
       my $bin = $args{bin};
       my $bind = dirname($bin);
       my $binn = basename($bin);
-      my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
+      my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
                            @{$args{objs}});
       my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
       my @linkdirs = ();
@@ -1191,7 +1183,7 @@ $bin$exeext: $objs $deps
        rm -f $bin$exeext
        \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
                -o $bin$exeext $objs \\
-               \$(PLIB_LDFLAGS) $linklibs \$(BIN_EX_LIBS)
+               $linklibs \$(BIN_EX_LIBS)
 EOF
   }
   sub in2script {