From 713dd76139b38d5998b7d3dbf1bdc7fb7219a4c6 Mon Sep 17 00:00:00 2001 From: w12 Date: Sun, 5 Jan 2025 11:04:16 +0100 Subject: [PATCH] =?UTF-8?q?miner=20=C3=BCberarbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile.am | 29 ++++--- build.sh | 4 + build_nolambocoin_miner.sh | 150 +++++++++++++++++++++++++++++++++++++ compat/jansson/Makefile.am | 31 ++++---- configure.ac | 86 +++++++++++---------- 5 files changed, 225 insertions(+), 75 deletions(-) create mode 100644 build_nolambocoin_miner.sh diff --git a/Makefile.am b/Makefile.am index a08c429..3536208 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,6 @@ AUTOMAKE_OPTIONS = subdir-objects +# Bedingte Optionen für Jansson if WANT_JANSSON JANSSON_INCLUDES = @JANSSON_CFLAGS@ else @@ -15,22 +16,18 @@ bin_PROGRAMS = nolambocoin-miner dist_man_MANS = nolambocoin-miner.1 nolambocoin-miner_SOURCES = \ - elist.h miner.h compat.h \ - cpu-miner.c util.c \ - sha2.c \ + cpu-miner.c util.c sha2.c \ yespower-1.0.1/sha256.c yespower-1.0.1/yespower-opt.c \ - YespowerSugar.c \ - YespowerIso.c \ - YespowerNull.c \ - YespowerUrx.c \ - YespowerLitb.c \ - YespowerIots.c \ - YespowerItc.c \ - YespowerYtn.c \ - yespower-1.0.1-power2b/sha256-p2b.c yespower-1.0.1-power2b/yespower-opt-p2b.c yespower-1.0.1-power2b/blake2b.c \ - YespowerMbc.c \ - YespowerARM.c \ - version.h + YespowerSugar.c YespowerIso.c YespowerNull.c \ + YespowerUrx.c YespowerLitb.c YespowerIots.c \ + YespowerItc.c YespowerYtn.c \ + yespower-1.0.1-power2b/sha256-p2b.c yespower-1.0.1-power2b/yespower-opt-p2b.c \ + yespower-1.0.1-power2b/blake2b.c YespowerMbc.c \ + YespowerARM.c version.h + +# Entferne Header-Dateien aus SOURCES und definiere sie separat +include_HEADERS = \ + elist.h miner.h compat.h AM_CPPFLAGS = $(JANSSON_INCLUDES) -I$(top_srcdir)/compat/jansson @PTHREAD_CFLAGS@ @@ -60,4 +57,4 @@ nolambocoin-miner_LDADD = @CURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@ if TARGET_WINDOWS nolambocoin-miner_LDADD += @WS2_LIBS@ -endif \ No newline at end of file +endif diff --git a/build.sh b/build.sh index 80b4559..96b50d1 100644 --- a/build.sh +++ b/build.sh @@ -2,6 +2,10 @@ make distclean || echo clean rm -f config.status +sudo chmod +x autogen.sh +cd share +sudo chmod +x genbuild.sh +cd .. # BUILD ./autogen.sh ./configure CFLAGS="-Wall -O2 -fomit-frame-pointer" diff --git a/build_nolambocoin_miner.sh b/build_nolambocoin_miner.sh new file mode 100644 index 0000000..454c720 --- /dev/null +++ b/build_nolambocoin_miner.sh @@ -0,0 +1,150 @@ +#!/bin/bash + +# build.sh - Ein Skript zur Automatisierung des Build- und Installationsprozesses für Nolambocoin Miner + +# Funktionen zur Anzeige von Nachrichten +function echo_info { + echo -e "\e[34m[INFO]\e[0m $1" +} + +function echo_success { + echo -e "\e[32m[SUCCESS]\e[0m $1" +} + +function echo_error { + echo -e "\e[31m[ERROR]\e[0m $1" +} + +# Überprüfen der Abhängigkeiten +function check_dependencies { + echo_info "Überprüfe erforderliche Abhängigkeiten..." + + local dependencies=("autoconf" "automake" "libcurl4-openssl-dev" "libjansson-dev" "build-essential" "pkg-config") + + for dep in "${dependencies[@]}"; do + if ! dpkg -s "$dep" &> /dev/null; then + echo_error "Abhängigkeit fehlt: $dep" + echo_info "Bitte installieren Sie fehlende Abhängigkeiten mit folgendem Befehl:" + echo_info "sudo apt-get install ${dependencies[@]}" + exit 1 + fi + done + + echo_success "Alle erforderlichen Abhängigkeiten sind installiert." +} + +# Initialisieren der Autotools +function initialize_autotools { + echo_info "Initialisiere Autotools..." + + if ! autoreconf -i; then + echo_error "Fehler beim Ausführen von autoreconf." + exit 1 + fi + + echo_success "Autotools erfolgreich initialisiert." +} + +# Konfigurieren des Projekts +function configure_project { + echo_info "Konfiguriere das Projekt..." + + if ! ./configure; then + echo_error "Fehler beim Ausführen von ./configure." + exit 1 + fi + + echo_success "Projekt erfolgreich konfiguriert." +} + +# Kompilieren des Projekts +function compile_project { + echo_info "Kompiliere das Projekt..." + + if ! make -j$(nproc); then + echo_error "Fehler beim Ausführen von make." + exit 1 + fi + + echo_success "Projekt erfolgreich kompiliert." +} + +# Installieren des Projekts +function install_project { + echo_info "Installiere das Projekt..." + + if [ "$EUID" -ne 0 ]; then + echo_error "Installation erfordert Root-Rechte. Bitte führen Sie das Skript mit sudo aus." + exit 1 + fi + + if ! make install; then + echo_error "Fehler beim Ausführen von make install." + exit 1 + fi + + echo_success "Projekt erfolgreich installiert." +} + +# Bereinigung des Build-Verzeichnisses +function clean_project { + echo_info "Bereinige das Projekt..." + + if ! make clean; then + echo_error "Fehler beim Ausführen von make clean." + exit 1 + fi + + echo_success "Projekt erfolgreich bereinigt." +} + +# Anzeige der Nutzung des Skripts +function show_help { + echo "Usage: ./build.sh [options]" + echo "" + echo "Options:" + echo " --build Konfiguriert und kompiliert das Projekt." + echo " --install Installiert das Projekt nach dem Kompilieren." + echo " --clean Bereinigt die Build-Dateien." + echo " --help Zeigt diese Hilfe an." + echo "" + echo "Beispiele:" + echo " ./build.sh --build" + echo " sudo ./build.sh --install" + echo " ./build.sh --clean" + exit 0 +} + +# Hauptfunktion zur Verarbeitung der Skript-Argumente +function main { + if [ $# -eq 0 ]; then + show_help + fi + + for arg in "$@"; do + case $arg in + --build) + check_dependencies + initialize_autotools + configure_project + compile_project + ;; + --install) + install_project + ;; + --clean) + clean_project + ;; + --help) + show_help + ;; + *) + echo_error "Unbekannte Option: $arg" + show_help + ;; + esac + done +} + +# Aufruf der Hauptfunktion mit allen übergebenen Argumenten +main "$@" diff --git a/compat/jansson/Makefile.am b/compat/jansson/Makefile.am index 94a583f..4583a04 100644 --- a/compat/jansson/Makefile.am +++ b/compat/jansson/Makefile.am @@ -1,18 +1,19 @@ +noinst_LIBRARIES = libjansson.a -noinst_LIBRARIES = libjansson.a +libjansson_a_SOURCES = \ + dump.c \ + hashtable.c \ + load.c \ + strbuffer.c \ + utf.c \ + value.c -libjansson_a_SOURCES = \ - config.h \ - dump.c \ - hashtable.c \ - hashtable.h \ - jansson.h \ - jansson_private.h \ - load.c \ - strbuffer.c \ - strbuffer.h \ - utf.c \ - utf.h \ - util.h \ - value.c +noinst_HEADERS = \ + config.h \ + hashtable.h \ + jansson.h \ + jansson_private.h \ + strbuffer.h \ + utf.h \ + util.h diff --git a/configure.ac b/configure.ac index 5148940..974d59a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,16 +1,25 @@ -AC_INIT([nolambocoin-miner], [1.0]) AC_PREREQ([2.59c]) -AC_CONFIG_SRCDIR([cpu-miner.c]) +AC_INIT([nolambocoin-miner], [1.0]) AM_INIT_AUTOMAKE([foreign]) + +AC_CONFIG_SRCDIR([cpu-miner.c]) AC_CONFIG_HEADERS([cpuminer-config.h]) -dnl Make sure anyone changing configure.ac/Makefile.am has a clue +# Füge die Makefile-Konfiguration hinzu +AC_CONFIG_FILES([Makefile + compat/Makefile + compat/jansson/Makefile + ]) + +# Lade pkg-config Makros +PKG_PROG_PKG_CONFIG + AM_MAINTAINER_MODE EXTERNAL_CFLAGS="$CFLAGS" -dnl Checks for programs +# Checks for programs AC_PROG_CC AC_PROG_GCC_TRADITIONAL AM_PROG_CC_C_O @@ -18,12 +27,12 @@ AM_PROG_AS AC_PROG_RANLIB if test -n "$EXTERNAL_CFLAGS"; then - CFLAGS="$EXTERNAL_CFLAGS" + CFLAGS="$EXTERNAL_CFLAGS" else - CFLAGS='-Wall -O2 -fomit-frame-pointer' + CFLAGS='-Wall -O2 -fomit-frame-pointer' fi -dnl Checks for header files +# Checks for header files AC_CHECK_HEADERS([sys/endian.h sys/param.h syslog.h sys/sysctl.h]) AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [], @@ -38,54 +47,35 @@ AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [], AC_FUNC_ALLOCA AC_CHECK_FUNCS([getopt_long]) -dnl Pthread Flags +# Pthread Flags AC_CHECK_LIB([pthread], [pthread_create], [PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR([pthread library not found.])]) AC_SUBST([PTHREAD_LIBS]) -AC_CHECK_FLAGS([-pthread], - [PTHREAD_CFLAGS="-pthread"], - [PTHREAD_CFLAGS=""]) +# Ersetze AC_CHECK_FLAGS durch AC_COMPILE_IFELSE +AC_MSG_CHECKING([whether -pthread flag is supported]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], + [PTHREAD_CFLAGS="-pthread"], + [PTHREAD_CFLAGS=""]) +AC_MSG_RESULT([$PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CFLAGS]) -dnl WS2 Libraries (Windows) +# WS2 Libraries (Windows) WS2_LIBS="" have_win32=false -# Conditional builds for all platforms -case $target in -*-*-mingw*) - have_win32=true - WS2_LIBS="-lws2_32" - ;; -esac - -AC_SUBST([WS2_LIBS]) - -dnl Checks for libcurl -PKG_CHECK_MODULES([CURL], [libcurl], [], [AC_MSG_ERROR([libcurl is required but not installed.])]) -AC_SUBST([CURL_CFLAGS]) -AC_SUBST([CURL_LIBS]) - -dnl Checks for jansson -PKG_CHECK_MODULES([JANSSON], [jansson], [], [AC_MSG_ERROR([jansson is required but not installed.])]) -AC_SUBST([JANSSON_CFLAGS]) -AC_SUBST([JANSSON_LIBS]) - -dnl Platform Detection -AC_MSG_CHECKING([for target platform]) - +# Plattform-Erkennung UNAME_S=`uname -s` UNAME_M=`uname -m` +AC_MSG_CHECKING([for target platform]) AC_MSG_RESULT([$UNAME_S $UNAME_M]) case "$UNAME_S" in Linux*) case "$UNAME_M" in armv7l*|armv8*|aarch64*) - # Allgemeine Raspberry Pi Erkennung ohne spezifische Modelle if grep -q "Raspberry Pi" /proc/device-tree/model 2>/dev/null; then AC_DEFINE([TARGET_RASPBERRY_PI], [1], [Define to 1 if compiling for Raspberry Pi]) AM_CONDITIONAL([TARGET_RASPBERRY_PI], [true]) @@ -143,12 +133,20 @@ esac AM_CONDITIONAL([WANT_JANSSON], [true]) -AC_SUBST(JANSSON_CFLAGS) -AC_SUBST(JANSSON_LIBS) -AC_SUBST(CURL_CFLAGS) -AC_SUBST(CURL_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(WS2_LIBS) +# Checks für libcurl +PKG_CHECK_MODULES([CURL], [libcurl >= 7.0], [], + [AC_MSG_ERROR([libcurl is required but not installed.])]) -AC_OUTPUT \ No newline at end of file +# Checks für jansson +PKG_CHECK_MODULES([JANSSON], [jansson >= 2.0], [], + [AC_MSG_ERROR([jansson is required but not installed.])]) + +AC_SUBST([JANSSON_CFLAGS]) +AC_SUBST([JANSSON_LIBS]) +AC_SUBST([CURL_CFLAGS]) +AC_SUBST([CURL_LIBS]) +AC_SUBST([PTHREAD_CFLAGS]) +AC_SUBST([PTHREAD_LIBS]) +AC_SUBST([WS2_LIBS]) + +AC_OUTPUT