depend.awk: Allow sort suppression from the command line. Idea from Pat.

This commit is contained in:
nhkeni
2024-03-17 12:17:41 -04:00
parent 118a82c9a0
commit 9dbab97a1e

View File

@@ -11,7 +11,6 @@
# cd .. ; sh sys/unix/setup.sh [sys/unix/hints/FOO] ) # cd .. ; sh sys/unix/setup.sh [sys/unix/hints/FOO] )
# newer usage: # newer usage:
# cd sys/unix ; make -f Makefile.src updatedepend # cd sys/unix ; make -f Makefile.src updatedepend
# #
# This awk program scans each file in sequence, looking for lines beginning # This awk program scans each file in sequence, looking for lines beginning
# with `#include "' and recording the name inside the quotes. For .h files, # with `#include "' and recording the name inside the quotes. For .h files,
@@ -19,6 +18,10 @@
# corresponding .o file; dependencies in nested header files are propagated # corresponding .o file; dependencies in nested header files are propagated
# to the .o target. # to the .o target.
# #
# Variables that can be set on the command line:
# -v dontsortdeps=1 do not sort the dependencies
# -v dontsortfules=1 do not sort the rules
#
# config.h and hack.h get special handling because of their heavy use; # config.h and hack.h get special handling because of their heavy use;
# timestamps for them allow make to avoid rechecking dates on # timestamps for them allow make to avoid rechecking dates on
# subsidiary headers for every source file; # subsidiary headers for every source file;
@@ -34,8 +37,6 @@
# zlib.h ditto # zlib.h ditto
# #
BEGIN { FS = "\"" #for `#include "X"', $2 is X BEGIN { FS = "\"" #for `#include "X"', $2 is X
dosort = 1
dorulesort = 1
special[++sp_cnt] = "../include/config.h" special[++sp_cnt] = "../include/config.h"
special[++sp_cnt] = "../include/hack.h" special[++sp_cnt] = "../include/hack.h"
alt_deps["../include/extern.h"] = "" alt_deps["../include/extern.h"] = ""
@@ -91,7 +92,7 @@ END {
# #
function output_dep(){ function output_dep(){
if(dorulesort){ if(!dontsortrules){
worklist[++worklistctr] = file worklist[++worklistctr] = file
} else { } else {
output_final2() output_final2()
@@ -100,7 +101,7 @@ function output_dep(){
function output_final( x) function output_final( x)
{ {
if(dorulesort){ if(!dontsortrules){
nhsort(worklist, 1, worklistctr, 1) nhsort(worklist, 1, worklistctr, 1)
for(x=1;x<=worklistctr;x++){ for(x=1;x<=worklistctr;x++){
file = worklist[x] file = worklist[x]
@@ -173,7 +174,7 @@ function format_dep(target, source, col, n, i, list, prefix, moc)
#files duplicate the target as next element but we need to skip that too #files duplicate the target as next element but we need to skip that too
first = moc ? 3 : 2 first = moc ? 3 : 2
source = list[first] source = list[first]
if (dosort){ if (!dontsortdeps){
nhsort(list, first, n, 0) nhsort(list, first, n, 0)
} }
for (i = first; i <= n; i++) { for (i = first; i <= n; i++) {