diff --git a/.gitignore b/.gitignore index 35271b5..03fd5fb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ lib/ build tags +.*.sw* +*~ + diff --git a/build.sh b/build.sh index d66ca4b..0d5eec0 100755 --- a/build.sh +++ b/build.sh @@ -1,15 +1,39 @@ -#!/bin/bash +#!/usr/bin/env bash # A simple bash script to suit my needs for faster testing. # This script was not made to be "optimized" but just to # "do the job" as fast as possible. # # Feel free to improve it(as in add features/optimize etc.). +# +# NetBSD has only csh, sh (kinda ksh clone) and ksh out of the box +## Get Operating System +OPSYS=$(uname -s) +ARCH=$(uname -p) # Figure out cores -CORES=`grep processor /proc/cpuinfo | wc -l` +case $OPSYS in + Linux) + CORES=`grep processor /proc/cpuinfo | wc -l` + ;; + FreeBSD) + # TODO Check if all *BSD could fit here + CORES=$(/sbin/sysctl hw.ncpu | cut -d ' ' -f 2) + ;; + *BSD) + # TODO Check if all *BSD could fit here + CORES=$(/sbin/sysctl hw.ncpu | cut -d ' ' -f 3) + ;; + Darwin) + # TODO + ;; + *) + # TODO + ;; +esac # Process to be passed to $MAKE MAKEOPT=$(($CORES + 1)) +echo -e "Building on $OPSYS $ARCH CPUs: $CORES with make -j$MAKEOPT\n" # arguments to pass to $TARGET (see below) generated ARGS=1337 # The target to build after building the library. @@ -116,10 +140,10 @@ ARGS="$ARGS $*" if [ "$force_select" = "yes" ]; then add_opts -DSOCKET_INTERFACE=Select else - PLATFORM=`uname -s` - case "$PLATFORM" in + OPSYS=`uname -s` + case "$OPSYS" in linux* | Linux*) add_opts -DSOCKET_INTERFACE=Epoll ;; - Darwin*) add_opts -DSOCKET_INTERFACE=KQueue ;; # unimplemented ;( + Darwin* | *BSD) add_opts -DSOCKET_INTERFACE=KQueue ;; # unimplemented ;( *) ;; esac fi @@ -150,7 +174,7 @@ cd build add_opts -DCMAKE_BUILD_TYPE="$build_type" echo Generating Makefile with $buildopt -cmake .. $buildopt || exit +cmake $buildopt .. || exit [[ "$clean_before_build" = "yes" ]] && $MAKE clean diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f200f2..90c3a69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,7 +57,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() # gcc compile flags -set(WARNS_FLAGS "-Wall -Wno-unused-result -Wno-sign-compare ") +set(WARNS_FLAGS "-Wall -Wno-sign-compare ") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -pipe -include ${csnippets_PRE_INCLUDE}") set(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -ggdb") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O1 -g3 -ggdb -fno-omit-frame-pointer")