e46c6b3a34a1b3a4ccd0387ce54a725a6f9a793a
[openwrt.git] / package / system / opkg / Makefile
1 #
2 # Copyright (C) 2006-2015 OpenWrt.org
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 include $(INCLUDE_DIR)/kernel.mk
9 include $(INCLUDE_DIR)/version.mk
10 include $(INCLUDE_DIR)/feeds.mk
11
12 PKG_NAME:=opkg
13 PKG_REV:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d
14 PKG_VERSION:=$(PKG_REV)
15 PKG_RELEASE:=10
16
17 PKG_SOURCE_PROTO:=git
18 PKG_SOURCE_VERSION:=$(PKG_REV)
19 PKG_SOURCE_SUBDIR:=opkg-$(PKG_VERSION)
20 PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg
21 PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
22 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
23 PKG_FIXUP:=autoreconf
24 PKG_REMOVE_FILES = autogen.sh aclocal.m4
25
26 PKG_LICENSE:=GPL-2.0
27 PKG_LICENSE_FILES:=COPYING
28
29 PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
30
31 PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES
32
33 PKG_BUILD_PARALLEL:=1
34 HOST_BUILD_PARALLEL:=1
35 PKG_INSTALL:=1
36
37 include $(INCLUDE_DIR)/package.mk
38 include $(INCLUDE_DIR)/host-build.mk
39
40 define Package/opkg/Default
41   SECTION:=base
42   CATEGORY:=Base system
43   TITLE:=opkg package manager
44   DEPENDS:=+uclient-fetch
45   URL:=http://wiki.openmoko.org/wiki/Opkg
46 endef
47
48 define Package/opkg/Default/description
49   Lightweight package management system
50   opkg is the opkg Package Management System, for handling
51   installation and removal of packages on a system. It can
52   recursively follow dependencies and download all packages
53   necessary to install a particular package.
54
55   opkg knows how to install both .ipk and .deb packages.
56 endef
57
58 define Package/opkg
59   $(call Package/opkg/Default)
60   VARIANT:=unsigned
61 endef
62
63 define Package/opkg/description
64   $(call Package/opkg/Default/description)
65 endef
66
67 define Package/opkg/conffiles
68 /etc/opkg.conf
69 /etc/opkg/keys/
70 /etc/opkg/customfeeds.conf
71 endef
72
73
74 define Package/opkg-smime
75   $(call Package/opkg/Default)
76   TITLE+= (with S/MIME signature support)
77   DEPENDS+=+PACKAGE_opkg-smime:libopenssl
78   VARIANT:=smime
79 endef
80
81 define Package/opkg-smime/description
82   $(call Package/opkg/Default/description)
83
84   This package allows the Package index to be verified with S/MIME.
85 endef
86
87 Package/opkg-smime/conffiles = $(Package/opkg/conffiles)
88
89 TARGET_CFLAGS += -ffunction-sections -fdata-sections
90 EXTRA_CFLAGS += $(TARGET_CPPFLAGS)
91
92 CONFIGURE_ARGS += \
93         --disable-curl \
94         --disable-gpg \
95         --enable-sha256 \
96         --with-opkgetcdir=/etc \
97         --with-opkglockfile=/var/lock/opkg.lock
98
99 ifeq ($(BUILD_VARIANT),smime)
100         CONFIGURE_ARGS += --enable-openssl --disable-usign
101 else
102   ifndef CONFIG_SIGNED_PACKAGES
103     CONFIGURE_ARGS += --disable-usign
104   endif
105 endif
106
107 MAKE_FLAGS = \
108                 CC="$(TARGET_CC)" \
109                 DESTDIR="$(PKG_INSTALL_DIR)" \
110                 HOST_CPU="$(PKGARCH)" \
111                 LDFLAGS="-Wl,--gc-sections" \
112
113 define Package/opkg/Default/install
114         $(INSTALL_DIR) $(1)/usr/lib/opkg
115         $(INSTALL_DIR) $(1)/bin
116         $(INSTALL_DIR) $(1)/etc/opkg
117         $(INSTALL_DIR) $(1)/etc/uci-defaults
118         $(INSTALL_DATA) ./files/customfeeds.conf $(1)/etc/opkg/customfeeds.conf
119         $(INSTALL_DATA) ./files/opkg$(2).conf $(1)/etc/opkg.conf
120         $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf)
121         $(VERSION_SED) $(1)/etc/opkg/distfeeds.conf
122         $(INSTALL_BIN) ./files/20_migrate-feeds $(1)/etc/uci-defaults/
123         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
124 endef
125
126 define Package/opkg/install
127         $(call Package/opkg/Default/install,$(1),)
128   ifneq ($(CONFIG_SIGNED_PACKAGES),)
129         echo "option check_signature 1" >> $(1)/etc/opkg.conf
130   endif
131         mkdir $(1)/usr/sbin
132         $(INSTALL_BIN) ./files/opkg-key $(1)/usr/sbin/
133 endef
134
135 define Package/opkg-smime/install
136         $(call Package/opkg/Default/install,$(1),-smime)
137         $(INSTALL_DIR) $(1)/etc/ssl/certs
138         $(if $(CONFIG_OPKGSMIME_CERT),$(INSTALL_DATA) $(call qstrip,$(CONFIG_OPKGSMIME_CERT)) $(1)/etc/ssl/certs/opkg.pem,)
139 endef
140
141 define Build/InstallDev
142         mkdir -p $(1)/usr/include
143         $(CP) $(PKG_INSTALL_DIR)/usr/include/libopkg $(1)/usr/include/
144 endef
145
146
147 HOST_CONFIGURE_ARGS+= \
148         --disable-curl \
149         --disable-gpg \
150         --enable-sha256 \
151         --with-opkgetcdir=/etc \
152         --with-opkglockfile=/tmp/opkg.lock
153
154 define Host/Compile
155         +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) CC="$(HOSTCC)" all
156 endef
157
158 define Host/Install
159         $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg
160 endef
161
162 $(eval $(call BuildPackage,opkg))
163 $(eval $(call BuildPackage,opkg-smime))
164 $(eval $(call HostBuild))