Revert "opkg: disable the use of vfork for the host build"
[openwrt/openwrt.git] / package / system / opkg / Makefile
1 #
2 # Copyright (C) 2006-2015 OpenWrt.org
3 # Copyright (C) 2016 LEDE Project
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 include $(INCLUDE_DIR)/version.mk
11 include $(INCLUDE_DIR)/feeds.mk
12
13 PKG_NAME:=opkg
14 PKG_REV:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d
15 PKG_VERSION:=$(PKG_REV)
16 PKG_RELEASE:=13
17
18 PKG_SOURCE_PROTO:=git
19 PKG_SOURCE_VERSION:=$(PKG_REV)
20 PKG_SOURCE_SUBDIR:=opkg-$(PKG_VERSION)
21 PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg
22 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
23 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
24 PKG_FIXUP:=autoreconf
25 PKG_REMOVE_FILES = autogen.sh aclocal.m4
26
27 PKG_LICENSE:=GPL-2.0
28 PKG_LICENSE_FILES:=COPYING
29
30 PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
31
32 PKG_FLAGS := nonshared
33 PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES
34
35 PKG_BUILD_PARALLEL:=1
36 HOST_BUILD_PARALLEL:=1
37 PKG_INSTALL:=1
38
39 include $(INCLUDE_DIR)/package.mk
40 include $(INCLUDE_DIR)/host-build.mk
41
42 define Package/opkg/Default
43 SECTION:=base
44 CATEGORY:=Base system
45 TITLE:=opkg package manager
46 DEPENDS:=+uclient-fetch
47 URL:=http://wiki.openmoko.org/wiki/Opkg
48 MENU:=1
49 endef
50
51 define Package/opkg/Default/description
52 Lightweight package management system
53 opkg is the opkg Package Management System, for handling
54 installation and removal of packages on a system. It can
55 recursively follow dependencies and download all packages
56 necessary to install a particular package.
57
58 opkg knows how to install both .ipk and .deb packages.
59 endef
60
61 define Package/opkg/config
62 config OPKG_SUPPORT_MD5
63 bool
64 default n
65 depends on PACKAGE_opkg
66 prompt "Support reading old md5 hashes."
67 help
68 Old opkg used md5s, new uses sha. This options enables understanding both while prefering sha.
69 endef
70
71 define Package/opkg
72 $(call Package/opkg/Default)
73 VARIANT:=unsigned
74 endef
75
76 define Package/opkg/description
77 $(call Package/opkg/Default/description)
78 endef
79
80 define Package/opkg/conffiles
81 /etc/opkg.conf
82 /etc/opkg/keys/
83 /etc/opkg/customfeeds.conf
84 endef
85
86
87 define Package/opkg-smime
88 $(call Package/opkg/Default)
89 TITLE+= (with S/MIME signature support)
90 DEPENDS+=+PACKAGE_opkg-smime:libopenssl
91 VARIANT:=smime
92 endef
93
94 define Package/opkg-smime/description
95 $(call Package/opkg/Default/description)
96
97 This package allows the Package index to be verified with S/MIME.
98 endef
99
100 define Package/opkg-smime/config
101 config OPKG_SMIME_SUPPORT_MD5
102 bool
103 default n
104 depends on PACKAGE_opkg-smime
105 prompt "Support reading old md5 hashes."
106 help
107 Old opkg used md5s, new uses sha. This options enables understanding both while prefering sha.
108 endef
109
110 Package/opkg-smime/conffiles = $(Package/opkg/conffiles)
111
112 TARGET_CFLAGS += -ffunction-sections -fdata-sections
113 EXTRA_CFLAGS += $(TARGET_CPPFLAGS)
114
115 CONFIGURE_ARGS += \
116 --disable-curl \
117 --disable-gpg \
118 --enable-sha256 \
119 --with-opkgetcdir=/etc \
120 --with-opkglockfile=/var/lock/opkg.lock
121
122 ifeq ($(BUILD_VARIANT),smime)
123 CONFIGURE_ARGS += --enable-openssl --disable-usign
124 ifeq ($(CONFIG_OPKG_SMIME_SUPPORT_MD5),y)
125 CONFIGURE_ARGS += --enable-md5
126 else
127 CONFIGURE_ARGS += --disable-md5
128 endif
129 else
130 ifndef CONFIG_SIGNED_PACKAGES
131 CONFIGURE_ARGS += --disable-usign
132 endif
133 ifeq ($(CONFIG_OPKG_SUPPORT_MD5),y)
134 CONFIGURE_ARGS += --enable-md5
135 else
136 CONFIGURE_ARGS += --disable-md5
137 endif
138 endif
139
140 MAKE_FLAGS = \
141 CC="$(TARGET_CC)" \
142 DESTDIR="$(PKG_INSTALL_DIR)" \
143 HOST_CPU="$(PKGARCH)" \
144 LDFLAGS="-Wl,--gc-sections" \
145
146 define Package/opkg/Default/install
147 $(INSTALL_DIR) $(1)/usr/lib/opkg
148 $(INSTALL_DIR) $(1)/bin
149 $(INSTALL_DIR) $(1)/etc/opkg
150 $(INSTALL_DIR) $(1)/etc/uci-defaults
151 $(INSTALL_DATA) ./files/customfeeds.conf $(1)/etc/opkg/customfeeds.conf
152 $(INSTALL_DATA) ./files/opkg$(2).conf $(1)/etc/opkg.conf
153 $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf)
154 $(VERSION_SED) $(1)/etc/opkg/distfeeds.conf
155 $(INSTALL_BIN) ./files/20_migrate-feeds $(1)/etc/uci-defaults/
156 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
157 endef
158
159 define Package/opkg/install
160 $(call Package/opkg/Default/install,$(1),)
161 ifneq ($(CONFIG_SIGNED_PACKAGES),)
162 echo "option check_signature 1" >> $(1)/etc/opkg.conf
163 endif
164 mkdir $(1)/usr/sbin
165 $(INSTALL_BIN) ./files/opkg-key $(1)/usr/sbin/
166 endef
167
168 define Package/opkg-smime/install
169 $(call Package/opkg/Default/install,$(1),-smime)
170 $(INSTALL_DIR) $(1)/etc/ssl/certs
171 $(if $(CONFIG_OPKGSMIME_CERT),$(INSTALL_DATA) $(call qstrip,$(CONFIG_OPKGSMIME_CERT)) $(1)/etc/ssl/certs/opkg.pem,)
172 endef
173
174 define Build/InstallDev
175 mkdir -p $(1)/usr/include
176 $(CP) $(PKG_INSTALL_DIR)/usr/include/libopkg $(1)/usr/include/
177 endef
178
179
180 HOST_CONFIGURE_ARGS+= \
181 --disable-curl \
182 --disable-gpg \
183 --enable-sha256 \
184 --with-opkgetcdir=/etc \
185 --with-opkglockfile=/tmp/opkg.lock
186
187 define Host/Compile
188 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) CC="$(HOSTCC)" all
189 endef
190
191 define Host/Install
192 $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg
193 endef
194
195 $(eval $(call BuildPackage,opkg))
196 $(eval $(call BuildPackage,opkg-smime))
197 $(eval $(call HostBuild))