From c446452b692d265d423da79fc881ad1907cfb08b Mon Sep 17 00:00:00 2001 From: Skip Hansen Date: Sat, 4 Nov 2023 08:20:51 -0700 Subject: [PATCH] Added support for sdcc 4.0.7 used by https://dmitry.gr projects. Make path's absolute, renamed scripts, added .gitignore --- sdcc/.gitignore | 3 +++ sdcc/README.md | 10 +++++----- sdcc/build_sdcc.sh | 17 ++++++++++++----- sdcc/setup.sh | 26 -------------------------- sdcc/setup_sdcc.sh | 28 ++++++++++++++++++++++++++++ sdcc/{unset.sh => unset_sdcc.sh} | 4 ---- 6 files changed, 48 insertions(+), 40 deletions(-) create mode 100644 sdcc/.gitignore delete mode 100755 sdcc/setup.sh create mode 100755 sdcc/setup_sdcc.sh rename sdcc/{unset.sh => unset_sdcc.sh} (70%) diff --git a/sdcc/.gitignore b/sdcc/.gitignore new file mode 100644 index 00000000..5dc3db17 --- /dev/null +++ b/sdcc/.gitignore @@ -0,0 +1,3 @@ +sdcc-*/ +sdcc/ + diff --git a/sdcc/README.md b/sdcc/README.md index e6c81207..aadd8d9b 100755 --- a/sdcc/README.md +++ b/sdcc/README.md @@ -1,9 +1,9 @@ -This subdirectory contains scripts to build the correct version of SDCC 4.2.0 for compiling 8051 based firmware. +This subdirectory contains scripts to build the correct version of SDCC (4.2.0) for compiling 8051 based firmware. -To use simply source setup.sh before building. The first time setup.sh is run proper version of SDCC sources will be checkout from github and built locally. +To use simply source setup_sdcc.sh before building. The first time setup_sdcc.sh is run proper version of SDCC sources will be checkout from github and built locally. Finally the environment variable CC will be set to 'sdcc' and the path to the local version of sdcc will be added to the beginning of the path. -The script unset.sh can be source to unset the CC environment variable and to restore the path. +The script unset_sdecc.sh can be source to unset the CC environment variable and to restore the path. For example @@ -21,14 +21,14 @@ Note: switching to '4.2.0'. (truncated...) -Added ../sdcc/sdcc/4.2.0/bin to PATH +Added ../sdcc/sdcc-4.2.0/bin to PATH skip@Dell-7040:~/esl/OpenEPaperLink/zbs243_AP_FW$ make sdcc -c main.c -DAP_FW=1 --code-size 0xfc00 -Isoc/zbs243 -DSOC_ZBS243 --xram-loc 0xe000 --xram-size 0x2000 --model-large -Icpu/8051 -mmcs51 --std-c2x --opt-code-size --peep-file cpu/8051/peep.def --fomit-frame-pointer -Iboard/zbs29_ssd1619 -Isoc/zbs243 -Icpu/8051 -I. -o main.rel (truncated...) objcopy main.ihx main.bin -I ihex -O binary -skip@Dell-7040:~/esl/OpenEPaperLink/zbs243_AP_FW$ . ../sdcc/unset.sh +skip@Dell-7040:~/esl/OpenEPaperLink/zbs243_AP_FW$ . ../sdcc/unset_sdcc.sh skip@Dell-7040:~/esl/OpenEPaperLink/zbs243_AP_FW$ ```` diff --git a/sdcc/build_sdcc.sh b/sdcc/build_sdcc.sh index 16969b54..da637e9c 100755 --- a/sdcc/build_sdcc.sh +++ b/sdcc/build_sdcc.sh @@ -1,7 +1,7 @@ #/bin/sh -# build local version of sdcc 4.2.0 from source +# build local version of sdcc from source -SDCC_VER=4.2.0 +SDCC_VER=${1:-4.2.0} if [ ! -e sdcc ]; then git clone https://github.com/swegener/sdcc.git @@ -9,16 +9,20 @@ if [ ! -e sdcc ]; then echo "Couldn't clone https://github.com/swegener/sdcc.git" exit 1 fi + cd sdcc + git tag 4.2.0 56dc646f8ba6d37c039c5e0c3e60b1340da65b9f + git tag 4.0.7 6f1f08a07fc7a05b06e7a2594a930d8984ba817a +else + cd sdcc fi -cd sdcc -git tag 4.2.0 56dc646f8ba6d37c039c5e0c3e60b1340da65b9f + git checkout ${SDCC_VER} if [ $? -ne 0 ]; then echo "Couldn't checkout ${SDCC_VER} source from git" exit 1 fi -./configure --prefix=`pwd`/${SDCC_VER} --disable-z80-port --disable-z180-port --disable-r2k-port --disable-r2ka-port --disable-r3ka-port --disable-sm83-port --disable-tlcs90-port --disable-ez80_z80-port --disable-z80n-port --disable-ds390-port --disable-ds400-port --disable-pic14-port --disable-pic16-port --disable-hc08-port --disable-s08-port --disable-stm8-port --disable-pdk13-port --disable-pdk14-port --disable-pdk15-port --disable-pdk16-port --disable-mos6502-port --disable-mos65c02-port 2>&1 | tee build.log +./configure --prefix=`pwd`/../sdcc-${SDCC_VER} --disable-z80-port --disable-z180-port --disable-r2k-port --disable-r2ka-port --disable-r3ka-port --disable-sm83-port --disable-tlcs90-port --disable-ez80_z80-port --disable-z80n-port --disable-ds390-port --disable-ds400-port --disable-pic14-port --disable-pic16-port --disable-hc08-port --disable-s08-port --disable-stm8-port --disable-pdk13-port --disable-pdk14-port --disable-pdk15-port --disable-pdk16-port --disable-mos6502-port --disable-mos65c02-port 2>&1 | tee build.log make -j8 2>&1 | tee -a build.log if [ $? -ne 0 ]; then echo "sdcc make failed see ./sdcc/build.log for details" @@ -30,5 +34,8 @@ if [ $? -ne 0 ]; then echo "sdcc make install failed see ./sdcc/build.log for details" exit 1 fi +make clean +git reset HEAD --hard +git clean -f -d -x diff --git a/sdcc/setup.sh b/sdcc/setup.sh deleted file mode 100755 index 922e91a7..00000000 --- a/sdcc/setup.sh +++ /dev/null @@ -1,26 +0,0 @@ -#/bin/sh -# set environment variables to use locally built sdcc version 4.2.0 - -#set -x -SDCC_VER=4.2.0 - -if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then - echo "This script must be SOURCED, not run directly (source $0)." - exit 1 -fi - -SDCC_DIR=`dirname ${BASH_SOURCE[0]}` - -if [ ! -e ${SDCC_DIR}/sdcc/${SDCC_VER} ]; then - (cd ${SDCC_DIR};./build_sdcc.sh) -fi - -export CC=sdcc -SDCC_PATH=${SDCC_DIR}/sdcc/${SDCC_VER}/bin -echo $PATH | grep ${SDCC_PATH} > /dev/null -if [ $? -ne 0 ]; then - export SDCC_PATH_SAVE=$PATH - export PATH=${SDCC_PATH}:$PATH - echo "Added ${SDCC_PATH} to PATH" -fi - diff --git a/sdcc/setup_sdcc.sh b/sdcc/setup_sdcc.sh new file mode 100755 index 00000000..c81cc0f8 --- /dev/null +++ b/sdcc/setup_sdcc.sh @@ -0,0 +1,28 @@ +#/bin/sh +# set environment variables to use locally built sdcc + +#set -x +SDCC_VER=${1:-4.2.0} + +if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then + echo "This script must be SOURCED, not run directly (source $0)." + exit 1 +fi + +SETUP_PATH=`readlink -f ${BASH_SOURCE[0]}` +SETUP_DIR=`dirname ${SETUP_PATH}` +SDCC_VER_DIR=${SETUP_DIR}/sdcc-${SDCC_VER} +source ${SETUP_DIR}/unset_sdcc.sh +if [ ! -e ${SDCC_VER_DIR} ]; then + (cd ${SETUP_DIR};./build_sdcc.sh ${SDCC_VER}) +fi + +SDCC_PATH=${SDCC_VER_DIR}/bin +echo $PATH | grep ${SDCC_PATH} > /dev/null +if [ $? -ne 0 ]; then + export CC=sdcc + export SDCC_PATH_SAVE=$PATH + export PATH=${SDCC_PATH}:$PATH + echo "Added ${SDCC_PATH} to PATH" +fi + diff --git a/sdcc/unset.sh b/sdcc/unset_sdcc.sh similarity index 70% rename from sdcc/unset.sh rename to sdcc/unset_sdcc.sh index e7d37aa9..2a106a8c 100755 --- a/sdcc/unset.sh +++ b/sdcc/unset_sdcc.sh @@ -2,15 +2,11 @@ # set environment variables to use locally built sdcc version 4.2.0 #set -x -SDCC_VER=4.2.0 if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then echo "This script must be SOURCED, not run directly (source $0)." exit 1 fi -SDCC_DIR=`dirname ${BASH_SOURCE[0]}` -SDCC_PATH=${SDCC_DIR}/sdcc/${SDCC_VER}/bin -echo $PATH | grep ${SDCC_PATH} > /dev/null if [ ! "${SDCC_PATH_SAVE}x" = "x" ]; then export PATH=${SDCC_PATH_SAVE} export SDCC_PATH_SAVE=