diff options
| author | Michael Forney <mforney@mforney.org> | 2016-04-17 00:05:36 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2016-04-17 00:06:52 -0700 |
| commit | 49c2d3507ca26b03eebf339444d4ba9fd5112aa3 (patch) | |
| tree | 56b8b71a98d089037946285c29875e7b447f1c51 | |
| parent | 22e7f1a6de75218591090a2ca86c60fdfad7715c (diff) | |
Make $srcdir refer to the src directory, and add $dir for the directory containing gen.rc
| -rw-r--r-- | core/cparser/gen.rc | 5 | ||||
| -rw-r--r-- | core/file/gen.rc | 10 | ||||
| -rw-r--r-- | core/libfirm/gen.rc | 52 | ||||
| -rw-r--r-- | core/plan9port/gen.rc | 12 | ||||
| -rw-r--r-- | core/sbase/gen.rc | 8 | ||||
| -rw-r--r-- | core/sinit/gen.rc | 4 | ||||
| -rw-r--r-- | core/tz/gen.rc | 6 | ||||
| -rw-r--r-- | core/ubase/gen.rc | 4 | ||||
| -rw-r--r-- | core/zlib/gen.rc | 2 | ||||
| -rw-r--r-- | ninja.rc | 2 | ||||
| -rw-r--r-- | rules.ninja | 2 | ||||
| -rwxr-xr-x | setup.rc | 30 |
12 files changed, 68 insertions, 69 deletions
diff --git a/core/cparser/gen.rc b/core/cparser/gen.rc index 725e931d..b72a0c51 100644 --- a/core/cparser/gen.rc +++ b/core/cparser/gen.rc @@ -1,15 +1,14 @@ cflags\ -I core/libfirm/src/include\ -I '$builddir'/core/libfirm\ - -I '$srcdir'/src/src\ + -I '$srcdir'/src\ -I '$outdir' rule revision_hdr 'echo ''#define cparser_REVISION ""'' >$out.tmp && mv $out.tmp $out' build '$outdir'/revision.h revision_hdr -cd src srcs=src/^( main.c */*.c ) for(src in $srcs) cc $src '|' '$outdir'/revision.h '||' '$builddir/core/libfirm/stamp' link cparser $srcs.o '$builddir'/core/libfirm/libfirm.a file bin/cparser '$outdir'/cparser 755 -file share/man/man1/cparser.1 '$srcdir'/src/cparser.1 644 +file share/man/man1/cparser.1 '$srcdir'/cparser.1 644 diff --git a/core/file/gen.rc b/core/file/gen.rc index 6b92f79a..b16292d3 100644 --- a/core/file/gen.rc +++ b/core/file/gen.rc @@ -68,21 +68,21 @@ cflags\ # strlcpy, strlcat, strcasestr, fmtcheck, getopt_long, sig_t, tm_zone, # tm_gmtoff -cd src/magic +cd magic magic_outs=magic/^( Header Localstuff ) -for(src in Header Localstuff) build '$outdir'/magic/$src copy '$srcdir'/src/magic/$src +for(src in Header Localstuff) build '$outdir'/magic/$src copy '$srcdir'/magic/$src cd Magdir srcs=* magic_outs=( $magic_outs magic/$srcs ) -for(src in $srcs) build '$outdir'/magic/$src copy '$srcdir'/src/magic/Magdir/$src +for(src in $srcs) build '$outdir'/magic/$src copy '$srcdir'/magic/Magdir/$src rule magic 'cd $outdir && file -C -m magic' build '$outdir'/magic.mgc magic '|' '$outdir'/$magic_outs let expr s@X.YY@`{echo $version | tr -d .}^@ --\ - build '$outdir'/include/magic.h sed '$srcdir'/src/src/magic.h.in + build '$outdir'/include/magic.h sed '$srcdir'/src/magic.h.in let expr '-e s@__CSECTION__@1@g -e s@__FSECTION__@5@g -e s@__VERSION__@'$version'@g -e s@__MAGIC__@/share/file/magic@g' --\ - build '$outdir'/file.1 sed '$srcdir'/src/doc/file.man + build '$outdir'/file.1 sed '$srcdir'/doc/file.man srcs=(\ src/magic.c\ diff --git a/core/libfirm/gen.rc b/core/libfirm/gen.rc index 8e5bea1e..22bb2819 100644 --- a/core/libfirm/gen.rc +++ b/core/libfirm/gen.rc @@ -1,36 +1,34 @@ cflags\ -I '$outdir' \ - -I '$srcdir'/src/include/libfirm/adt\ - -I '$srcdir'/src/include/libfirm\ - -I '$srcdir'/src/ir/adt\ - -I '$srcdir'/src/ir/ana\ - -I '$srcdir'/src/ir/be/ia32\ - -I '$srcdir'/src/ir/be\ - -I '$srcdir'/src/ir/common\ - -I '$srcdir'/src/ir/ident\ - -I '$srcdir'/src/ir/ir\ - -I '$srcdir'/src/ir/kaps\ - -I '$srcdir'/src/ir/libcore\ - -I '$srcdir'/src/ir/lower\ - -I '$srcdir'/src/ir/lpp\ - -I '$srcdir'/src/ir/opt\ - -I '$srcdir'/src/ir/stat\ - -I '$srcdir'/src/ir/tr\ - -I '$srcdir'/src/ir/tv + -I '$srcdir'/include/libfirm/adt\ + -I '$srcdir'/include/libfirm\ + -I '$srcdir'/ir/adt\ + -I '$srcdir'/ir/ana\ + -I '$srcdir'/ir/be/ia32\ + -I '$srcdir'/ir/be\ + -I '$srcdir'/ir/common\ + -I '$srcdir'/ir/ident\ + -I '$srcdir'/ir/ir\ + -I '$srcdir'/ir/kaps\ + -I '$srcdir'/ir/libcore\ + -I '$srcdir'/ir/lower\ + -I '$srcdir'/ir/lpp\ + -I '$srcdir'/ir/opt\ + -I '$srcdir'/ir/stat\ + -I '$srcdir'/ir/tr\ + -I '$srcdir'/ir/tv backends=( amd64 arm ia32 sparc TEMPLATE ) -rule irspec '$python $srcdir/src/scripts/gen_ir.py $srcdir/src/scripts/ir_spec.py $in >$out.tmp && mv $out.tmp $out' -rule new_nodes '$perl $srcdir/src/ir/be/scripts/generate_new_opcodes.pl $in $outdir' -rule regalloc_if '$perl $srcdir/src/ir/be/scripts/generate_regalloc_if.pl $in $outdir' -rule emitter '$perl $srcdir/src/ir/be/scripts/generate_emitter.pl $in $outdir' - -cd src +rule irspec '$python $srcdir/scripts/gen_ir.py $srcdir/scripts/ir_spec.py $in >$out.tmp && mv $out.tmp $out' +rule new_nodes '$perl $srcdir/ir/be/scripts/generate_new_opcodes.pl $in $outdir' +rule regalloc_if '$perl $srcdir/ir/be/scripts/generate_regalloc_if.pl $in $outdir' +rule emitter '$perl $srcdir/ir/be/scripts/generate_emitter.pl $in $outdir' genhdrs=( nodes.h gen_irnode.h gen_proj_names.h ) gensrcs=( gen_irnode.c gen_irio.c ) for(gensrc in $genhdrs $gensrcs) { - build '$outdir'/$gensrc irspec '$srcdir'/src/scripts/templates/$gensrc + build '$outdir'/$gensrc irspec '$srcdir'/scripts/templates/$gensrc } srcs=( ir/*/*.c '$outdir'/$gensrcs ) @@ -45,14 +43,14 @@ for(backend in $backends) { objs=( $objs $srcs.o ) stampdeps=( $stampdeps gen_$backend^_$types.h ) { - cflags -I '$srcdir'/src/ir/be/$backend + cflags -I '$srcdir'/ir/be/$backend for(type in $types) { outs=( '$outdir'/gen_$backend^_$type.^(c h) )\ - build $"outs $type '$srcdir'/src/ir/be/$backend/$backend^_spec.pl + build $"outs $type '$srcdir'/ir/be/$backend/$backend^_spec.pl } for(src in $srcs) cc $src '||' '$outdir/stamp' } >../$backend.ninja - subninja '$srcdir'/$backend.ninja + subninja '$dir'/$backend.ninja } ar libfirm.a $objs diff --git a/core/plan9port/gen.rc b/core/plan9port/gen.rc index cd03cbc2..d2f3e497 100644 --- a/core/plan9port/gen.rc +++ b/core/plan9port/gen.rc @@ -1,10 +1,10 @@ cflags\ - -I '$srcdir'/src/include\ - -I '$srcdir'/src/src/cmd/rc\ - -I '$srcdir'/src/src/lib9/fmt\ + -I '$srcdir'/include\ + -I '$srcdir'/src/cmd/rc\ + -I '$srcdir'/src/lib9/fmt\ -I '$outdir' -yacc x '$srcdir'/src/src/cmd/rc/syn.y +yacc x '$srcdir'/src/cmd/rc/syn.y static_lib lib9.a src/lib9/^(\ argv0.c\ @@ -90,7 +90,7 @@ srcs=(\ } file bin/rc '$outdir'/rc 755 -file share/man/man1/rc.1 '$srcdir'/src/man/man1/rc.1 644 -file lib/rcmain '$srcdir'/src/rcmain 644 +file share/man/man1/rc.1 '$srcdir'/man/man1/rc.1 644 +file lib/rcmain '$srcdir'/rcmain 644 stamp x.tab.h diff --git a/core/sbase/gen.rc b/core/sbase/gen.rc index 530abb53..86bdb775 100644 --- a/core/sbase/gen.rc +++ b/core/sbase/gen.rc @@ -6,8 +6,6 @@ cflags\ -std'='c99 -Wall -pedantic\ -I '$outdir' -cd src - static_lib libutil.a libutil/*.c static_lib libutf.a libutf/*.c @@ -110,8 +108,8 @@ executables=(\ getconf_hdrs=( confstr limits sysconf pathconf )^_l.h getconf_outs='$outdir'/$getconf_hdrs -rule getconf_headers 'getconf=$$PWD/$srcdir/src/getconf.sh && cd $outdir && $$getconf' -build $"getconf_outs getconf_headers '|' '$srcdir/src/getconf.sh' +rule getconf_headers 'getconf=$$PWD/$srcdir/getconf.sh && cd $outdir && $$getconf' +build $"getconf_outs getconf_headers '|' '$srcdir/getconf.sh' for(exe in $executables) { if(~ $exe install) src=x$exe @@ -121,7 +119,7 @@ for(exe in $executables) { link $exe $src.c.o libutil.a libutf.a file bin/$exe '$outdir'/$exe 755 - file share/man/man1/$exe.1 '$srcdir'/src/$src.1 644 + file share/man/man1/$exe.1 '$srcdir'/$src.1 644 } stamp $getconf_hdrs diff --git a/core/sinit/gen.rc b/core/sinit/gen.rc index 8cfe44b7..556d5564 100644 --- a/core/sinit/gen.rc +++ b/core/sinit/gen.rc @@ -1,9 +1,9 @@ cflags -Wall -Wextra -I '$outdir' -build '$outdir'/config.h copy '$srcdir'/src/config.def.h +build '$outdir'/config.h copy '$srcdir'/config.def.h cc sinit.c '||' '$outdir'/stamp link sinit sinit.c.o file bin/sinit '$outdir'/sinit 755 -file share/man/man8/sinit.8 '$srcdir'/src/sinit.8 644 +file share/man/man8/sinit.8 '$srcdir'/sinit.8 644 stamp config.h diff --git a/core/tz/gen.rc b/core/tz/gen.rc index a4851a4c..6d73e30c 100644 --- a/core/tz/gen.rc +++ b/core/tz/gen.rc @@ -16,13 +16,13 @@ tzdata=(\ rule zic '$zic -d $outdir/zoneinfo $in' for(data in $tzdata) { - zones=`{awk '/^Zone/ {print $2}' src/$data} + zones=`{awk '/^Zone/ {print $2}' $data} if(! ~ $#zones 0) { outs='$outdir'/zoneinfo/$zones - build $"outs zic '$srcdir'/src/$data + build $"outs zic '$srcdir'/$data for(zone in $zones) file share/zoneinfo/$zone '$outdir'/zoneinfo/$zone 644 } ifs=' -' { links=`{awk '/^Link/ {print $2 " " $3}' src/$data} } +' { links=`{awk '/^Link/ {print $2 " " $3}' $data} } for(line in $links) link=`{printf %s $line} sym share/zoneinfo/$link(2) $link(1) } diff --git a/core/ubase/gen.rc b/core/ubase/gen.rc index 55ace420..80c91fdd 100644 --- a/core/ubase/gen.rc +++ b/core/ubase/gen.rc @@ -5,7 +5,7 @@ cflags\ -std'='c99 -Wall -Wextra\ -I '$outdir' -build '$outdir/config.h' copy '$srcdir/src/config.def.h' +build '$outdir/config.h' copy '$srcdir/config.def.h' static_lib libutil.a\ libutil/agetcwd.c\ @@ -32,7 +32,7 @@ fn myexe { cc $exe.c '||' '$outdir/stamp' exe $exe '$outdir'/$exe.c.o '$outdir/libutil.a' file bin/$exe '$outdir'/$exe 755 - if(~ $#* 1) file share/man/man$1/$exe.$1 '$srcdir'/src/$exe.$1 644 + if(~ $#* 1) file share/man/man$1/$exe.$1 '$srcdir'/$exe.$1 644 status=() } diff --git a/core/zlib/gen.rc b/core/zlib/gen.rc index 0cd8d1b6..90c903d7 100644 --- a/core/zlib/gen.rc +++ b/core/zlib/gen.rc @@ -21,5 +21,5 @@ static_lib libz.a\ gzread.c\ gzwrite.c -build '$outdir'/include/zlib.h copy '$srcdir'/src/zlib.h +build '$outdir'/include/zlib.h copy '$srcdir'/zlib.h stamp include/zlib.h @@ -55,7 +55,7 @@ fn cc { src=$1 obj=$src.o { shift if(! ~ $src '$'*) { - src='$srcdir'/src/$src + src='$srcdir'/$src obj='$outdir'/$obj } build $obj cc $src $* diff --git a/rules.ninja b/rules.ninja index a8c9127d..cae07e47 100644 --- a/rules.ninja +++ b/rules.ninja @@ -1,5 +1,5 @@ rule gen - command = rc ./setup.rc $srcdir + command = rc ./setup.rc $dir generator = 1 # toolchain @@ -19,8 +19,8 @@ if(! ~ $#* 0 1) usage . ./ninja.rc fn subgen { - subninja '$srcdir'/$1/local.ninja - gen_inputs=( $gen_inputs phony/'$srcdir'/$1/gen ) + subninja '$dir'/$1/local.ninja + gen_inputs=( $gen_inputs phony/'$dir'/$1/gen ) tree_inputs=( $tree_inputs '$outdir'/$1/root.tree ) tree_perms=( $tree_perms '$outdir'/$1/root.perms ) if(~ $recurse 1 || ! [ -f $1/local.ninja ]) @ gen $1 & @@ -32,35 +32,39 @@ fn gen { if not dir=$dir/$1 cd $1 - ifs=() { oldcwd=`{pwd | head -c -1} } tree_perms=() perms_inputs=() tree_inputs=() gen_inputs=() + ifs=() { absdir=`{pwd | head -c -1} } { - set srcdir $dir - outdir='$builddir' { - if(! ~ $dir .) outdir=$outdir/$dir - set outdir $outdir + set dir $dir + if(~ $dir .) set outdir '$builddir' + if not set outdir '$builddir/$dir' + + if([ -d src ]) { + cd src + if(~ $dir .) set srcdir src + if not set srcdir '$dir/src' } - . ./gen.rc + . $absdir/gen.rc - build 'phony/$srcdir/gen' phony '$srcdir'/local.ninja $gen_inputs - build '$srcdir'/local.ninja gen '|' setup.rc ninja.rc '$srcdir'/gen.rc + build 'phony/$dir/gen' phony '$dir/local.ninja' $gen_inputs + build '$dir/local.ninja' gen '|' setup.rc ninja.rc '$dir/gen.rc' if(! ~ $#tree_perms 0) { - printf '%s\n' $tree_perms >$oldcwd/local.perms - perms_inputs=( $perms_inputs '$srcdir'/local.perms ) + printf '%s\n' $tree_perms >$absdir/local.perms + perms_inputs=( $perms_inputs '$dir'/local.perms ) } if(~ $#perms_inputs 0) build '$outdir/root.perms' stamp if not build '$outdir/root.perms' cat $perms_inputs if(~ $#tree_inputs 0) build '$outdir/root.tree' stamp if not build '$outdir/root.tree' cat $tree_inputs } >local.ninja.tmp - mv $oldcwd/^( local.ninja.tmp local.ninja ) + mv $absdir/^( local.ninja.tmp local.ninja ) if(! ~ $quiet 1) echo 'generated '$dir >[1=2] status=() |
