| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2019 Lucian Cristian |
| 3 | # |
| 4 | # This is free software, licensed under the GNU General Public License v2. |
| 5 | # See /LICENSE for more information. |
| 6 | # |
| 7 | include $(TOPDIR)/rules.mk |
| 8 | |
| 9 | PKG_NAME:=nss |
| 10 | PKG_VERSION:=3.93 |
| 11 | PKG_RELEASE:=1 |
| 12 | |
| 13 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz |
| 14 | PKG_SOURCE_URL:= \ |
| 15 | https://download.cdn.mozilla.net/pub/security/$(PKG_NAME)/releases/NSS_$(subst .,_,$(PKG_VERSION))_RTM/src \ |
| 16 | https://archive.mozilla.org/pub/security/$(PKG_NAME)/releases/NSS_$(subst .,_,$(PKG_VERSION))_RTM/src |
| 17 | PKG_HASH:=15f54bb72048eb105f8c0e936a04b899e74c3db9a19bbc1e00acee2af9476a8a |
| 18 | |
| 19 | PKG_MAINTAINER:=Lucian Cristian <lucian.cristian@gmail.com> |
| 20 | PKG_LICENSE:=MPL-2.0 |
| 21 | PKG_LICENSE_FILES:=nss/COPYING |
| 22 | PKG_CPE_ID:=cpe:/a:mozilla:network_security_services |
| 23 | |
| 24 | PKG_BUILD_PARALLEL:=0 |
| 25 | |
| 26 | include $(INCLUDE_DIR)/package.mk |
| 27 | |
| 28 | define Package/libnss |
| 29 | SECTION:=libs |
| 30 | SUBMENU:=SSL |
| 31 | CATEGORY:=Libraries |
| 32 | TITLE:=Mozilla's SSL and TLS implementation |
| 33 | URL:=https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS |
| 34 | DEPENDS:=+libpthread +libsqlite3 +nspr |
| 35 | endef |
| 36 | |
| 37 | define Package/nss-utils |
| 38 | SECTION:=utils |
| 39 | CATEGORY:=Utilities |
| 40 | TITLE:=Utilities for Mozilla's SSL and TLS implementation |
| 41 | URL:=https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS |
| 42 | DEPENDS:=+libnss |
| 43 | endef |
| 44 | |
| 45 | define Package/libnss/description |
| 46 | Network Security Services (NSS) is a set of libraries designed to support |
| 47 | cross-platform development of security-enabled client and server applications. |
| 48 | Applications built with NSS can support SSL v2 and v3, TLS, PKCS 5, PKCS 7, |
| 49 | PKCS 11, PKCS 12, S/MIME, X.509 v3 certificates, and other security standards. |
| 50 | endef |
| 51 | |
| 52 | CONFIGURE_PATH = ./nss |
| 53 | MAKE_PATH = ./nss |
| 54 | |
| 55 | LBITS = $(shell $(TARGET_CC) -dM -E - </dev/null | grep -q "__LP64__" && echo 64 || echo 32) |
| 56 | |
| 57 | ifeq ($(LBITS),64) |
| 58 | export USE_64=1 |
| 59 | endif |
| 60 | |
| 61 | ifeq ($(CONFIG_CPU_TYPE),"xscale") |
| 62 | TARGET_CFLAGS+= -mfloat-abi=softfp |
| 63 | endif |
| 64 | |
| 65 | ifneq ($(findstring arm,$(CONFIG_ARCH)),) |
| 66 | ifeq ($(findstring neon,$(CONFIG_CPU_TYPE)),) |
| 67 | export NSS_DISABLE_ARM32_NEON |
| 68 | endif |
| 69 | endif |
| 70 | |
| 71 | export NATIVE_CC=$(HOSTCC) |
| 72 | export NATIVE_FLAGS=$(HOST_CFLAGS) |
| 73 | export NSS_ENABLE_WERROR=0 |
| 74 | |
| 75 | MAKE_FLAGS += \ |
| 76 | CROSS_COMPILE=1 \ |
| 77 | BUILD_OPT=1 \ |
| 78 | NSDISTMODE=copy \ |
| 79 | NSS_DISABLE_GTESTS=1 \ |
| 80 | NSS_USE_SYSTEM_SQLITE=1 \ |
| 81 | OS_ARCH=Linux \ |
| 82 | OS_TEST=$(ARCH) \ |
| 83 | fpic="$(FPIC)" \ |
| 84 | NSPR_INCLUDE_DIR=$(STAGING_DIR)/usr/include/nspr \ |
| 85 | SEED_ONLY_DEV_URANDOM=1 \ |
| 86 | NS_USE_GCC=1 \ |
| 87 | FREEBL_NO_DEPEND=1 \ |
| 88 | NSS_PKIX_NO_LDAP=1 \ |
| 89 | ALLOW_OPT_CODE_SIZE=1 \ |
| 90 | OPT_CODE_SIZE=1 \ |
| 91 | OS_REL_CFLAGS="$(TARGET_CFLAGS)" |
| 92 | |
| 93 | #native compile nsinstall |
| 94 | define Build/Configure |
| 95 | USE_NATIVE=1 OS_REL_CFLAGS="$(HOST_CFLAGS)" LDFLAGS="$(HOST_LDFLAGS)" \ |
| 96 | CC="$(HOSTCC)" CPU_ARCH="$(HOST_ARCH)" \ |
| 97 | $(MAKE) -C $(PKG_BUILD_DIR)/nss/coreconf/nsinstall |
| 98 | endef |
| 99 | |
| 100 | define Build/Compile |
| 101 | $(call Build/Compile/Default,nss_build_all) |
| 102 | endef |
| 103 | |
| 104 | define Package/libnss/conffiles |
| 105 | /etc/pki/nssdb |
| 106 | endef |
| 107 | |
| 108 | define Build/InstallDev |
| 109 | $(INSTALL_DIR) \ |
| 110 | $(2)/bin \ |
| 111 | $(1)/usr/bin \ |
| 112 | $(1)/usr/include/nss \ |
| 113 | $(1)/usr/lib \ |
| 114 | $(1)/usr/lib/pkgconfig |
| 115 | $(CP) $(PKG_BUILD_DIR)/dist/private/nss/*.h \ |
| 116 | $(1)/usr/include/nss/ |
| 117 | $(CP) $(PKG_BUILD_DIR)/dist/public/nss/*.h \ |
| 118 | $(1)/usr/include/nss/ |
| 119 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/*.so \ |
| 120 | $(1)/usr/lib/ |
| 121 | $(CP) $(PKG_BUILD_DIR)/nss/config/*.pc \ |
| 122 | $(1)/usr/lib/pkgconfig/ |
| 123 | $(CP) $(PKG_BUILD_DIR)/nss/config/nss-config \ |
| 124 | $(1)/usr/bin/ |
| 125 | $(SED) 's,^\(prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \ |
| 126 | $(1)/usr/bin/nss-config |
| 127 | $(LN) ../../usr/bin/nss-config \ |
| 128 | $(2)/bin/ |
| 129 | endef |
| 130 | |
| 131 | define Package/nss-utils/install |
| 132 | $(INSTALL_DIR) \ |
| 133 | $(1)/usr/bin |
| 134 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/bin/certutil $(1)/usr/bin |
| 135 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/bin/pk12util $(1)/usr/bin |
| 136 | endef |
| 137 | |
| 138 | #for now pack only libreswan needed libs |
| 139 | define Package/libnss/install |
| 140 | $(INSTALL_DIR) \ |
| 141 | $(1)/usr/lib \ |
| 142 | $(1)/etc/pki/nssdb \ |
| 143 | $(1)/etc/ipsec.d |
| 144 | |
| 145 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libfreebl3.so $(1)/usr/lib/ |
| 146 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libnss3.so $(1)/usr/lib/ |
| 147 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libnssckbi.so $(1)/usr/lib/ |
| 148 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libnssutil3.so $(1)/usr/lib/ |
| 149 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libsmime3.so $(1)/usr/lib/ |
| 150 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libsoftokn3.so $(1)/usr/lib/ |
| 151 | $(CP) $(PKG_BUILD_DIR)/dist/build_dir/lib/libssl3.so $(1)/usr/lib/ |
| 152 | # Provide databases with a blank certificate |
| 153 | $(CP) ./files/blank-cert9.db $(1)/etc/pki/nssdb/cert9.db |
| 154 | $(CP) ./files/blank-key4.db $(1)/etc/pki/nssdb/key4.db |
| 155 | $(CP) ./files/system-pkcs11.txt $(1)/etc/pki/nssdb/pkcs11.txt |
| 156 | ln -s /etc/pki/nssdb/cert9.db $(1)/etc/ipsec.d/cert9.db |
| 157 | ln -s /etc/pki/nssdb/key4.db $(1)/etc/ipsec.d/key4.db |
| 158 | ln -s /etc/pki/nssdb/pkcs11.txt $(1)/etc/ipsec.d/pkcs11.txt |
| 159 | endef |
| 160 | |
| 161 | $(eval $(call BuildPackage,nss-utils)) |
| 162 | $(eval $(call BuildPackage,libnss)) |