echo 'ARCH=$(ARCH)' >> $@
echo 'CROSS=$(CROSS)' >> $@
echo 'KCROSS=$(KCROSS)' >> $@
- echo "CC=$(shell bash -c 'type -p $(CC)')" >> $@
- echo "LD=$(shell bash -c 'type -p $(LD)')" >> $@
+ echo 'CC=$(CC)' >> $@
+ echo 'LD=$(LD)' >> $@
echo 'REQFLAGS=$(filter-out -I%,$(REQFLAGS))' >> $@
echo 'OPTFLAGS=$(OPTFLAGS)' >> $@
echo 'LDFLAGS=$(LDFLAGS)' >> $@
- echo "STRIP=$(shell bash -c 'type -p $(STRIP)')" >> $@
+ echo 'STRIP=$(STRIP)' >> $@
echo 'STRIPFLAGS=$(STRIPFLAGS)' >> $@
echo 'EMAIN=$(EMAIN)' >> $@
echo 'BITSIZE=$(BITSIZE)' >> $@
local-clean:
rm -f klibc.config klcc
-local-spotless:
+local-spotless: local-clean
rm -f klibc.spec *~ tags
local-install: $(CROSS)klcc
syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs
rm -rf syscalls
mkdir syscalls
- $(PERL) syscalls.pl SYSCALLS.i $(ARCH) $(BITSIZE) syscalls.nrs ../include/klibc/havesyscall.h
+ $(PERL) syscalls.pl SYSCALLS.i arch/$(ARCH)/sysstub.ph $(ARCH) \
+ $(BITSIZE) syscalls.nrs \
+ syscalls ../include/klibc/havesyscall.h
touch $@
../include/klibc/havesyscall.h: syscalls.dir
socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h
rm -rf socketcalls
mkdir socketcalls
- $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH)
+ $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH) socketcalls
touch $@
%/static.obj: %.dir
# A few system calls are dual-return with the second return value in
# r20 (a4).
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
$stype = $stype || 'common';
$stype = 'common' if ( $stype eq 'dual0' );
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "#include <machine/asm.h>\n";
print OUT "\n";
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\t.text\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
# system call number in r0 (v0), return an error value in r19 (a3) as
# well as the return value in r0 (v0).
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
$stype = $stype || 'common';
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/asm.h>\n";
print OUT "#include <asm/regdef.h>\n";
print OUT "#include <asm/unistd.h>\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.text\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.globl ${fname}\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.section\t\".text.syscall\",\"ax\"\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
$stype = $stype || 'common';
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
$stype = $stype || 'common';
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
# Script to generate system call stubs
#
-sub make_sysstub($$$$@) {
- my($fname, $type, $sname, $stype, @args) = @_;
+sub make_sysstub($$$$$@) {
+ my($outputdir, $fname, $type, $sname, $stype, @args) = @_;
- open(OUT, '>', "syscalls/${fname}.S");
+ open(OUT, '>', "${outputdir}/${fname}.S");
print OUT "#include <asm/unistd.h>\n";
print OUT "\n";
print OUT "\t.type ${fname},\@function\n";
push(@args, $arg);
}
}
-($file, $arch) = @args;
+($file, $arch, $outputdir) = @args;
if (!open(FILE, "< $file")) {
die "$file: $!\n";
}
+print "socketcall-objs := ";
while ( defined($line = <FILE>) ) {
chomp $line;
$line =~ s/\s*[\#\;].*$//; # Strip comments and trailing blanks
push(@cargs, "$arg a".$i++);
}
$nargs = $i;
+ print " \\\n\tsocketcalls/${name}.o";
if ( $arch eq 'i386' ) {
- open(OUT, '>', "socketcalls/${name}.S")
- or die "$0: Cannot open socketcalls/${name}.S\n";
+ open(OUT, '>', "${outputdir}/${name}.S")
+ or die "$0: Cannot open ${outputdir}/${name}.S\n";
print OUT "#include <sys/socketcalls.h>\n";
print OUT "\n";
print OUT "\t.size ${name},.-${name}\n";
close(OUT);
} else {
- open(OUT, '>', "socketcalls/${name}.c")
- or die "$0: Cannot open socketcalls/${name}.c\n";
+ open(OUT, '>', "${outputdir}/${name}.c")
+ or die "$0: Cannot open ${outputdir}/${name}.c\n";
- print OUT "#include \"../socketcommon.h\"\n";
+ print OUT "#include \"socketcommon.h\"\n";
print OUT "\n";
print OUT "#ifndef __NR_${name}\n\n";
die "$file:$.: Could not parse input\n";
}
}
+
+print "\n";
push(@args, $arg);
}
}
-($file, $arch, $bits, $unistd, $havesyscall) = @args;
+($file, $sysstub, $arch, $bits, $unistd, $outputdir, $havesyscall) = @args;
-require "arch/$arch/sysstub.ph";
+require "$sysstub";
if (!open(UNISTD, '<', $unistd)) {
die "$0: $unistd: $!\n";
}
+
while ( defined($line = <UNISTD>) ) {
chomp $line;
die "$0: $file: $!\n";
}
+print "syscall-objs := ";
+
while ( defined($line = <FILE>) ) {
chomp $line;
$line =~ s/\s*(|[\#;].*)$//; # Strip comments and trailing blanks
@args = split(/\s*\,\s*/, $argv);
print HAVESYS "#define _KLIBC_HAVE_SYSCALL_${fname} ${sname}\n";
- make_sysstub($fname, $type, $sname, $stype, @args);
+ print " \\\n\tsyscalls/${fname}.o";
+ make_sysstub($outputdir, $fname, $type, $sname, $stype, @args);
} else {
die "$file:$.: Could not parse input: \"$line\"\n";
}
}
+print "\n";
+
print HAVESYS "\n#endif\n";
close(HAVESYS);
# Usage: makeklcc klcc.in klibc.config perlpath
#
+use File::Spec;
+
($klccin, $klibcconf, $perlpath) = @ARGV;
+sub pathsearch($) {
+ my($file) = @_;
+ my(@path);
+ my($p,$pp);
+
+ if ( $file =~ /\// ) {
+ return File::Spec->rel2abs($file);
+ }
+
+ foreach $p ( split(/\:/, $ENV{'PATH'}) ) {
+ $pp = File::Spec->rel2abs(File::Spec->catpath(undef, $p, $file));
+ return $pp if ( -x $pp );
+ }
+
+ return undef;
+}
+
print "#!${perlpath}\n";
open(KLIBCCONF, '<', $klibcconf) or die "$0: cannot open $klibcconf: $!\n";
chomp $l;
if ( $l =~ /^([^=]+)\=(.*)$/ ) {
$n = $1; $s = $2;
+
+ if ( $n eq 'CC' || $n eq 'LD' || $n eq 'STRIP' ) {
+ $s1 = pathsearch($s);
+ die "$0: Cannot find $n: $s\n" unless ( defined($s1) );
+ $s = $s1;
+ }
+
print "\$$n = \"\Q$s\E\";\n";
print "\@$n = qw($s);\n";
print "\$conf{\'\L$n\E\'} = \\\$$n;\n";