Skip to content

Commit dc5cbfe

Browse files
committed
adding support for build install target
1 parent e1c8ff0 commit dc5cbfe

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

Makefile.in

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include config.mk
22

3-
all:
3+
all:
44
$(MAKE) -C $(VORTEX_HOME)/third_party
55
$(MAKE) -C hw
66
$(MAKE) -C sim
@@ -28,3 +28,40 @@ clean-all:
2828
$(MAKE) -C kernel clean
2929
$(MAKE) -C runtime clean
3030
$(MAKE) -C tests clean-all
31+
32+
# Install setup
33+
KERNEL_DIRS = $(PREFIX)/kernel/include $(PREFIX)/kernel/lib
34+
RUNTIME_DIRS = $(PREFIX)/runtime/include $(PREFIX)/runtime/lib
35+
KERNEL_LIB = kernel/libvortex.a
36+
RUNTIME_LIB = runtime/stub/libvortex.so
37+
38+
KERNEL_LIB_DST = $(PREFIX)/kernel/lib
39+
RUNTIME_LIB_DST = $(PREFIX)/runtime/lib
40+
KERNEL_INC_DST = $(PREFIX)/kernel/include
41+
RUNTIME_INC_DST = $(PREFIX)/runtime/include
42+
43+
KERNEL_HEADERS = $(wildcard $(VORTEX_HOME)/kernel/include/*.h)
44+
RUNTIME_HEADERS = $(wildcard $(VORTEX_HOME)/runtime/include/*.h)
45+
46+
INSTALL_DIRS = $(KERNEL_LIB_DST) $(RUNTIME_LIB_DST) $(KERNEL_INC_DST) $(RUNTIME_INC_DST)
47+
48+
$(INSTALL_DIRS):
49+
mkdir -p $@
50+
51+
$(KERNEL_INC_DST)/%.h: $(VORTEX_HOME)/kernel/include/%.h | $(KERNEL_INC_DST)
52+
cp $< $@
53+
54+
$(RUNTIME_INC_DST)/%.h: $(VORTEX_HOME)/runtime/include/%.h | $(RUNTIME_INC_DST)
55+
cp $< $@
56+
57+
$(KERNEL_LIB_DST)/libvortex.a: kernel/libvortexrt.a | $(KERNEL_LIB_DST)
58+
cp $< $@
59+
60+
$(RUNTIME_LIB_DST)/libvortex.so: runtime/stub/libvortex.so | $(RUNTIME_LIB_DST)
61+
cp $< $@
62+
63+
install: $(INSTALL_DIRS) \
64+
$(KERNEL_HEADERS:$(VORTEX_HOME)/kernel/include/%=$(KERNEL_INC_DST)/%) \
65+
$(RUNTIME_HEADERS:$(VORTEX_HOME)/runtime/include/%=$(RUNTIME_INC_DST)/%) \
66+
$(KERNEL_LIB_DST)/libvortex.a \
67+
$(RUNTIME_LIB_DST)/libvortex.so

config.mk.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ TOOLDIR ?= @TOOLDIR@
1919

2020
OSVERSION ?= @OSVERSION@
2121

22+
PREFIX ?= @PREFIX@
23+
2224
LLVM_VORTEX ?= $(TOOLDIR)/llvm-vortex
2325

2426
LIBC_VORTEX ?= $(TOOLDIR)/libc$(XLEN)

configure

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
# Determine the current working directory
17+
CURRENT_DIR=$(pwd)
18+
1619
# Function to detect current OS
1720
detect_osversion() {
1821
local osversion="unsupported"
@@ -60,7 +63,7 @@ copy_files() {
6063
filename_no_ext="${filename%.in}"
6164
dest_file="$dest_dir/$filename_no_ext"
6265
mkdir -p "$dest_dir"
63-
sed "s|@VORTEX_HOME@|$SCRIPT_DIR|g; s|@XLEN@|$XLEN|g; s|@TOOLDIR@|$TOOLDIR|g; s|@OSVERSION@|$OSVERSION|g" "$file" > "$dest_file"
66+
sed "s|@VORTEX_HOME@|$SCRIPT_DIR|g; s|@XLEN@|$XLEN|g; s|@TOOLDIR@|$TOOLDIR|g; s|@OSVERSION@|$OSVERSION|g; s|@PREFIX@|$PREFIX|g" "$file" > "$dest_file"
6467
# apply permissions to bash scripts
6568
read -r firstline < "$dest_file"
6669
if [[ "$firstline" =~ ^#!.*bash ]]; then
@@ -110,6 +113,7 @@ copy_files() {
110113
default_xlen=32
111114
default_tooldir=/opt
112115
default_osversion=$(detect_osversion)
116+
default_prefix=$CURRENT_DIR
113117

114118
# load default configuration parameters from existing config.mk
115119
if [ -f "config.mk" ]; then
@@ -121,6 +125,7 @@ if [ -f "config.mk" ]; then
121125
XLEN\ ?*) default_xlen=${value//\?=/} ;;
122126
TOOLDIR\ ?*) default_tooldir=${value//\?=/} ;;
123127
OSVERSION\ ?*) default_osversion=${value//\?=/} ;;
128+
PREFIX\ ?*) default_prefix=${value//\?=/} ;;
124129
esac
125130
done < config.mk
126131
fi
@@ -129,20 +134,23 @@ fi
129134
XLEN=${XLEN:=$default_xlen}
130135
TOOLDIR=${TOOLDIR:=$default_tooldir}
131136
OSVERSION=${OSVERSION:=$default_osversion}
137+
PREFIX=${PREFIX:=$default_prefix}
132138

133139
# parse command line arguments
134140
usage() {
135141
echo "Usage: $0 [--xlen=<value>] [--tooldir=<path>] [--osversion=<version>]"
136142
echo " --xlen=<value> Set the XLEN value (default: 32)"
137143
echo " --tooldir=<path> Set the TOOLDIR path (default: /opt)"
138-
echo " --osversion=<version> Set the OS Version (default: $(detect_os))"
144+
echo " --osversion=<version> Set the OS Version (default: $(detect_os))"
145+
echo " --prefix=<path> Set installation directory"
139146
exit 1
140147
}
141148
while [[ "$#" -gt 0 ]]; do
142149
case $1 in
143150
--xlen=*) XLEN="${1#*=}" ;;
144151
--tooldir=*) TOOLDIR="${1#*=}" ;;
145152
--osversion=*) OSVERSION="${1#*=}" ;;
153+
--prefix=*) PREFIX="${1#*=}" ;;
146154
-h|--help) usage ;;
147155
*) echo "Unknown parameter passed: $1"; usage ;;
148156
esac
@@ -161,9 +169,6 @@ SUBDIRS=("." "!ci" "!perf" "hw*" "kernel*" "runtime*" "sim*" "tests*")
161169
# Get the directory of the script
162170
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
163171

164-
# Determine the current working directory
165-
CURRENT_DIR=$(pwd)
166-
167172
THIRD_PARTY_DIR=$SCRIPT_DIR/third_party
168173

169174
copy_files "$SCRIPT_DIR" "$CURRENT_DIR"

0 commit comments

Comments
 (0)