[uClibc]Awk poetry ;) [was: awk replacement for initfini.pl]
Christian MICHON
christian_michon at yahoo.fr
Mon Oct 14 04:34:04 UTC 2002
Done !
1) Look at the end of this email and create the file initfini.awk
( When making so, make sure you do not change any of the backslashes !! )
2) chmod +x initfini.awk
3) Drop the initfini.awk in extra/scripts
4) Edit the lines calling the previous initfini.pl as follow
(namely: libc/sysdeps/linux/common/Makefile)
before:
=======
crti.S crtn.S: initfini.s $(TOPDIR)/extra/scripts/initfini.pl
$(TOPDIR)/extra/scripts/initfini.pl
after:
======
crti.S crtn.S: initfini.s $(TOPDIR)/extra/scripts/initfini.awk
$(TOPDIR)/extra/scripts/initfini.awk initfini.s
Tested on today's CVS with x86 target. Please give it a shot on
other architectures. I tried to remain as fidel as possible to
Erik's previous perl poetry. ( I hope the Code Poet will start
liking awk after this. ;) )
Now I can throw away the bloated perl-5.6/8 from my system.
No offence or flame please: my personal views only ;)
Enjoy !
Christian
=======================================================================
= save as initfini.awk ============
= cut here ========================
#! /usr/bin/awk -f
# vim:ai:sw=2:
BEGIN \
{ alignval="";
endp=0;
end=0;
system("/bin/touch crt[in].S");
system("/bin/rm -f crt[in].S");
omitcrti=0;
omitcrtn=0;
while(getline < "initfini.s")
{ if(/\.endp/) {endp=1}
if(/\.end/) {end=1}
if(/\.align/) {alignval=$2}
}
close("initfini.s");
}
/HEADER_ENDS/{omitcrti=1;omitcrtn=1;getline}
/PROLOG_BEGINS/{omitcrti=0;omitcrtn=0;getline}
/i_am_not_a_leaf/{getline}
/_init:/||/_fini:/{omitcrtn=1}
/PROLOG_PAUSES/{omitcrti=1;getline}
/PROLOG_UNPAUSES/{omitcrti=0;getline}
/PROLOG_ENDS/{omitcrti=1;getline}
/EPILOG_BEGINS/{omitcrtn=0;getline}
/EPILOG_ENDS/{omitcrtn=1;getline}
/TRAILER_BEGINS/{omitcrti=0;omitcrtn=0;getline}
/END_INIT/ \
{ if(endp)
{ gsub("END_INIT",".endp _init",$0)
}
else
{ if(end)
{ gsub("END_INIT",".end _init",$0)
}
else
{ gsub("END_INIT","",$0)
}
}
}
/END_FINI/ \
{ if(endp)
{ gsub("END_FINI",".endp _fini",$0)
}
else
{ if(end)
{ gsub("END_FINI",".end _fini",$0)
}
else
{ gsub("END_FINI","",$0)
}
}
}
/ALIGN/ \
{ if(alignval!="")
{ gsub("ALIGN",sprintf(".align %s",alignval),$0)
}
else
{ gsub("ALIGN","",$0)
}
}
omitcrti==0 {print >> "crti.S"}
omitcrtn==0 {print >> "crtn.S"}
END \
{ close("crti.S");
close("crtn.S");
}
= cut here ========================
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
More information about the uClibc
mailing list