add default Build/Install template, which is activated by setting PKG_INSTALL=1
[15.05/openwrt.git] / include / package-defaults.mk
1
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 define Package/Default
9   CONFIGFILE:=
10   SECTION:=opt
11   CATEGORY:=Extra packages
12   DEPENDS:=
13   PROVIDES:=
14   EXTRA_DEPENDS:=
15   MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
16   SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
17   ifneq ($(PKG_VERSION),)
18     ifneq ($(PKG_RELEASE),)
19       VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
20     else
21       VERSION:=$(PKG_VERSION)
22     endif
23   else
24     VERSION:=$(PKG_RELEASE)
25   endif
26   PKGARCH:=$(ARCH)
27   PRIORITY:=optional
28   DEFAULT:=
29   MENU:=
30   SUBMENU:=
31   SUBMENUDEP:=
32   TITLE:=
33   KCONFIG:=
34 endef
35
36 Build/Patch:=$(Build/Patch/Default)
37 ifneq ($(strip $(PKG_UNPACK)),)
38   define Build/Prepare/Default
39         $(PKG_UNPACK)
40         $(Build/Patch)
41         $(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used)
42   endef
43 endif
44
45 export PKG_CONFIG_PATH=$(STAGING_DIR)/usr/lib/pkgconfig:$(STAGING_DIR_HOST)/usr/lib/pkgconfig
46 export PKG_CONFIG_LIBDIR=$(STAGING_DIR)/usr/lib/pkgconfig
47
48 CONFIGURE_PREFIX:=/usr
49 CONFIGURE_ARGS = \
50                 --target=$(GNU_TARGET_NAME) \
51                 --host=$(GNU_TARGET_NAME) \
52                 --build=$(GNU_HOST_NAME) \
53                 --program-prefix="" \
54                 --program-suffix="" \
55                 --prefix=$(CONFIGURE_PREFIX) \
56                 --exec-prefix=$(CONFIGURE_PREFIX) \
57                 --bindir=$(CONFIGURE_PREFIX)/bin \
58                 --sbindir=$(CONFIGURE_PREFIX)/sbin \
59                 --libexecdir=$(CONFIGURE_PREFIX)/lib \
60                 --sysconfdir=/etc \
61                 --datadir=$(CONFIGURE_PREFIX)/share \
62                 --localstatedir=/var \
63                 --mandir=$(CONFIGURE_PREFIX)/man \
64                 --infodir=$(CONFIGURE_PREFIX)/info \
65                 $(DISABLE_NLS)
66
67 CONFIGURE_VARS = \
68                 $(TARGET_CONFIGURE_OPTS) \
69                 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
70                 CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
71                 CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
72                 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
73                 PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" \
74                 PKG_CONFIG_LIBDIR="$(PKG_CONFIG_LIBDIR)"
75
76 CONFIGURE_PATH = .
77 CONFIGURE_CMD = ./configure
78
79 replace_script=$(FIND) $(1) -name $(2) | $(XARGS) -n1 cp $(SCRIPT_DIR)/$(2);
80
81 define Build/Configure/Default
82         (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \
83         if [ -x $(CONFIGURE_CMD) ]; then \
84                 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.guess) \
85                 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.sub) \
86                 $(CONFIGURE_VARS) \
87                 $(2) \
88                 $(CONFIGURE_CMD) \
89                 $(CONFIGURE_ARGS) \
90                 $(1); \
91         fi; \
92         )
93 endef
94
95 MAKE_VARS = \
96         CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
97         CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
98         LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
99
100 MAKE_FLAGS = \
101         $(TARGET_CONFIGURE_OPTS) \
102         CROSS="$(TARGET_CROSS)" \
103         ARCH="$(ARCH)"
104
105 MAKE_INSTALL_FLAGS = \
106         $(MAKE_FLAGS) \
107         DESTDIR="$(PKG_INSTALL_DIR)"
108
109 MAKE_PATH = .
110
111 define Build/Compile/Default
112         $(MAKE_VARS) \
113         $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
114                 $(MAKE_FLAGS) \
115                 $(1);
116 endef
117
118 define Build/Install/Default
119         $(MAKE_VARS) \
120         $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
121                 $(MAKE_INSTALL_FLAGS) \
122                 $(1) install;
123 endef