]> xenbits.xensource.com Git - rumpuser-xen.git/commitdiff
app-tools: Provide rumpxen-app-* helpers
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 24 Jun 2014 17:39:09 +0000 (18:39 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 30 Jun 2014 14:52:49 +0000 (15:52 +0100)
Provide:

 * A GCC wrapper which allows a naive Makefile to compile and link an
   "executable" to generate a rump kernel image.  This uses:

 * A GCC specs file.  This provides the right "system" include
   directories - that is, the headers for the rump kernel application
   environment.  It also uses:

 * A stunt wrapper for "ld".  Building a minios-based Xen image needs
   two runs of ld.  This ld wrapper parses and categorises its
   arguments and runs the two appropriate link steps.

 * A pair of simple wrapper scripts for configure and make, which set
   CC and pass the --host= option.

With these changes, and a suitably modified xen.git, we can run
configure and build a relevant subset of the Xen management libraries
and tools.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
.gitignore
Makefile
app-tools/ld [new file with mode: 0755]
app-tools/rumpxen-app-cc.in [new file with mode: 0755]
app-tools/rumpxen-app-configure.in [new file with mode: 0755]
app-tools/rumpxen-app-make.in [new file with mode: 0755]
app-tools/specs.in [new file with mode: 0644]

index 27970b8876ff1a85bba5d2d3aaede5f3d3cc2a5e..cf262395653065d5ea145b74d82604493940e279 100644 (file)
@@ -10,3 +10,8 @@ rumpobj
 rumptools
 include/mini-os/machine
 include/xen
+
+app-tools/rumpxen-app-cc
+app-tools/specs
+app-tools/rumpxen-app-configure
+app-tools/rumpxen-app-make
index d80200471fc1db1161e2bb650b81e8b763f23e8c..3e4e12f017d993c768aeabf07e45b4b37ef07abc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -102,7 +102,7 @@ HTTPD_OBJS+= httpd/bozohttpd.o httpd/main.o httpd/ssl-bozo.o
 HTTPD_OBJS+= httpd/content-bozo.o httpd/dir-index-bozo.o
 
 .PHONY: default
-default: objs $(TARGET)
+default: objs app-tools $(TARGET)
 
 objs:
        mkdir -p $(OBJ_DIR)/lib $(OBJ_DIR)/xen/$(TARGET_ARCH_DIR)
@@ -137,6 +137,38 @@ $(TARGET): links $(OBJS) $(HTTPD_OBJS) $(APP_O) arch_lib
        $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
        #gzip -f -9 -c $@ >$@.gz
 
+
+APP_TOOLS += rumpxen-app-cc specs
+APP_TOOLS += rumpxen-app-configure rumpxen-app-make
+
+.PHONY: app-tools
+app-tools: $(addprefix app-tools/, $(APP_TOOLS))
+
+$(eval \
+APP_TOOLS_LDLIBS := $(patsubst -L%, -L$$(abspath %), $(LDARCHLIB) $(LDLIBS)))
+# We need to expand this twice because the replacement argument to
+# patsubst is normally expanded only once (beforehand), but we want to
+# apply abspath to each individual argument.
+
+APP_TOOLS_OBJS := \
+       $(abspath $(filter-out %/rumpkern_demo.o, $(OBJS))) \
+       $(APP_TOOLS_LDLIBS)
+
+APP_TOOLS_ARCH := $(subst x86_32,i386, \
+                  $(subst x86_64,amd64, \
+                  $(XEN_TARGET_ARCH)))
+
+app-tools/%: app-tools/%.in Makefile Config.mk
+       sed <$< >$@.tmp \
+               -e 's#!ARCH!#$(strip $(APP_TOOLS_ARCH))#;' \
+               -e 's#!BASE!#$(abspath .)#;' \
+               -e 's#!APPTOOLS!#$(abspath app-tools)#;' \
+               -e 's#!OBJS!#$(APP_TOOLS_OBJS)#;' \
+               -e 's#!HEAD_OBJ!#$(abspath $(HEAD_OBJ))#;' \
+               -e 's#!LDSCRIPT!#$(abspath $(LDSCRIPT))#;'
+       if test -x $<; then chmod +x $@.tmp; fi
+       mv -f $@.tmp $@
+
 .PHONY: clean arch_clean
 
 arch_clean:
diff --git a/app-tools/ld b/app-tools/ld
new file mode 100755 (executable)
index 0000000..322dd67
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -e
+outargs=()
+
+fail () { echo >&2 "stunt ld: $*"; exit 127; }
+
+noshift () { fail "no arg for $a"; }
+
+echo "stunt ld: $*"
+
+while [ $# != 0 ]; do
+       a=$1; shift
+       case "$a" in
+       [^-]*|-L*|-l*|--whole-archive|--no-whole-archive)
+               outargs+=("$a")
+               ;;
+       -m)
+               march="$1"; shift || noshift
+               outargs+=("$a" "$march")
+               ;;
+       -o)
+               outfile="$1"; shift || noshift
+               ;;
+       --as-needed|--no-as-needed)
+               ;;
+       --stunt-final-script)
+               finallds="$1"; shift || noshift
+               ;;
+       --stunt-intermediate)
+               inter1="$1"; shift || noshift
+               inter2="$1"; shift || noshift
+               ;;
+       *)
+               fail "unknown option $a"
+               ;;
+       esac
+done
+
+if [ x"$outfile" = x ]; then outfile=a.out; fi
+
+set -x
+ld -nostdlib -r "${outargs[@]}" -o "$inter1"
+objcopy -w -G xenos_* -G _start "$inter1" "$inter2"
+ld -m "$march" -T "$finallds" "$inter2" -o "$outfile"
diff --git a/app-tools/rumpxen-app-cc.in b/app-tools/rumpxen-app-cc.in
new file mode 100755 (executable)
index 0000000..6a80a4a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+case " $* " in
+*" -v "*)   set -x ;;
+esac
+exec gcc -D__RUMPUSER_XEN__ -D__NetBSD__ -specs=!APPTOOLS!/specs "$@"
diff --git a/app-tools/rumpxen-app-configure.in b/app-tools/rumpxen-app-configure.in
new file mode 100755 (executable)
index 0000000..1cbaf73
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# invoke this (for example) as  .../app-configure ./configure --prefix=...
+set -e
+prog=$1; shift
+exec "$prog" --host=!ARCH!-rumpxen-netbsd CC=!APPTOOLS!/rumpxen-app-cc
diff --git a/app-tools/rumpxen-app-make.in b/app-tools/rumpxen-app-make.in
new file mode 100755 (executable)
index 0000000..ea9b1e9
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# invoke this (for example) as  .../app-build make target
+set -e
+prog=$1; shift
+exec "$prog" CC=!APPTOOLS!/rumpxen-app-cc "$@"
diff --git a/app-tools/specs.in b/app-tools/specs.in
new file mode 100644 (file)
index 0000000..99309e8
--- /dev/null
@@ -0,0 +1,20 @@
+%rename cpp_options old_cpp_options
+*cpp_options:
+-nostdinc -isystem !BASE!/rump/include %(old_cpp_options)
+
+*linker:
+!APPTOOLS!/ld --stunt-intermediate %g.link1 %g.link2 --stunt-final-script !LDSCRIPT!
+
+*link:
+%{m64:-m elf_x86_64} %{m64|mx32:;:-m elf_i386} %{mx32:-m elf32_x86_64}
+
+*endfile:
+!OBJS!
+
+*startfile:
+!HEAD_OBJ!
+
+%rename link_libgcc old_link_libgcc
+
+%rename libgcc old_libgcc