Source

LIME / lib / imp2hdr.awk

Full commit
#!/usr/bin/awk -f
##################################################################
# This AWK scripts performs depth-first search and inclusion 
#
#Copyright (C) 2008 NXP Semiconductors B.V.
#
#This file is part of LIME.
#
#LIME is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License version 2
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#LIME is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with LIME.  If not, see <http://www.gnu.org/licenses/>.
##################################################################
func dump(x) {
	gsub(suff "$","",x)
	if (do_includes) {
		print "#include <" x ".h>"
		return
	}
	print x
}
BEGIN { 
  suff=(suff ? suff : ".imports")
  file[++i]=ARGV[1]
  done[file[i]]=1
  for (;i>0;i--) {
     while ((getline < (file[i]))>0) {
	f=$0 suff
  	if (f in done) continue
	done[f]=1
	file[++i]=f
     	if (preorder) dump(file[i])
     }
     if (postorder && i>1) dump(file[i])
     close(file[i]);
  }
}