build system: introduce a new feature called build variants.
[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)/%,%,$(CURDIR))
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   ifneq ($(CONFIG_TARGET_adm5120),y)
27     PKGARCH:=$(BOARD)
28   else
29     PKGARCH:=$(BOARD)_$(ARCH)
30   endif
31   PRIORITY:=optional
32   DEFAULT:=
33   MENU:=
34   SUBMENU:=
35   SUBMENUDEP:=
36   TITLE:=
37   KCONFIG:=
38   BUILDONLY:=
39   URL:=
40   VARIANT:=
41 endef
42
43 Build/Patch:=$(Build/Patch/Default)
44 ifneq ($(strip $(PKG_UNPACK)),)
45   define Build/Prepare/Default
46         $(PKG_UNPACK)
47         $(Build/Patch)
48   endef
49 endif
50
51 CONFIGURE_PREFIX:=/usr
52 CONFIGURE_ARGS = \
53                 --target=$(GNU_TARGET_NAME) \
54                 --host=$(GNU_TARGET_NAME) \
55                 --build=$(GNU_HOST_NAME) \
56                 --program-prefix="" \
57                 --program-suffix="" \
58                 --prefix=$(CONFIGURE_PREFIX) \
59                 --exec-prefix=$(CONFIGURE_PREFIX) \
60                 --bindir=$(CONFIGURE_PREFIX)/bin \
61                 --sbindir=$(CONFIGURE_PREFIX)/sbin \
62                 --libexecdir=$(CONFIGURE_PREFIX)/lib \
63                 --sysconfdir=/etc \
64                 --datadir=$(CONFIGURE_PREFIX)/share \
65                 --localstatedir=/var \
66                 --mandir=$(CONFIGURE_PREFIX)/man \
67                 --infodir=$(CONFIGURE_PREFIX)/info \
68                 $(DISABLE_NLS) \
69                 $(DISABLE_LARGEFILE) \
70                 $(DISABLE_IPV6)
71
72 CONFIGURE_VARS = \
73                 $(TARGET_CONFIGURE_OPTS) \
74                 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
75                 CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
76                 CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
77                 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
78
79 CONFIGURE_PATH = .
80 CONFIGURE_CMD = ./configure
81
82 replace_script=$(FIND) $(1) -name $(2) | $(XARGS) chmod u+w; $(FIND) $(1) -name $(2) | $(XARGS) -n1 cp $(SCRIPT_DIR)/$(2);
83
84 define Build/Configure/Default
85         (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \
86         if [ -x $(CONFIGURE_CMD) ]; then \
87                 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.guess) \
88                 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.sub) \
89                 $(CONFIGURE_VARS) \
90                 $(2) \
91                 $(CONFIGURE_CMD) \
92                 $(CONFIGURE_ARGS) \
93                 $(1); \
94         fi; \
95         )
96 endef
97
98 MAKE_VARS = \
99         CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
100         CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
101         LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
102
103 MAKE_FLAGS = \
104         $(TARGET_CONFIGURE_OPTS) \
105         CROSS="$(TARGET_CROSS)" \
106         ARCH="$(ARCH)"
107
108 MAKE_INSTALL_FLAGS = \
109         $(MAKE_FLAGS) \
110         DESTDIR="$(PKG_INSTALL_DIR)"
111
112 MAKE_PATH = .
113
114 define Build/Compile/Default
115         $(MAKE_VARS) \
116         $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
117                 $(MAKE_FLAGS) \
118                 $(1);
119 endef
120
121 define Build/Install/Default
122         $(MAKE_VARS) \
123         $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
124                 $(MAKE_INSTALL_FLAGS) \
125                 $(1) install;
126 endef
127
128 define Build/Dist/Default
129         $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" dist)
130 endef
131
132 define Build/DistCheck/Default
133         $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" distcheck)
134 endef