| 1 |
#! /bin/bash |
|---|
| 2 |
|
|---|
| 3 |
# compile osian kernel |
|---|
| 4 |
|
|---|
| 5 |
# Copyright (c) 2006, Jonas Zaddach & Brad DeMorrow |
|---|
| 6 |
# All rights reserved. |
|---|
| 7 |
# |
|---|
| 8 |
# Redistribution and use in source and binary forms, |
|---|
| 9 |
# with or without modification, are permitted provided |
|---|
| 10 |
# that the following conditions are met: |
|---|
| 11 |
# |
|---|
| 12 |
# * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 |
# this list of conditions and the following disclaimer. |
|---|
| 14 |
# * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 |
# this list of conditions and the following disclaimer in the documentation |
|---|
| 16 |
# and/or other materials provided with the distribution. |
|---|
| 17 |
# * Neither the name of the <ORGANIZATION> nor the names of its contributors |
|---|
| 18 |
# may be used to endorse or promote products derived from this software |
|---|
| 19 |
# without specific prior written permission. |
|---|
| 20 |
# |
|---|
| 21 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 22 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|---|
| 23 |
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 24 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
|---|
| 25 |
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 31 |
# POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 |
|
|---|
| 33 |
#split path variable into pieces |
|---|
| 34 |
ALL_PATH=`echo $PATH | sed -e 's/:/\n/g'` |
|---|
| 35 |
|
|---|
| 36 |
#try to find build |
|---|
| 37 |
if [ "$CUSTOM_BUILD" == "" ] |
|---|
| 38 |
then |
|---|
| 39 |
for MY_PATH in $ALL_PATH |
|---|
| 40 |
do |
|---|
| 41 |
CUSTOM_BUILD=`find $MY_PATH -name build 2> /dev/null` |
|---|
| 42 |
if [ "$CUSTOM_BUILD" != "" ] |
|---|
| 43 |
then |
|---|
| 44 |
break |
|---|
| 45 |
fi |
|---|
| 46 |
done |
|---|
| 47 |
|
|---|
| 48 |
if [ "$CUSTOM_BUILD" == "" ] |
|---|
| 49 |
then |
|---|
| 50 |
echo 'build not found in your $PATH variable.' |
|---|
| 51 |
echo 'Please specify location of your build in $CUSTOM_BUILD.' |
|---|
| 52 |
exit |
|---|
| 53 |
fi |
|---|
| 54 |
fi |
|---|
| 55 |
|
|---|
| 56 |
echo "compiling D source files ..." |
|---|
| 57 |
echo "using build: $CUSTOM_BUILD" |
|---|
| 58 |
|
|---|
| 59 |
mkdir -p tmp/objs |
|---|
| 60 |
|
|---|
| 61 |
$CUSTOM_BUILD -obj -odtmp/objs osian/kernel/boot/main.d |
|---|
| 62 |
|
|---|
| 63 |
# unfortunately, build creates directory structure for object files |
|---|
| 64 |
ALL_OBJS=`find tmp/objs/osian/kernel -name "*.o"` |
|---|
| 65 |
for OBJ in $ALL_OBJS |
|---|
| 66 |
do |
|---|
| 67 |
OBJ_NAME=`echo $OBJ | sed -e 's/^.*tmp\/objs\///' | sed -e 's/\//_/g'` |
|---|
| 68 |
mv -f $OBJ tmp/objs/$OBJ_NAME 2> /dev/null |
|---|
| 69 |
done |
|---|