Skip to content

Commit

Permalink
remove CXX
Browse files Browse the repository at this point in the history
  • Loading branch information
junjiemars committed Nov 15, 2024
1 parent c754ec2 commit 350e218
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 101 deletions.
14 changes: 5 additions & 9 deletions auto/cc/clang
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
# author: Junjie Mars
#------------------------------------------------

nm_clang_ver=`$CC -v 2>&1 | grep '\(clang\|LLVM\) version' 2>&1 \
| sed -e 's/^.* version \(.*\)/\1/'`
nm_clang_ver=$($CC -v 2>&1 | grep '\(clang\|LLVM\) version' 2>&1 \
| sed -e 's/^.* version \(.*\)/\1/')

echo " + clang version: $nm_clang_ver"
printf " + clang version: $nm_clang_ver\n"

NM_COMPILER="clang $nm_clang_ver"
have=NM_COMPILER value="\"$NM_COMPILER\"" . ${NORE_ROOT}/auto/define

. ${NORE_ROOT}/auto/cc/version
CC_VER=`version_n $(echo $nm_clang_ver | cut -d' ' -f1)`
CC_VER=$(version_n $(printf $nm_clang_ver | cut -d' ' -f1))
have=CLANG value=$CC_VER . ${NORE_ROOT}/auto/define


Expand Down Expand Up @@ -78,11 +78,7 @@ esac
case "$NM_STD" in
NO) nm_std_opt="" ;;
YES)
if [ "$CXX" = "$CC" ]; then
nm_std_opt=""
else
nm_std_opt="-std=c11"
fi
nm_std_opt="-std=c11"
;;
*) nm_std_opt="${NM_STD}" ;;
esac
Expand Down
24 changes: 10 additions & 14 deletions auto/cc/conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,36 @@
# author: Junjie Mars
#------------------------------------------------

# c compiler
CC=${CC:-cc}
CXX=
# extra flags to c compiler
CFLAGS=${CFLAGS}

# predefined to c compiler
ASM="\$(CC)"
LINK="\$(CC)"
ASM="\${ASM}"
LINK="\${LINK}"

# c preprocessor
CPP=${CPP}
# extra flags to c preprocessor
CPPFLAGS=${CPPFLAGS}

# assembler
AS=${AS}
AS=${AS:-as}
# extra flags to assembler
ASFLAGS=${ASFLAGS}

# archiver
AR=${AR}
AR=${AR:-ar}
# extra flags to archiver
ARFLAGS=${ARFLAGS}

# extra flags to c compiler
CFLAGS=${CFLAGS}
# extra flags to c++ compiler
CXXFLAGS=

INC=${INC}

# linker
LD=${LD:-$CC}

# extra flags to compiler for linker
# such as -L
LDFLAGS=${LDFLAGS}
Expand Down Expand Up @@ -166,11 +167,6 @@ if [ -n "$nm_utf_opt" ]; then
CPPFLAGS=${CPPFLAGS:+$CPPFLAGS }${nm_utf_opt}
fi

# cxx flags
if [ "$CXX" = "$CC" ]; then
CXXFLAGS=$CFLAGS
fi

# inc option
INC="${nm_inc_opt}${NM_OUT} ${nm_inc_opt}${NM_OUT}/inc${INC:+ $INC}"

Expand Down
14 changes: 5 additions & 9 deletions auto/cc/gcc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
# author: Junjie Mars
#------------------------------------------------

nm_gcc_ver=`$CC -v 2>&1 | grep 'gcc version' 2>&1 \
| sed -e 's/^.* version \(.*\)/\1/'`
nm_gcc_ver=$($CC -v 2>&1 | grep 'gcc version' 2>&1 \
| sed -e 's/^.* version \(.*\)/\1/')

echo " + gcc version: $nm_gcc_ver"
printf " + gcc version: $nm_gcc_ver\n"

NM_COMPILER="gcc $nm_gcc_ver"
have=NM_COMPILER value="\"$NM_COMPILER\"" . ${NORE_ROOT}/auto/define

. ${NORE_ROOT}/auto/cc/version
CC_VER=`version_n $(echo $nm_gcc_ver | cut -d' ' -f1)`
CC_VER=$(version_n $(printf $nm_gcc_ver | cut -d' ' -f1))
have=GCC value=$CC_VER . ${NORE_ROOT}/auto/define


Expand Down Expand Up @@ -78,11 +78,7 @@ esac
case "$NM_STD" in
NO) nm_std_opt="" ;;
YES)
if [ "$CXX" = "$CC" ]; then
nm_std_opt=""
else
nm_std_opt="-std=c11"
fi
nm_std_opt="-std=c11"
;;
*) nm_std_opt="${NM_STD}" ;;
esac
Expand Down
11 changes: 4 additions & 7 deletions auto/cc/msvc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
# author: Junjie Mars
#------------------------------------------------

nm_msvc_ver=`$CC 2>&1 | grep 'Compiler Version' 2>&1 \
| sed -e 's/^.* Version \(.*\)/\1/'`
nm_msvc_ver=$($CC 2>&1 | grep 'Compiler Version' 2>&1 \
| sed -e 's/^.* Version \(.*\)/\1/')

echo " + msvc version: $nm_msvc_ver"
printf " + msvc version: $nm_msvc_ver\n"

NM_COMPILER="msvc $nm_msvc_ver"
have=NM_COMPILER value="\"$NM_COMPILER\"" . ${NORE_ROOT}/auto/define

. ${NORE_ROOT}/auto/cc/version
CC_VER=`version_n $(echo $nm_msvc_ver | cut -d' ' -f1)`
CC_VER=$(version_n $(printf $nm_msvc_ver | cut -d' ' -f1))
have=MSVC value=$CC_VER . ${NORE_ROOT}/auto/define


Expand Down Expand Up @@ -74,9 +74,6 @@ esac
case "$NM_VERBOSE" in
NO)
CC="${CC:+$CC }-nologo"
if [ "$CXX" = "$CC" ]; then
CXX="${CXX:+$CXX }-nologo"
fi
AR="${AR:+$AR }-nologo"
AS="${AS:+$AS }-nologo"
;;
Expand Down
35 changes: 8 additions & 27 deletions auto/cc/name
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,18 @@ else
printf "${nm_found}\n"
fi

CC_NAME=$(basename $CC)
if $($CC -v 2>&1 | grep -q 'gcc version'); then
printf " + using GNU ${CC_NAME} compiler\n"

nm_feature="C++ compiler"
nm_feature_name="CXX"
nm_feature_run=dumb
nm_feature_h="#include <iostream>"
nm_feature_flags=
nm_feature_value=
nm_feature_test="std::cout << \"$CC\n\";"
. ${NORE_ROOT}/auto/feature

cc_or_cxx="C"
if [ ".yes" = ".$nm_found" ]; then
CXX=$nm_feature_value
cc_or_cxx="C/C++"
fi


if $($CC -v 2>&1 | grep 'gcc version' >/dev/null 2>&1); then
CC_NAME=gcc
printf " + using GNU ${cc_or_cxx} compiler\n"

elif $($CC -v 2>&1 | grep '\(clang\|LLVM\) version' >/dev/null 2>&1); then
CC_NAME=clang
printf " + using Clang ${cc_or_cxx} compiler\n"
elif $($CC -v 2>&1 | grep -q '\(clang\|LLVM\) version'); then
printf " + using ${CC_NAME} compiler\n"

elif $($CC 2>&1 | grep 'Microsoft .* C\/C++' >/dev/null 2>&1); then
CC_NAME=msvc
printf " + using Microsoft ${cc_or_cxx} compiler\n"
elif $($CC 2>&1 | grep -q 'Microsoft .* C\/C++'); then
printf " + using Microsoft ${CC_NAME} compiler\n"

else
CC_NAME=unknown
printf " + using ${CC_NAME} compiler\n"
fi

# eof
7 changes: 2 additions & 5 deletions auto/feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ fi


autotest_c="$NM_AUTOTEST.c"
if [ "$CXX" = "$CC" ]; then
autotest_c="$NM_AUTOTEST.cc"
fi

cat << END > $autotest_c
$nm_feature_h
int main(void)
int main (void)
{
$nm_feature_test
$nm_feature_test
}
END
Expand Down
34 changes: 4 additions & 30 deletions auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ cat << END > $NM_MAKEFILE
#
CC = $CC
`
if [ ".$CXX" = ".$CC" ]; then
echo "CXX = \$CXX"
fi
`
CPP = $CPP
AS = $AS
Expand All @@ -54,11 +49,6 @@ LFLAGS = $LFLAGS
YFLAGS = $YFLAGS
CFLAGS = $CFLAGS
`
if [ ".$CXX" = ".$CC" ]; then
echo "CXXFLAGS = \$CFLAGS"
fi
`
INC = $INC
Expand Down Expand Up @@ -256,11 +246,7 @@ END
fi
fi # end of [ ! -d $nm_stick_src ]

if [ "$CXX" != "$CC" ]; then
nm_stick_norm_c="${nm_stick_norm}.c"
else
nm_stick_norm_c="${nm_stick_norm}.cc"
fi
nm_stick_norm_c="${nm_stick_norm}.c"

if [ YES = $NM_NEW -a ! -f "$nm_stick_norm_c" ]; then
printf " + generating `echo_pretty_path $nm_stick_src/$nm_stick_norm_c` file ... "
Expand All @@ -272,24 +258,12 @@ END
*/
#include <nore.h>
`
if [ "$CXX" != "$CC" ]; then
echo "#include <stdio.h>"
else
echo "#include <iostream>"
fi
`
#include <stdio.h>
int
main(void)
main (void)
{
`
if [ "$CXX" != "$CC" ]; then
echo " printf(\\"Hello, Nore!\\\\\n\\");"
else
echo " std::cout << \\"Hello, Nore!\\" << std::endl;"
fi
`
printf ("Hello, Nore!\\n");
return 0;
}
END
Expand Down
1 change: 1 addition & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ unset -f command 2>/dev/null
# check commands
set -e
awk=$(command -v awk)
basename=$(command -v basename)
chmod=$(command -v chmod)
curl=$(command -v curl)
cut=$(command -v cut)
Expand Down

0 comments on commit 350e218

Please sign in to comment.