<commit_before>##############################################################################
# GNU Makefile for the primesieve console application (read INSTALL)
#              and the primesieve C++ library         (read doc/LIBPRIMESIEVE)
#
# Author:          <NAME>
# Contact:         <EMAIL>
# Created:         10 July 2010
# Last modified:   16 September 2013
#
# Project home:    http://primesieve.googlecode.com
##############################################################################

TARGET   := primesieve
CXX      := c++
CXXFLAGS := -Wall -O2
BINDIR   := bin
EXDIR    := examples
INCDIR   := include
LIBDIR   := lib
OBJDIR   := obj
FPICDIR  := obj/fpic
SOEDIR   := src/soe

SOE_OBJECTS:= \
  $(OBJDIR)/EratBig.o \
  $(OBJDIR)/EratMedium.o \
  $(OBJDIR)/EratSmall.o \
  $(OBJDIR)/ParallelPrimeSieve.o \
  $(OBJDIR)/popcount.o \
  $(OBJDIR)/PreSieve.o \
  $(OBJDIR)/PrimeFinder.o \
  $(OBJDIR)/PrimeGenerator.o \
  $(OBJDIR)/PrimeSieve-nthPrime.o \
  $(OBJDIR)/PrimeSieve.o \
  $(OBJDIR)/SieveOfEratosthenes.o \
  $(OBJDIR)/WheelFactorization.o

SOE_HEADERS := \
  $(SOEDIR)/bits.h \
  $(SOEDIR)/config.h \
  $(SOEDIR)/littleendian_cast.h \
  $(SOEDIR)/EratBig.h \
  $(SOEDIR)/EratMedium.h \
  $(SOEDIR)/EratSmall.h \
  $(SOEDIR)/imath.h \
  $(SOEDIR)/ParallelPrimeSieve.h \
  $(SOEDIR)/ParallelPrimeSieve-lock.h \
  $(SOEDIR)/PreSieve.h \
  $(SOEDIR)/PrimeFinder.h \
  $(SOEDIR)/PrimeGenerator.h \
  $(SOEDIR)/PrimeSieve.h \
  $(SOEDIR)/primesieve_error.h \
  $(SOEDIR)/PrimeSieveCallback.h \
  $(SOEDIR)/PrimeSieve-lock.h \
  $(SOEDIR)/SieveOfEratosthenes.h \
  $(SOEDIR)/SieveOfEratosthenes-GENERATE.h \
  $(SOEDIR)/SieveOfEratosthenes-inline.h \
  $(SOEDIR)/stop_primesieve.h \
  $(SOEDIR)/toString.h \
  $(SOEDIR)/WheelFactorization.h

INC_HEADERS := \
  $(SOEDIR)/ParallelPrimeSieve.h \
  $(SOEDIR)/PrimeSieve.h \
  $(SOEDIR)/primesieve_error.h \
  $(SOEDIR)/PrimeSieveCallback.h \
  $(SOEDIR)/stop_primesieve.h

#-----------------------------------------------------------------------------
# Needed to suppress output while checking system features
#-----------------------------------------------------------------------------

NO_STDOUT := 1> /dev/null
NO_STDERR := 2> /dev/null
NO_OUTPUT := $(NO_STDOUT) $(NO_STDERR)

#-----------------------------------------------------------------------------
# Find the compiler's OpenMP flag
#-----------------------------------------------------------------------------

ifneq ($(OPENMP),no)
OPENMP_PROGRAM := '\#include <omp.h>\n int main() { return _OPENMP; }'

is-openmp = $(shell command -v $(CXX) $(NO_OUTPUT) && \
                    printf $(OPENMP_PROGRAM) | \
                    $(CXX) $(CXXFLAGS) $1 -xc++ -c -o /dev/null - $(NO_STDERR) && \
                    echo successfully compiled!)

ifeq ($(call is-openmp,),)
  ifneq ($(call is-openmp,-openmp),)
    CXXFLAGS += -openmp
  else
    ifneq ($(call is-openmp,-fopenmp),)
      CXXFLAGS += -fopenmp
    endif
  endif
endif
endif

#-----------------------------------------------------------------------------
# Add the CPU's L1 data cache size (in kilobytes) to CXXFLAGS
#-----------------------------------------------------------------------------

L1_DCACHE_BYTES := $(shell getconf LEVEL1_DCACHE_SIZE $(NO_STDERR) || \
                           command -v sysctl $(NO_OUTPUT) && \
                           sysctl hw.l1dcachesize $(NO_STDERR) | \
                           sed -e 's/^.* //')

ifneq ($(shell expr $(L1_DCACHE_BYTES) '-' $(L1_DCACHE_BYTES) '+' 1 $(NO_OUTPUT) && \
               echo is a number),)
  L1_DCACHE_SIZE := $(shell expr $(L1_DCACHE_BYTES) '/' 1024)
  ifeq ($(shell expr $(L1_DCACHE_SIZE) '>=' 8    $(NO_OUTPUT) && \
                expr $(L1_DCACHE_SIZE) '<=' 2048 $(NO_OUTPUT) && \
                echo valid),)
    L1_DCACHE_SIZE :=
  endif
endif

ifneq ($(L1_DCACHE_SIZE),)
  override CXXFLAGS += -DL1_DCACHE_SIZE=$(L1_DCACHE_SIZE)
endif

#-----------------------------------------------------------------------------
# Default installation path
#-----------------------------------------------------------------------------

PREFIX := /usr

ifneq ($(shell uname | grep -i linux),)
  PREFIX := /usr/local
endif
ifneq ($(shell uname | grep -i mingw),)
  PREFIX := /mingw
endif

#-----------------------------------------------------------------------------
# make        -> libprimesieve.a
# make shared -> libprimesieve.(so|dylib)
#-----------------------------------------------------------------------------

ifeq ($(SHARED),)
  STATIC := yes
endif

ifneq ($(shell uname | grep -i darwin),)
  SOFLAG := -dynamiclib
  SHARED_LIBRARY := lib$(TARGET).dylib
else
  SOFLAG := -shared
  SHARED_LIBRARY := lib$(TARGET).so
  ifeq ($(shell uname | egrep -i 'mingw|cygwin'),)
    FPIC := -fPIC
  endif
endif

#-----------------------------------------------------------------------------
# Top level targets
#-----------------------------------------------------------------------------

.PHONY: default all lib

default: bin static

all: bin static shared

lib: $(if $(STATIC),static,) $(if $(SHARED),shared,)

#-----------------------------------------------------------------------------
# Create and clean output directories
#-----------------------------------------------------------------------------

.PHONY: make_dir clean

make_dir:
	@mkdir -p $(BINDIR) $(LIBDIR) $(OBJDIR) $(FPICDIR)
	@mkdir -p  $(INCDIR)/$(TARGET)/soe

clean:
	rm -rf $(BINDIR) $(LIBDIR) $(OBJDIR) $(INCDIR)

#-----------------------------------------------------------------------------
# Compilation rules
#-----------------------------------------------------------------------------

$(OBJDIR)/%.o: $(SOEDIR)/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(FPICDIR)/%.o: $(SOEDIR)/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) $(FPIC) -c $< -o $@

$(OBJDIR)/%.o: src/apps/console/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(OBJDIR)/%.o: src/test/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(BINDIR)/%: $(EXDIR)/%.cpp<commit_msg>Removed legacy code<commit_after>##############################################################################
# GNU Makefile for the primesieve console application (read INSTALL)
#              and the primesieve C++ library         (read doc/LIBPRIMESIEVE)
#
# Author:          <NAME>
# Contact:         <EMAIL>
# Created:         10 July 2010
# Last modified:   17 September 2013
#
# Project home:    http://primesieve.googlecode.com
##############################################################################

TARGET   := primesieve
CXX      := c++
CXXFLAGS := -Wall -O2
BINDIR   := bin
EXDIR    := examples
INCDIR   := include
LIBDIR   := lib
OBJDIR   := obj
FPICDIR  := obj/fpic
SOEDIR   := src/soe

SOE_OBJECTS:= \
  $(OBJDIR)/EratBig.o \
  $(OBJDIR)/EratMedium.o \
  $(OBJDIR)/EratSmall.o \
  $(OBJDIR)/ParallelPrimeSieve.o \
  $(OBJDIR)/popcount.o \
  $(OBJDIR)/PreSieve.o \
  $(OBJDIR)/PrimeFinder.o \
  $(OBJDIR)/PrimeGenerator.o \
  $(OBJDIR)/PrimeSieve-nthPrime.o \
  $(OBJDIR)/PrimeSieve.o \
  $(OBJDIR)/SieveOfEratosthenes.o \
  $(OBJDIR)/WheelFactorization.o

SOE_HEADERS := \
  $(SOEDIR)/bits.h \
  $(SOEDIR)/config.h \
  $(SOEDIR)/littleendian_cast.h \
  $(SOEDIR)/EratBig.h \
  $(SOEDIR)/EratMedium.h \
  $(SOEDIR)/EratSmall.h \
  $(SOEDIR)/imath.h \
  $(SOEDIR)/ParallelPrimeSieve.h \
  $(SOEDIR)/ParallelPrimeSieve-lock.h \
  $(SOEDIR)/PreSieve.h \
  $(SOEDIR)/PrimeFinder.h \
  $(SOEDIR)/PrimeGenerator.h \
  $(SOEDIR)/PrimeSieve.h \
  $(SOEDIR)/primesieve_error.h \
  $(SOEDIR)/PrimeSieveCallback.h \
  $(SOEDIR)/PrimeSieve-lock.h \
  $(SOEDIR)/SieveOfEratosthenes.h \
  $(SOEDIR)/SieveOfEratosthenes-GENERATE.h \
  $(SOEDIR)/SieveOfEratosthenes-inline.h \
  $(SOEDIR)/stop_primesieve.h \
  $(SOEDIR)/toString.h \
  $(SOEDIR)/WheelFactorization.h

INC_HEADERS := \
  $(SOEDIR)/ParallelPrimeSieve.h \
  $(SOEDIR)/PrimeSieve.h \
  $(SOEDIR)/primesieve_error.h \
  $(SOEDIR)/PrimeSieveCallback.h \
  $(SOEDIR)/stop_primesieve.h

#-----------------------------------------------------------------------------
# Needed to suppress output while checking system features
#-----------------------------------------------------------------------------

NO_STDOUT := 1> /dev/null
NO_STDERR := 2> /dev/null
NO_OUTPUT := $(NO_STDOUT) $(NO_STDERR)

#-----------------------------------------------------------------------------
# Find the compiler's OpenMP flag
#-----------------------------------------------------------------------------

ifneq ($(OPENMP),no)
OPENMP_PROGRAM := '\#include <omp.h>\n int main() { return _OPENMP; }'

is-openmp = $(shell command -v $(CXX) $(NO_OUTPUT) && \
                    printf $(OPENMP_PROGRAM) | \
                    $(CXX) $(CXXFLAGS) $1 -xc++ -c -o /dev/null - $(NO_STDERR) && \
                    echo successfully compiled!)

ifeq ($(call is-openmp,),)
  ifneq ($(call is-openmp,-openmp),)
    CXXFLAGS += -openmp
  else
    ifneq ($(call is-openmp,-fopenmp),)
      CXXFLAGS += -fopenmp
    endif
  endif
endif
endif

#-----------------------------------------------------------------------------
# Add the CPU's L1 data cache size (in kilobytes) to CXXFLAGS
#-----------------------------------------------------------------------------

L1_DCACHE_BYTES := $(shell getconf LEVEL1_DCACHE_SIZE $(NO_STDERR) || \
                           command -v sysctl $(NO_OUTPUT) && \
                           sysctl hw.l1dcachesize $(NO_STDERR) | \
                           sed -e 's/^.* //')

ifneq ($(shell expr $(L1_DCACHE_BYTES) '-' $(L1_DCACHE_BYTES) '+' 1 $(NO_OUTPUT) && \
               echo is a number),)
  L1_DCACHE_SIZE := $(shell expr $(L1_DCACHE_BYTES) '/' 1024)
  ifeq ($(shell expr $(L1_DCACHE_SIZE) '>=' 8    $(NO_OUTPUT) && \
                expr $(L1_DCACHE_SIZE) '<=' 2048 $(NO_OUTPUT) && \
                echo valid),)
    L1_DCACHE_SIZE :=
  endif
endif

ifneq ($(L1_DCACHE_SIZE),)
  override CXXFLAGS += -DL1_DCACHE_SIZE=$(L1_DCACHE_SIZE)
endif

#-----------------------------------------------------------------------------
# Default installation path
#-----------------------------------------------------------------------------

PREFIX := /usr

ifneq ($(shell uname | grep -i linux),)
  PREFIX := /usr/local
endif
ifneq ($(shell uname | grep -i mingw),)
  PREFIX := /mingw
endif

#-----------------------------------------------------------------------------
# libprimesieve flags
#-----------------------------------------------------------------------------

ifneq ($(shell uname | grep -i darwin),)
  SOFLAG := -dynamiclib
  SHARED_LIBRARY := lib$(TARGET).dylib
else
  SOFLAG := -shared
  SHARED_LIBRARY := lib$(TARGET).so
  ifeq ($(shell uname | egrep -i 'mingw|cygwin'),)
    FPIC := -fPIC
  endif
endif

#-----------------------------------------------------------------------------
# Top level targets
#-----------------------------------------------------------------------------

.PHONY: default all lib

default: bin lib

all: bin static shared

lib: static

#-----------------------------------------------------------------------------
# Create and clean output directories
#-----------------------------------------------------------------------------

.PHONY: make_dir clean

make_dir:
	@mkdir -p $(BINDIR) $(LIBDIR) $(OBJDIR) $(FPICDIR)
	@mkdir -p  $(INCDIR)/$(TARGET)/soe

clean:
	rm -rf $(BINDIR) $(LIBDIR) $(OBJDIR) $(INCDIR)

#-----------------------------------------------------------------------------
# Compilation rules
#-----------------------------------------------------------------------------

$(OBJDIR)/%.o: $(SOEDIR)/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(FPICDIR)/%.o: $(SOEDIR)/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) $(FPIC) -c $< -o $@

$(OBJDIR)/%.o: src/apps/console/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(OBJDIR)/%.o: src/test/%.cpp $(SOE_HEADERS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(BINDIR)/%: $(EXDIR)/%.cpp
{'fraction_non_alphanumeric': 0.37097589752233273, 'fraction_numerical': 0.006741951795044665, 'mean_word_length': 1.470233139050791, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1927518', 'n_tokens_mistral': 3921, 'n_tokens_neox': 3685, 'n_words': 714}