From d2167e033fdf1cfc7bcc35dfd87a31da65dc9324 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 12 Jul 2024 16:48:19 +0200 Subject: [PATCH] Update to macOS compile scripts --- compile_macos_clang.sh | 15 ++++--- compile_macos_clang_M2.sh | 77 ++++++++++++++++++++++++++++++++ compile_macos_clang_M2_shared.sh | 76 +++++++++++++++++++++++++++++++ compile_macos_gcc.sh | 6 ++- compile_macos_shared.sh | 25 +++-------- 5 files changed, 171 insertions(+), 28 deletions(-) create mode 100644 compile_macos_clang_M2.sh create mode 100644 compile_macos_clang_M2_shared.sh diff --git a/compile_macos_clang.sh b/compile_macos_clang.sh index 87268bd1c..0448471c2 100755 --- a/compile_macos_clang.sh +++ b/compile_macos_clang.sh @@ -1,14 +1,17 @@ #!/bin/bash # ngspice build script for macOS, release or debug version, 64 bit -# compile_macos.sh +# compile_macos_clang.sh +# tested with macOS BigSur 11.7.9, MacBook Air i5 +# OpenMP is not available! # Procedure: # Install gcc, bison, flex, libtool, autoconf, automake, # libx11 and libx11-dev (headers), libXaw and libXaw-dev, libreadline and dev -# Declare 'compile_linux.sh' executable and start compiling with -# './compile_macos.sh' or './compile_macos.sh d' from the ngspice directory. +# XCODE and commandline tools +# Declare 'compile_macos_clang.sh' executable and start compiling with +# './compile_macos_clang.sh' or './compile_macos_clang.sh d' from the ngspice directory. # Options: -# CIDER, XSPICE, and OpenMP may be selected at will. +# KLU, OSDI, and XSPICE may be deselected at will. # ngspice as shared library: # Replace --with-x by --with-ngshared in line ../configure ... . @@ -41,13 +44,13 @@ if test "$1" = "d"; then echo # Builtin readline is not compatible (Big Sur), readline via Homebrew required (in /usr/local/opt) # Standard clang does not support OpenMP - ../configure --with-x --enable-cider --with-readline=/usr/local/opt/readline CFLAGS="-m64 -O0 -g -Wall -I/opt/X11/include/freetype2 -I/usr/local/opt/readline/include" LDFLAGS="-m64 -g -L/usr/local/opt/readline/lib -L/opt/X11/lib" + ../configure --with-x --enable-cider --disable-openmp --with-readline=/usr/local/opt/readline CFLAGS="-m64 -O0 -g -Wall -I/opt/X11/include/freetype2 -I/usr/local/opt/readline/include" LDFLAGS="-m64 -g -L/usr/local/opt/readline/lib -L/opt/X11/lib" else cd release if [ $? -ne 0 ]; then echo "cd release failed"; exit 1 ; fi echo "configuring for 64 bit release" echo - ../configure --with-x --enable-cider --with-readline=/usr/local/opt/readline CFLAGS="-m64 -O2 -I/opt/X11/include/freetype2 -I/usr/local/opt/readline/include -I/usr/local/opt/ncurses/include" LDFLAGS="-m64 -L/usr/local/opt/readline/lib -L/usr/local/opt/ncurses/lib -L/opt/X11/lib" + ../configure --with-x --enable-cider --disable-openmp --with-readline=/usr/local/opt/readline CFLAGS="-m64 -O2 -I/opt/X11/include/freetype2 -I/usr/local/opt/readline/include -I/usr/local/opt/ncurses/include" LDFLAGS="-m64 -L/usr/local/opt/readline/lib -L/usr/local/opt/ncurses/lib -L/opt/X11/lib" fi if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi diff --git a/compile_macos_clang_M2.sh b/compile_macos_clang_M2.sh new file mode 100644 index 000000000..0e8150baf --- /dev/null +++ b/compile_macos_clang_M2.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# ngspice build script for macOS, release or debug version, 64 bit +# compile_macos_clang_M2.sh + +# Procedure: +# Install gcc, bison, flex, libtool, autoconf, automake, +# libx11 and libx11-dev (headers), libXaw and libXaw-dev, libreadline and dev +# XCODE, commandline tools +# Declare 'compile_macos_clang_M2.sh' executable and start compiling with +# './compile_macoss_clang_M2.sh' or './compile_macoss_clang_M2.sh d' from the ngspice directory. +# Options: +# CIDER may be selected at will. +# OpenMP has been installed from https://mac.r-project.org/openmp/ + +# ngspice as shared library: +# Replace --with-x by --with-ngshared in line ../configure ... . +# Add (optionally) --enable-relpath to avoid absolute paths when searching for code models. +# It might be necessary to uncomment and run ./autogen.sh . + +SECONDS=0 + +if test "$1" = "d"; then + if [ ! -d "debug" ]; then + mkdir debug + if [ $? -ne 0 ]; then echo "mkdir debug failed"; exit 1 ; fi + fi +else + if [ ! -d "release" ]; then + mkdir release + if [ $? -ne 0 ]; then echo "mkdir release failed"; exit 1 ; fi + fi +fi + +# If compiling sources from git, you may need to uncomment the following two lines: +./autogen.sh +if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi + +echo +if test "$1" = "d"; then + cd debug + if [ $? -ne 0 ]; then echo "cd debug failed"; exit 1 ; fi + echo "configuring for 64 bit debug" + echo +# Builtin readline is not compatible (Big Sur), readline via Homebrew required (in /opt/homebrew/opt) +# Standard clang does not support OpenMP, uses https://mac.r-project.org/openmp/ + + ../configure --with-x --enable-cider --with-readline=/opt/homebrew/opt/readline --enable-debug CFLAGS="-m64 -O0 -g -Wall -I/opt/X11/include/freetype2 -I/opt/homebrew/opt/readline/include" LDFLAGS="-m64 -g -L/opt/homebrew/opt/readline/lib -L/opt/X11/lib -L/usr/local/lib -lomp" +else + cd release + if [ $? -ne 0 ]; then echo "cd release failed"; exit 1 ; fi + echo "configuring for 64 bit release" + echo + ../configure --with-x --enable-cider --with-readline=/opt/homebrew/opt/readline CFLAGS="-m64 -O2 -I/opt/X11/include/freetype2 -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/ncurses/include" LDFLAGS="-m64 -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/ncurses/lib -L/opt/X11/lib -L/usr/local/lib -lomp" +fi +if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi + +echo +# make clean is required for properly making the code models +echo "cleaning (see make_clean.log)" +make clean 2>&1 -j8 | tee make_clean.log +exitcode=${PIPESTATUS[0]} +if [ $exitcode -ne 0 ]; then echo "make clean failed"; exit 1 ; fi +echo "compiling (see make.log)" +make 2>&1 -j8 | tee make.log +exitcode=${PIPESTATUS[0]} +if [ $exitcode -ne 0 ]; then echo "make failed"; exit 1 ; fi +# Install to /usr/local +echo "installing (see make_install.log)" +make install 2>&1 | tee make_install.log +exitcode=${PIPESTATUS[0]} +if [ $exitcode -ne 0 ]; then echo "make install failed"; exit 1 ; fi + +ELAPSED="Elapsed compile time: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec" +echo +echo $ELAPSED +echo "success" +exit 0 diff --git a/compile_macos_clang_M2_shared.sh b/compile_macos_clang_M2_shared.sh new file mode 100644 index 000000000..3ba0e1ef9 --- /dev/null +++ b/compile_macos_clang_M2_shared.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# ngspice build script for macOS, release or debug version, 64 bit +# compile_macos_clang_M2.sh +# tested with Mac mini, Apple M2 + +# Procedure: +# Install gcc, bison, flex, libtool, autoconf, automake, +# libx11 and libx11-dev (headers), libXaw and libXaw-dev, libreadline and dev +# XCODE, commandline tools +# Declare 'compile_macos_clang_M2.sh' executable and start compiling with +# './compile_macoss_clang_M2.sh' or './compile_macoss_clang_M2.sh d' from the ngspice directory. +# Options: +# CIDER may be selected at will. +# OpenMP has been installed from https://mac.r-project.org/openmp/ + +# ngspice as shared library: +# Replace --with-x by --with-ngshared in line ../configure ... . +# Add (optionally) --enable-relpath to avoid absolute paths when searching for code models. +# It might be necessary to uncomment and run ./autogen.sh . + +SECONDS=0 + +if test "$1" = "d"; then + if [ ! -d "debug" ]; then + mkdir debug + if [ $? -ne 0 ]; then echo "mkdir debug failed"; exit 1 ; fi + fi +else + if [ ! -d "release" ]; then + mkdir release + if [ $? -ne 0 ]; then echo "mkdir release failed"; exit 1 ; fi + fi +fi + +# If compiling sources from git, you may need to uncomment the following two lines: +./autogen.sh +if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi + +echo +if test "$1" = "d"; then + cd debug + if [ $? -ne 0 ]; then echo "cd debug failed"; exit 1 ; fi + echo "configuring for 64 bit debug" + echo + + ../configure --with-ngshared --enable-cider --with-readline=/opt/homebrew/opt/readline --enable-debug CFLAGS="-m64 -O0 -g -Wall -I/opt/X11/include/freetype2 -I/opt/homebrew/opt/readline/include" LDFLAGS="-m64 -g -L/opt/homebrew/opt/readline/lib -L/opt/X11/lib -L/usr/local/lib -lomp" +else + cd release + if [ $? -ne 0 ]; then echo "cd release failed"; exit 1 ; fi + echo "configuring for 64 bit release" + echo + ../configure --with-ngshared --enable-cider --with-readline=/opt/homebrew/opt/readline CFLAGS="-m64 -O2 -I/opt/X11/include/freetype2 -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/ncurses/include" LDFLAGS="-m64 -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/ncurses/lib -L/opt/X11/lib -L/usr/local/lib -lomp" +fi +if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi + +echo +# make clean is required for properly making the code models +echo "cleaning (see make_clean.log)" +make clean 2>&1 -j8 | tee make_clean.log +exitcode=${PIPESTATUS[0]} +if [ $exitcode -ne 0 ]; then echo "make clean failed"; exit 1 ; fi +echo "compiling (see make.log)" +make 2>&1 -j8 | tee make.log +exitcode=${PIPESTATUS[0]} +if [ $exitcode -ne 0 ]; then echo "make failed"; exit 1 ; fi +# Install to /usr/local +echo "installing (see make_install.log)" +make install 2>&1 | tee make_install.log +exitcode=${PIPESTATUS[0]} +if [ $exitcode -ne 0 ]; then echo "make install failed"; exit 1 ; fi + +ELAPSED="Elapsed compile time: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec" +echo +echo $ELAPSED +echo "success" +exit 0 diff --git a/compile_macos_gcc.sh b/compile_macos_gcc.sh index fa5393ae9..6bd1c0113 100755 --- a/compile_macos_gcc.sh +++ b/compile_macos_gcc.sh @@ -1,14 +1,16 @@ #!/bin/bash # ngspice build script for macOS, release or debug version, 64 bit # compile_macos.sh +# tested with macOS BigSur 11.7.9, MacBook Air i5 # Procedure: # Install gcc, bison, flex, libtool, autoconf, automake, # libx11 and libx11-dev (headers), libXaw and libXaw-dev, libreadline and dev -# Declare 'compile_linux.sh' executable and start compiling with +# XCODE and commandline tools +# Declare 'compile_macos_gcc.sh' executable and start compiling with # './compile_macos.sh' or './compile_macos.sh d' from the ngspice directory. # Options: -# CIDER, XSPICE, and OpenMP may be selected at will. +# KLU, OSDI, XSPICE, and OpenMP may be deselected at will. # --disable-debug will give O2 optimization (versus O0 for debug) and removes all debugging info. # ngspice as shared library: diff --git a/compile_macos_shared.sh b/compile_macos_shared.sh index 35673abf7..9cd8664a0 100755 --- a/compile_macos_shared.sh +++ b/compile_macos_shared.sh @@ -1,21 +1,15 @@ #!/bin/bash # ngspice build script for MINGW in MSYS2, release or debug version, 64 bit # compile_min_shared.sh +# tested with macOS BigSur 11.7.9, MacBook Air i5 #Procedure: -# Install MSYS2, plus gcc 64 bit, bison, flex, autoconf, automake, libtool -# See https://github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2 # start compiling with -# './compile_min_shared.sh' for release or './compile_min_shared.sh d' +# './compile_macos_shared.sh' for release or './compile_macos_shared.sh d' # for debug version of shared ngspice # Options: -# --adms and --enable-adms will install extra HICUM, EKV and MEXTRAM models via the -# adms interface. -# Please see http://ngspice.sourceforge.net/admshowto.html for more info on adms. -# CIDER, XSPICE, and OpenMP may be selected at will. -# --disable-debug will give O2 optimization (versus O0 for debug) and removes all debugging info. -# To obtain a 32 bit executable, replace -m64 by -m32 ./configure lines. +# KLU, OSDI, XSPICE, and OpenMP may be deselected at will. # Add (optionally) --enable-relpath to avoid absolute paths when searching for code models. # It might be necessary to uncomment and run ./autogen.sh . @@ -38,28 +32,19 @@ fi ./autogen.sh if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi -# Alternatively, if compiling sources from git, and want to add adms created devices, -# you may need to uncomment the following two lines (and don't forget to add adms option -# to the ../configure statement): -#./autogen.sh --adms -#if [ $? -ne 0 ]; then echo "./autogen.sh failed"; exit 1 ; fi - echo if test "$1" = "d"; then cd debug-sh if [ $? -ne 0 ]; then echo "cd debug-sh failed"; exit 1 ; fi echo "configuring for 64 bit debug" echo -# You may add --enable-adms to the following command for adding adms generated devices - ../configure --with-ngshared --enable-xspice --enable-cider --enable-openmp CFLAGS="-O0" LDFLAGS=" -lomp" + ../configure --with-ngshared --enable-cider CFLAGS="-O0" LDFLAGS=" -lomp" else cd release-sh if [ $? -ne 0 ]; then echo "cd release-sh failed"; exit 1 ; fi echo "configuring for 64 bit release" echo -# You may add --enable-adms to the following command for adding adms generated devices -# ../configure --with-ngshared --enable-xspice --enable-cider --enable-openmp --disable-debug CFLAGS="-O2" LDFLAGS="-lomp" - ../configure --with-ngshared --enable-xspice --enable-cider --disable-debug --enable-openmp CC="gcc-11" CXX="g++-11" CFLAGS="-m64 -O2 -I/usr/local/include" LDFLAGS="-m64 -L/usr/local/lib" + ../configure --with-ngshared --enable-cider CC="gcc-11" CXX="g++-11" CFLAGS="-m64 -O2 -I/usr/local/include" LDFLAGS="-m64 -L/usr/local/lib" fi if [ $? -ne 0 ]; then echo "../configure failed"; exit 1 ; fi