Browse Source

Merge branch 'libbase58' into bfgminer

Luke Dashjr 11 years ago
parent
commit
0f1e6b3e15
10 changed files with 156 additions and 62 deletions
  1. 3 0
      .gitmodules
  2. 5 20
      Makefile.am
  3. 5 41
      configure.ac
  4. 1 0
      libbase58
  5. 1 1
      libblkmaker
  6. 98 0
      m4/bundled_lib.m4
  7. 34 0
      m4/custom_subdirs.m4
  8. 3 0
      make-release
  9. 2 0
      openwrt/bfgminer/Makefile
  10. 4 0
      windows-build.txt

+ 3 - 0
.gitmodules

@@ -4,3 +4,6 @@
 [submodule "ccan"]
 	path = ccan-upstream
 	url = git://git.ozlabs.org/~ccan/ccan
+[submodule "libbase58"]
+	path = libbase58
+	url = https://github.com/luke-jr/libbase58.git

+ 5 - 20
Makefile.am

@@ -65,10 +65,6 @@ bfgminer_CPPFLAGS += $(NCURSES_CPPFLAGS)
 bfgminer_CPPFLAGS += $(AUTOSCAN_CPPFLAGS)
 bfgminer_LDADD += $(AUTOSCAN_LIBS)
 
-bfgminer_LDADD += $(libblkmaker_LIBS)
-bfgminer_LDFLAGS += $(libblkmaker_LDFLAGS)
-bfgminer_CPPFLAGS += $(libblkmaker_CFLAGS)
-
 # common sources
 bfgminer_SOURCES := miner.c
 
@@ -86,22 +82,11 @@ version.h: update-version
 bfgminer_SOURCES += version.h
 BUILT_SOURCES = version.h
 
-SUBDIRS += $(LIBBLKMAKER_SUBDIRS)
-LIBBLKMAKER_SUBDIRS =
-if NEED_LIBBLKMAKER
-LIBBLKMAKER_SUBDIRS         += libblkmaker
-EXTRA_bfgminer_DEPENDENCIES += libblkmaker_directory
-libblkmaker_directory:
-	cd libblkmaker && $(MAKE)
-
-if HAVE_CYGWIN
-EXTRA_bfgminer_DEPENDENCIES += cygblkmaker-0.1-0.dll cygblkmaker_jansson-0.1-0.dll
-
-cyg%.dll: libblkmaker/.libs/cyg%.dll
-	cp -p $< $@
-endif
-
-endif
+SUBDIRS += $(libbase58_SUBDIRS) $(libblkmaker_SUBDIRS)
+bfgminer_LDADD += $(libbase58_LIBS) $(libblkmaker_LIBS)
+bfgminer_CPPFLAGS += $(libbase58_CFLAGS) $(libblkmaker_CFLAGS)
+EXTRA_bfgminer_DEPENDENCIES += $(libbase58_EXTRADEPS) $(libblkmaker_EXTRADEPS)
+@BUNDLED_LIB_RULES@
 
 bfgminer_SOURCES	+= logging.c
 

+ 5 - 41
configure.ac

@@ -1386,44 +1386,8 @@ else
 fi
 
 
-maybe_ldconfig=
-AC_ARG_WITH([system-libblkmaker], [AC_HELP_STRING([--with-system-libblkmaker], [Use system libblkmaker rather than bundled one (default disabled)])],[true],[with_system_libblkmaker=no])
-if test "x$with_system_libblkmaker" = "xyes"; then
-	PKG_CHECK_MODULES([libblkmaker],[libblkmaker_jansson-0.1],[
-		true
-	],[
-		AC_MSG_ERROR([Could not find system libblkmaker])
-	])
-else
-	save_LDFLAGS="$LDFLAGS"
-	LDFLAGS="$LDFLAGS -Wl,-zorigin"
-	origin_LDFLAGS=
-	AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
-	AC_TRY_LINK([],[],[
-		AC_MSG_RESULT([yes])
-		origin_LDFLAGS=',-zorigin'
-	],[
-		AC_MSG_RESULT([no])
-	])
-	LDFLAGS="$save_LDFLAGS"
-	
-	libblkmaker_CFLAGS='-Ilibblkmaker'
-	libblkmaker_LDFLAGS='-Llibblkmaker/.libs -Wl,-rpath,\$$ORIGIN/libblkmaker/.libs'"$origin_LDFLAGS"
-	libblkmaker_LIBS='-lblkmaker_jansson-0.1 -lblkmaker-0.1'
-	AC_CONFIG_SUBDIRS([libblkmaker])
-	_ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g`
-	possible_ldconfigs="${target}-ldconfig"
-	if test "x$cross_compiling" != "xyes"; then
-		possible_ldconfigs="${possible_ldconfigs} ldconfig"
-	fi
-	AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH])
-	if test "x$LDCONFIG" != "x"; then
-		maybe_ldconfig=" && $LDCONFIG"
-	fi
-fi
-AC_SUBST(libblkmaker_CFLAGS)
-AC_SUBST(libblkmaker_LDFLAGS)
-AC_SUBST(libblkmaker_LIBS)
+BFG_BUNDLED_LIB([libbase58],[libbase58],[auto],[libbase58],[base58],[],[--disable-tool --disable-static --enable-shared])
+BFG_BUNDLED_LIB([libblkmaker],[libblkmaker_jansson-0.1],[no],[libblkmaker],[blkmaker_jansson-0.1 blkmaker-0.1],[libbase58])
 
 
 $have_udevrules || use_udevrules=false
@@ -1447,7 +1411,6 @@ if $use_udevrules; then
 fi
 
 
-AM_CONDITIONAL([NEED_LIBBLKMAKER], [test x$with_system_libblkmaker != xyes])
 AM_CONDITIONAL([NEED_BFG_BINLOADER], [test x$need_binloader = xyes])
 AM_CONDITIONAL([NEED_DYNCLOCK], [test x$need_dynclock = xyes])
 AM_CONDITIONAL([USE_GC3355], [test x$need_gc3355 = xyes])
@@ -1859,6 +1822,7 @@ if $use_udevrules; then
 fi
 
 AC_OUTPUT
+BFG_CUSTOM_SUBDIRS_OUTPUT
 
 
 wordfilter ()
@@ -1871,8 +1835,8 @@ echo "------------------------------------------------------------------------"
 echo "$PACKAGE $VERSION configuration options summary"
 echo "------------------------------------------------------------------------"
 echo
-echo "  CFLAGS...............: "`wordfilter "$CPPFLAGS $AUTOSCAN_CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libblkmaker_CFLAGS $hidapi_CFLAGS"`
-echo "  LDFLAGS..............: "`wordfilter "$LDFLAGS $AUTOSCAN_LIBS $PTHREAD_FLAGS $libblkmaker_LDFLAGS $PTHREAD_LIBS $LIBS $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $UDEV_LIBS $LIBUSB_LIBS $RT_LIBS $sensors_LIBS $libblkmaker_LIBS"`
+echo "  CFLAGS...............: "`wordfilter "$CPPFLAGS $AUTOSCAN_CPPFLAGS $NCURSES_CPPFLAGS $PTHREAD_FLAGS $CFLAGS $LIBUSB_CFLAGS $JANSSON_CFLAGS $PTHREAD_FLAGS $libbase58_CFLAGS $libblkmaker_CFLAGS $hidapi_CFLAGS"`
+echo "  LDFLAGS..............: "`wordfilter "$LDFLAGS $AUTOSCAN_LIBS $PTHREAD_FLAGS $PTHREAD_LIBS $LIBS $DLOPEN_FLAGS $LIBCURL_LIBS $JANSSON_LIBS $NCURSES_LIBS $PDCURSES_LIBS $WS2_LIBS $MATH_LIBS $UDEV_LIBS $LIBUSB_LIBS $RT_LIBS $sensors_LIBS $libbase58_LIBS $libblkmaker_LIBS"`
 echo "  Installation.prefix..: $prefix"
 echo
 echo "${lowllist_print}" | tr '~' '\n'

+ 1 - 0
libbase58

@@ -0,0 +1 @@
+Subproject commit 619e4e15e323a93b4068c42535da7be977fb3de3

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit 6cc0258704ece616f2de6e5509abfc7fba108957
+Subproject commit d46062c7e66bd57e5e2640c4289c127c150bb495

+ 98 - 0
m4/bundled_lib.m4

@@ -0,0 +1,98 @@
+dnl * Copyright 2014 Luke Dashjr
+dnl *
+dnl * This program is free software; you can redistribute it and/or modify it
+dnl * under the terms of the GNU General Public License as published by the Free
+dnl * Software Foundation; either version 3 of the License, or (at your option)
+dnl * any later version.  See COPYING for more details.
+
+m4_divert_text([DEFAULTS], [
+origin_LDFLAGS=
+origin_LDFLAGS_checked=false
+maybe_ldconfig=
+maybe_ldconfig_checked=false
+BUNDLED_LIB_RULES=
+])
+
+AC_SUBST(BUNDLED_LIB_RULES)
+AM_SUBST_NOTMAKE(BUNDLED_LIB_RULES)
+
+AC_DEFUN([BFG_CHECK_LD_ORIGIN],[
+if ! $origin_LDFLAGS_checked; then
+	save_LDFLAGS="$LDFLAGS"
+	LDFLAGS="$LDFLAGS -Wl,-zorigin"
+	AC_MSG_CHECKING([whether the linker recognizes the -zorigin option])
+	AC_TRY_LINK([],[],[
+		AC_MSG_RESULT([yes])
+		origin_LDFLAGS=',-zorigin'
+	],[
+		AC_MSG_RESULT([no])
+	])
+	LDFLAGS="$save_LDFLAGS"
+	origin_LDFLAGS_checked=true
+fi
+])
+
+AC_DEFUN([BFG_CHECK_LDCONFIG],[
+if ! $maybe_ldconfig_checked; then
+	_ROOTPATH=$PATH$PATH_SEPARATOR`echo $PATH | sed s/bin/sbin/g`
+	possible_ldconfigs="${target}-ldconfig"
+	if test "x$cross_compiling" != "xyes"; then
+		possible_ldconfigs="${possible_ldconfigs} ldconfig"
+	fi
+	AC_CHECK_PROGS([LDCONFIG],[${possible_ldconfigs}],[],[$_ROOTPATH])
+	if test "x$LDCONFIG" != "x"; then
+		maybe_ldconfig=" && $LDCONFIG"
+	fi
+	maybe_ldconfig_checked=true
+fi
+])
+
+AC_DEFUN([BFG_BUNDLED_LIB_VARS],[
+	BFG_CHECK_LD_ORIGIN
+	_AC_SRCDIRS(["$ac_dir"])
+	$1_CFLAGS='-I'"${ac_abs_top_srcdir}"'/$2'
+	$1_LIBS='-L'"${ac_abs_top_srcdir}"'/$2/.libs -Wl,-rpath,\$$ORIGIN/$2/.libs'"$origin_LDFLAGS"' m4_foreach_w([mylib],[$3],[ -l[]mylib])'
+	$1_SUBDIRS=$2
+	$1_EXTRADEPS=$1_directory
+	BUNDLED_LIB_RULES="$BUNDLED_LIB_RULES
+$1_directory:
+	\$(MAKE) -C $2
+"
+	if $have_cygwin; then
+		$1_EXTRADEPS="$$1_EXTRADEPS m4_foreach_w([mylib],[$3],[ cyg[]mylib[]-0.dll])"
+		BUNDLED_LIB_RULES="$BUNDLED_LIB_RULES[]m4_foreach_w([mylib],[$3],[
+cyg[]mylib[]-0.dll: $2/.libs/cyg[]mylib[]-0.dll
+	cp -p \$< \$[]@
+])"
+	fi
+])
+
+dnl BFG_BUNDLED_LIB([PKG-NAME],PKGCONF-NAME],[DEFAULT:YES/NO/AUTO],[PATH],[LIBS],[DEPENDENT-PKGS],[CONFIGURE-ARGS],[CONFIGURE-ARGS])
+AC_DEFUN([BFG_BUNDLED_LIB],[
+	AC_ARG_WITH([system-$1],[ifelse([$3],[no],AC_HELP_STRING([--with-system-$1], [Use system $1 rather than bundled one (default disabled)]),AC_HELP_STRING([--without-system-$1], [Use bundled $1 rather than system one]))],[true],[with_system_$1=$3])
+	if test "x$with_system_$1" != "xno"; then
+		PKG_CHECK_MODULES([$1],[$2],[
+			with_system_$1=yes
+		],[
+			if test "x$with_system_$1" = "xyes"; then
+				AC_MSG_ERROR([Could not find system $1])
+			else
+				AC_MSG_NOTICE([Didn't find system $1, using bundled copy])
+				with_system_$1=no
+			fi
+		])
+	fi
+	if test "x$with_system_$1" = "xno"; then
+		BFG_BUNDLED_LIB_VARS([$1],[$4],[$5])
+		BFG_CUSTOM_SUBDIR([$4],[$7],[$8 m4_foreach_w([mydep],[$6],[ mydep[]_LIBS='$mydep[]_LIBS' mydep[]_CFLAGS='$mydep[]_CFLAGS'])])
+		BFG_CHECK_LDCONFIG
+	else
+		$1_SUBDIRS=
+		$1_EXTRADEPS=
+	fi
+	AC_SUBST($1_CFLAGS)
+	AC_SUBST($1_LIBS)
+	AC_SUBST($1_SUBDIRS)
+	AC_SUBST($1_EXTRADEPS)
+	AM_CONDITIONAL(NEED_[]m4_toupper([$1]), [test x$with_system_$1 != xyes])
+])

+ 34 - 0
m4/custom_subdirs.m4

@@ -0,0 +1,34 @@
+dnl * Copyright 2014 Luke Dashjr
+dnl *
+dnl * This program is free software; you can redistribute it and/or modify it
+dnl * under the terms of the GNU General Public License as published by the Free
+dnl * Software Foundation; either version 3 of the License, or (at your option)
+dnl * any later version.  See COPYING for more details.
+
+m4_divert_text([DEFAULTS], [
+custom_subdirs=
+])
+
+AC_DEFUN([BFG_CUSTOM_SUBDIR],[
+	if false; then
+		AC_CONFIG_SUBDIRS([$1])
+	fi
+	custom_subdirs="$custom_subdirs $1"
+	custom_subdir_[]AS_TR_SH([$1])_args="$2"
+	custom_subdir_[]AS_TR_SH([$1])_forceargs="$3"
+])
+
+AC_DEFUN([BFG_CUSTOM_SUBDIRS_OUTPUT],[
+	if test "$no_recursion" != yes; then
+		orig_subdirs="$subdirs"
+		orig_ac_configure_args="$ac_configure_args"
+		for custom_subdir in $custom_subdirs; do
+			subdirs="$custom_subdir"
+			custom_subdir_base="AS_TR_SH([$custom_subdir])"
+			eval 'ac_configure_args="$custom_subdir_'"$custom_subdir_base"'_args $orig_ac_configure_args $custom_subdir_'"$custom_subdir_base"'_forceargs"'
+			_AC_OUTPUT_SUBDIRS
+		done
+		subdirs="$orig_subdirs"
+		ac_configure_args="$orig_ac_configure_args"
+	fi
+])

+ 3 - 0
make-release

@@ -97,16 +97,19 @@ for build in "${builds[@]}"; do
 		--enable-modminer \
 		--enable-ztex \
 		--enable-scrypt \
+		--without-system-libbase58 \
 		--host="$machine"
 	make $MAKEOPTS
 	if test "x$DEBUG_RELEASE" != "x1"; then
 		"$machine"-strip \
 			libblkmaker/.libs/*.dll \
+			libbase58/.libs/*.dll \
 			*.exe
 	fi
 	cp -vr \
 		*.exe \
 		libblkmaker/.libs/*.dll \
+		libbase58/.libs/*.dll \
 		opencl \
 		example.conf \
 		windows-build.txt \

+ 2 - 0
openwrt/bfgminer/Makefile

@@ -99,6 +99,7 @@ TARGET_CFLAGS += -Iuthash-1.9.8/src
 
 CONFIGURE_ARGS += --without-libudev
 CONFIGURE_ARGS += --without-sensors
+CONFIGURE_ARGS += --without-system-libbase58
 
 define Build/Prepare
 	$(call Build/Prepare/Default)
@@ -117,6 +118,7 @@ define Package/$(PKG_NAME)/install
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(PKG_NAME) $(1)/usr/bin
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(PKG_NAME)-rpc $(1)/usr/bin
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libblkmaker*.so* $(1)/usr/lib
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libbase58*.so* $(1)/usr/lib
 endef
 
 ALL_$(PKG_NAME)_PACKAGES += $(PKG_NAME)

+ 4 - 0
windows-build.txt

@@ -239,6 +239,10 @@ C:\MinGW\msys\1.0\home\USER\bfgminer\opencl
 
 	*.cl
 
+C:\MinGW\msys\1.0\home\USER\bfgminer\libbase58\.libs
+
+	libbase58-0.dll
+
 C:\MinGW\msys\1.0\home\USER\bfgminer\libblkmaker\.libs  
 
 	libblkmaker-0.1-0.dll