Openssl add host

i want to add a host in openssl for package purposes. can anyone tell me add host in openssl. I saw in the past that openssl can add hosts

https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg26956.html

The message that you referenced, contains a patch that adds a "host build" of openssl to the Makefile so that openssl is built also for the buildhost, not just for the router. Is that what you want?

The message was from year 2014 and would likely require large modifications to match the current OpenWrt and openssl.

Usually you already have a native openssl library available for most platforms so it makes no sense to use the OpenWrt make system for recreating it.

1 Like

for example i created host in bind package and i found this problem. although I added --without-openssl in HOST_CONFIGURE_ARGS

/bin/sh ../../libtool  --tag=CC   --mode=link gcc -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wno-missing-field-initializers -Wformat -Wshadow -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=format-security -Werror=parentheses -Werror=implicit -Werror=strict-prototypes -Werror=vla -fno-strict-aliasing -fno-delete-null-pointer-checks -fdiagnostics-show-option -O2 -I/home/open/sdk64/staging_dir/host/include -I/home/open/sdk64/staging_dir/hostpkg/include -I/home/open/sdk64/staging_dir/target-aarch64_cortex-a53_musl/host/include -pthread -Wl,--export-dynamic  -release "9.18.11" -L/home/open/sdk64/staging_dir/host/lib -L/home/open/sdk64/staging_dir/hostpkg/lib -L/home/open/sdk64/staging_dir/target-aarch64_cortex-a53_musl/host/lib -o libisc.la -rpath /home/open/sdk64/staging_dir/hostpkg/lib  netmgr/libisc_la-netmgr.lo netmgr/libisc_la-tcp.lo netmgr/libisc_la-tcpdns.lo netmgr/libisc_la-timer.lo netmgr/libisc_la-tlsdns.lo netmgr/libisc_la-udp.lo netmgr/libisc_la-uv-compat.lo netmgr/libisc_la-uverr2result.lo libisc_la-aes.lo libisc_la-app.lo libisc_la-assertions.lo libisc_la-astack.lo libisc_la-backtrace.lo libisc_la-base32.lo libisc_la-base64.lo libisc_la-bind9.lo libisc_la-buffer.lo libisc_la-commandline.lo libisc_la-condition.lo libisc_la-counter.lo libisc_la-crc64.lo libisc_la-dir.lo libisc_la-entropy.lo libisc_la-errno.lo libisc_la-errno2result.lo libisc_la-error.lo libisc_la-event.lo libisc_la-file.lo libisc_la-fsaccess.lo libisc_la-fsaccess_common.lo libisc_la-glob.lo libisc_la-hash.lo libisc_la-heap.lo libisc_la-hex.lo libisc_la-hmac.lo libisc_la-ht.lo libisc_la-httpd.lo libisc_la-interfaceiter.lo libisc_la-iterated_hash.lo libisc_la-lex.lo libisc_la-lib.lo libisc_la-log.lo libisc_la-managers.lo libisc_la-md.lo libisc_la-mem.lo libisc_la-meminfo.lo libisc_la-mutex.lo libisc_la-mutexblock.lo libisc_la-net.lo libisc_la-netaddr.lo libisc_la-netscope.lo libisc_la-nonce.lo libisc_la-openssl_shim.lo libisc_la-os.lo libisc_la-parseint.lo libisc_la-pool.lo libisc_la-picohttpparser.lo libisc_la-portset.lo libisc_la-quota.lo libisc_la-radix.lo libisc_la-random.lo libisc_la-ratelimiter.lo libisc_la-regex.lo libisc_la-region.lo libisc_la-resource.lo libisc_la-result.lo libisc_la-rwlock.lo libisc_la-safe.lo libisc_la-serial.lo libisc_la-siphash.lo libisc_la-sockaddr.lo libisc_la-stats.lo libisc_la-stdio.lo libisc_la-stdtime.lo libisc_la-string.lo libisc_la-symtab.lo libisc_la-syslog.lo libisc_la-task.lo libisc_la-taskpool.lo libisc_la-thread.lo libisc_la-time.lo libisc_la-timer.lo libisc_la-tls.lo libisc_la-tm.lo libisc_la-trampoline.lo libisc_la-url.lo libisc_la-utf8.lo netmgr/libisc_la-http.lo netmgr/libisc_la-tlsstream.lo -L/home/open/sdk64/staging_dir/hostpkg/lib -luv -lpthread -ldl -lrt  -L/home/open/sdk64/staging_dir/hostpkg/lib -lssl -lcrypto  -L/home/open/sdk64/staging_dir/hostpkg/lib -lz   -L/home/open/sdk64/staging_dir/host/lib -ljson-c  -L/home/open/sdk64/staging_dir/hostpkg/lib -lnghttp2  -L/home/open/sdk64/staging_dir/hostpkg/lib -lxml2
OpenWrt-libtool: link: warning: library `/home/open/sdk64/staging_dir/host/lib/libssl.la' was moved.
/home/open/sdk64/staging_dir/target-aarch64_cortex-a53_musl/../host/bin/grep: /builder/shared-workdir/build/staging_dir/host/lib/libcrypto.la: No such file or directory
/home/open/sdk64/staging_dir/target-aarch64_cortex-a53_musl/../host/bin/sed: can't read /builder/shared-workdir/build/staging_dir/host/lib/libcrypto.la: No such file or directory
OpenWrt-libtool: link: `/builder/shared-workdir/build/staging_dir/host/lib/libcrypto.la' is not a valid libtool archive

Please use the </> button when pasting code/cli output

#
# Copyright (C) 2006-2012 OpenWrt.org
#               2014-2020 Noah Meyerhans <frodo@morgul.net>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=bind
PKG_VERSION:=9.18.11
PKG_RELEASE:=2
USERID:=bind=57:bind=57

PKG_MAINTAINER:=Noah Meyerhans <frodo@morgul.net>
PKG_LICENSE:=MPL-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_CPE_ID:=cpe:/a:isc:bind

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:= \
	https://www.mirrorservice.org/sites/ftp.isc.org/isc/bind9/$(PKG_VERSION) \
	https://ftp.isc.org/isc/bind9/$(PKG_VERSION)
PKG_HASH:=8ff3352812230cbcbda42df87cad961f94163d3da457c5e4bef8057fd5df2158

PKG_FIXUP:=autoreconf
HOST_REMOVE_FILES:=aclocal.m4 libtool.m4
PKG_REMOVE_FILES:=aclocal.m4 libtool.m4

PKG_INSTALL:=1
PKG_USE_MIPS16:=0
PKG_BUILD_PARALLEL:=1

HOST_BUILD_DEPENDS:=nghttp2/host libuv/host libjson-c/host
PKG_BUILD_DEPENDS:=nghttp2

PKG_CONFIG_DEPENDS := \
	CONFIG_BIND_LIBJSON \
	CONFIG_BIND_LIBXML2

PKG_BUILD_DEPENDS += BIND_LIBXML2:libxml2 BIND_LIBJSON:libjson-c

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk

define Package/bind/Default
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+bind-libs +@OPENSSL_WITH_EC
  TITLE:=bind
  URL:=https://www.isc.org/software/bind
  SUBMENU:=IP Addresses and Names
endef

define Package/bind-libs
  SECTION:=libs
  CATEGORY:=Libraries
  DEPENDS:=+libopenssl \
	+zlib \
	+libpthread \
	+libatomic \
	+libuv \
	+libnghttp2 \
	+BIND_LIBXML2:libxml2 \
	+BIND_LIBJSON:libjson-c
  TITLE:=bind shared libraries
  URL:=https://www.isc.org/software/bind
endef

define Package/bind-server
  $(call Package/bind/Default)
  TITLE+= DNS server
  DEPENDS+= +libcap
endef

define Package/bind-server/config
	source "$(SOURCE)/Config.in"
endef

define Package/bind-server-filter-aaaa
  $(call Package/bind-server)
  DEPENDS:=bind-server
  TITLE+= filter AAAA plugin
endef

define Package/bind-client
  $(call Package/bind/Default)
  TITLE+= dynamic DNS client
endef

define Package/bind-tools
  $(call Package/bind/Default)
  TITLE+= administration tools (all)
	DEPENDS:= \
	+bind-check \
	+bind-dig \
	+bind-nslookup \
	+bind-dnssec \
	+bind-host \
	+bind-rndc
endef

define Package/bind-rndc
  $(call Package/bind/Default)
  TITLE+= administration tools (rndc and rndc-confgen only)
endef

define Package/bind-check
  $(call Package/bind/Default)
  TITLE+= administration tools (named-checkconf and named-checkzone only)
endef

define Package/bind-dnssec
  $(call Package/bind/Default)
  TITLE+= administration tools (dnssec-keygen, dnssec-settime and dnssec-signzone only)
endef

define Package/bind-host
  $(call Package/bind/Default)
  TITLE+= simple DNS client
endef

define Package/bind-dig
  $(call Package/bind/Default)
  TITLE+= DNS excavation tool
endef

define Package/bind-nslookup
  $(call Package/bind/Default)
  TITLE+= nslookup utility
  ALTERNATIVES:= \
	  200:/usr/bin/nslookup:/usr/libexec/nslookup-bind
endef

export BUILD_CC="$(TARGET_CC)"

TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed

HOST_CONFIGURE_ARGS += \
	--disable-linux-caps \
	--disable-geoip \
	--without-openssl \
	--with-libtool \
	--without-lmdb \
	--enable-epoll \
	--without-gssapi \
	--without-readline \
	--without-python

HOST_CONFIGURE_VARS += \
	BUILD_CC="$(HOST_CC)" \

CONFIGURE_ARGS += \
	--disable-linux-caps \
	--disable-geoip \
	--with-openssl="$(STAGING_DIR)/usr" \
	--with-libtool \
	--without-lmdb \
	--enable-epoll \
	--without-gssapi \
	--without-readline \
	--without-python \
	--sysconfdir=/etc/bind

ifdef CONFIG_BIND_LIBJSON
	TARGET_CFLAGS += -DHAVE_JSON_C -UHAVE_JSON
	CONFIGURE_ARGS += \
		--with-json-c=yes
else
	CONFIGURE_ARGS += \
		--with-json-c=no
endif

ifdef CONFIG_BIND_LIBXML2
	CONFIGURE_ARGS += \
		--with-libxml2=yes
else
	CONFIGURE_ARGS += \
		--with-libxml2=no
endif

CONFIGURE_VARS += \
	BUILD_CC="$(TARGET_CC)" \

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR)/lib/dns \
		BUILD_CC="$(HOSTCC)" \
		CC="$(HOSTCC)" \
		CFLAGS="-O2" \
		LIBS="" \
		gen
	$(call Build/Compile/Default)
endef

define Host/Install
	$(INSTALL_DIR) $(STAGING_DIR_HOST)/include
	$(CP) $(HOST_BUILD_DIR)/lib/bind/include/* $(STAGING_DIR_HOST)/include/
	$(INSTALL_DIR) $(STAGING_DIR_HOST)/lib/
	$(CP) $(HOST_BUILD_DIR)/lib/bind/libbind.a $(STAGING_DIR_HOST)/lib/
endef

define Package/bind-libs/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib
endef

define Package/bind-server/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/named $(1)/usr/sbin/
	$(INSTALL_DIR) $(1)/etc/bind
	$(CP) \
		./files/bind/db.0 \
		./files/bind/db.127 \
		./files/bind/db.255 \
		./files/bind/db.local \
		./files/bind/db.root \
		./files/bind/bind.keys \
		$(1)/etc/bind/
	sed -e '1s/ broadcast / empty rfc1918 /' \
		< ./files/bind/db.0 \
		> $(1)/etc/bind/db.empty
	$(CP) ./files/bind/named.conf.example $(1)/etc/bind/named.conf
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/named.init $(1)/etc/init.d/named
	find $(1)/etc/bind/ -name ".svn" | xargs rm -rf
endef

define Package/bind-server/conffiles
/etc/bind/db.0
/etc/bind/db.127
/etc/bind/db.255
/etc/bind/db.local
/etc/bind/db.root
/etc/bind/named.conf
endef

define Package/bind-server-filter-aaaa/install
	$(INSTALL_DIR) $(1)/usr/lib/bind
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/bind/filter-aaaa.so $(1)/usr/lib/bind
endef

define Package/bind-client/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/nsupdate $(1)/usr/bin/
endef

define Package/bind-tools/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/delv $(1)/usr/bin/
endef

define Package/bind-rndc/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rndc $(1)/usr/sbin/
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rndc-confgen $(1)/usr/sbin/
endef

define Package/bind-check/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/named-checkconf $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/named-checkzone $(1)/usr/bin/
endef

define Package/bind-dnssec/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dnssec-keygen $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dnssec-settime $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dnssec-signzone $(1)/usr/bin/
endef

define Package/bind-host/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/host $(1)/usr/bin/
endef

define Package/bind-dig/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dig $(1)/usr/bin/
endef

define Package/bind-nslookup/install
	$(INSTALL_DIR) $(1)/usr/libexec
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/nslookup $(1)/usr/libexec/nslookup-bind
endef

$(eval $(call HostBuild,bind-libs))
$(eval $(call BuildPackage,bind-libs))
$(eval $(call BuildPackage,bind-server))
$(eval $(call BuildPackage,bind-server-filter-aaaa))
$(eval $(call BuildPackage,bind-client))
$(eval $(call BuildPackage,bind-tools))
$(eval $(call BuildPackage,bind-rndc))
$(eval $(call BuildPackage,bind-check))
$(eval $(call BuildPackage,bind-dnssec))
$(eval $(call BuildPackage,bind-host))
$(eval $(call BuildPackage,bind-dig))
$(eval $(call BuildPackage,bind-nslookup))