build: allow packages to declare ABI versions to detect necessary package rebuilds
[openwrt/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 PKG_DEFAULT_DEPENDS = +libc +USE_EGLIBC:librt +USE_EGLIBC:libpthread
9
10 ifneq ($(PKG_NAME),toolchain)
11 PKG_FIXUP_DEPENDS = $(if $(filter kmod-%,$(1)),$(2),$(PKG_DEFAULT_DEPENDS) $(filter-out $(PKG_DEFAULT_DEPENDS),$(2)))
12 else
13 PKG_FIXUP_DEPENDS = $(2)
14 endif
15
16 define Package/Default
17 CONFIGFILE:=
18 SECTION:=opt
19 CATEGORY:=Extra packages
20 DEPENDS:=
21 MDEPENDS:=
22 PROVIDES:=
23 EXTRA_DEPENDS:=
24 MAINTAINER:=$(PKG_MAINTAINER)
25 SOURCE:=$(patsubst $(TOPDIR)/%,%,$(CURDIR))
26 ifneq ($(PKG_VERSION),)
27 ifneq ($(PKG_RELEASE),)
28 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
29 else
30 VERSION:=$(PKG_VERSION)
31 endif
32 else
33 VERSION:=$(PKG_RELEASE)
34 endif
35 ABI_VERSION:=
36 ifneq ($(PKG_FLAGS),)
37 PKGFLAGS:=$(PKG_FLAGS)
38 else
39 PKGFLAGS:=
40 endif
41 ifneq ($(ARCH_PACKAGES),)
42 PKGARCH:=$(ARCH_PACKAGES)
43 else
44 PKGARCH:=$(BOARD)
45 endif
46 DEFAULT:=
47 MENU:=
48 SUBMENU:=
49 SUBMENUDEP:=
50 TITLE:=
51 KCONFIG:=
52 BUILDONLY:=
53 HIDDEN:=
54 URL:=
55 VARIANT:=
56 endef
57
58 Build/Patch:=$(Build/Patch/Default)
59 ifneq ($(strip $(PKG_UNPACK)),)
60 define Build/Prepare/Default
61 $(PKG_UNPACK)
62 $(Build/Patch)
63 endef
64 endif
65
66 EXTRA_CXXFLAGS = $(EXTRA_CFLAGS)
67
68 CONFIGURE_PREFIX:=/usr
69 CONFIGURE_ARGS = \
70 --target=$(GNU_TARGET_NAME) \
71 --host=$(GNU_TARGET_NAME) \
72 --build=$(GNU_HOST_NAME) \
73 --program-prefix="" \
74 --program-suffix="" \
75 --prefix=$(CONFIGURE_PREFIX) \
76 --exec-prefix=$(CONFIGURE_PREFIX) \
77 --bindir=$(CONFIGURE_PREFIX)/bin \
78 --sbindir=$(CONFIGURE_PREFIX)/sbin \
79 --libexecdir=$(CONFIGURE_PREFIX)/lib \
80 --sysconfdir=/etc \
81 --datadir=$(CONFIGURE_PREFIX)/share \
82 --localstatedir=/var \
83 --mandir=$(CONFIGURE_PREFIX)/man \
84 --infodir=$(CONFIGURE_PREFIX)/info \
85 $(DISABLE_NLS) \
86 $(DISABLE_LARGEFILE) \
87 $(DISABLE_IPV6)
88
89 CONFIGURE_VARS = \
90 $(TARGET_CONFIGURE_OPTS) \
91 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
92 CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CFLAGS)" \
93 CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
94 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
95
96 CONFIGURE_PATH = .
97 CONFIGURE_CMD = ./configure
98
99 replace_script=$(FIND) $(1) -name $(2) | $(XARGS) chmod u+w; $(FIND) $(1) -name $(2) | $(XARGS) -n1 cp $(SCRIPT_DIR)/$(2);
100
101 define Build/Configure/Default
102 (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \
103 if [ -x $(CONFIGURE_CMD) ]; then \
104 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.guess) \
105 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.sub) \
106 $(CONFIGURE_VARS) \
107 $(2) \
108 $(CONFIGURE_CMD) \
109 $(CONFIGURE_ARGS) \
110 $(1); \
111 fi; \
112 )
113 endef
114
115 MAKE_VARS = \
116 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
117 CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
118 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
119
120 MAKE_FLAGS = \
121 $(TARGET_CONFIGURE_OPTS) \
122 CROSS="$(TARGET_CROSS)" \
123 ARCH="$(ARCH)"
124
125 MAKE_INSTALL_FLAGS = \
126 $(MAKE_FLAGS) \
127 DESTDIR="$(PKG_INSTALL_DIR)"
128
129 MAKE_PATH = .
130
131 define Build/Compile/Default
132 +$(MAKE_VARS) \
133 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
134 $(MAKE_FLAGS) \
135 $(1);
136 endef
137
138 define Build/Install/Default
139 $(MAKE_VARS) \
140 $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
141 $(MAKE_INSTALL_FLAGS) \
142 $(if $(1), $(1), install);
143 endef
144
145 define Build/Dist/Default
146 $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" dist)
147 endef
148
149 define Build/DistCheck/Default
150 $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" distcheck)
151 endef