include: remove file before overwritting it with replace_script
[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 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   USERID:=
57 endef
58
59 Build/Patch:=$(Build/Patch/Default)
60 ifneq ($(strip $(PKG_UNPACK)),)
61   define Build/Prepare/Default
62         $(PKG_UNPACK)
63         $(Build/Patch)
64   endef
65 endif
66
67 EXTRA_CXXFLAGS = $(EXTRA_CFLAGS)
68 DISABLE_NLS:=--disable-nls
69
70 CONFIGURE_PREFIX:=/usr
71 CONFIGURE_ARGS = \
72                 --target=$(GNU_TARGET_NAME) \
73                 --host=$(GNU_TARGET_NAME) \
74                 --build=$(GNU_HOST_NAME) \
75                 --program-prefix="" \
76                 --program-suffix="" \
77                 --prefix=$(CONFIGURE_PREFIX) \
78                 --exec-prefix=$(CONFIGURE_PREFIX) \
79                 --bindir=$(CONFIGURE_PREFIX)/bin \
80                 --sbindir=$(CONFIGURE_PREFIX)/sbin \
81                 --libexecdir=$(CONFIGURE_PREFIX)/lib \
82                 --sysconfdir=/etc \
83                 --datadir=$(CONFIGURE_PREFIX)/share \
84                 --localstatedir=/var \
85                 --mandir=$(CONFIGURE_PREFIX)/man \
86                 --infodir=$(CONFIGURE_PREFIX)/info \
87                 $(DISABLE_NLS) \
88                 $(DISABLE_LARGEFILE) \
89                 $(DISABLE_IPV6)
90
91 CONFIGURE_VARS = \
92                 $(TARGET_CONFIGURE_OPTS) \
93                 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
94                 CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CFLAGS)" \
95                 CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
96                 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
97
98 CONFIGURE_PATH = .
99 CONFIGURE_CMD = ./configure
100
101 replace_script=$(FIND) $(1) -name $(2) | $(XARGS) chmod u+w; \
102                $(FIND) $(1) -name $(2) | $(XARGS) -n1 cp --remove-destination \
103                $(SCRIPT_DIR)/$(2);
104
105 define Build/Configure/Default
106         (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \
107         if [ -x $(CONFIGURE_CMD) ]; then \
108                 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.guess) \
109                 $(call replace_script,$(PKG_BUILD_DIR)/$(3),config.sub) \
110                 $(CONFIGURE_VARS) \
111                 $(2) \
112                 $(CONFIGURE_CMD) \
113                 $(CONFIGURE_ARGS) \
114                 $(1); \
115         fi; \
116         )
117 endef
118
119 MAKE_VARS = \
120         CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
121         CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
122         LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
123
124 MAKE_FLAGS = \
125         $(TARGET_CONFIGURE_OPTS) \
126         CROSS="$(TARGET_CROSS)" \
127         ARCH="$(ARCH)"
128
129 MAKE_INSTALL_FLAGS = \
130         $(MAKE_FLAGS) \
131         DESTDIR="$(PKG_INSTALL_DIR)"
132
133 MAKE_PATH = .
134
135 define Build/Compile/Default
136         +$(MAKE_VARS) \
137         $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
138                 $(MAKE_FLAGS) \
139                 $(1);
140 endef
141
142 define Build/Install/Default
143         $(MAKE_VARS) \
144         $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
145                 $(MAKE_INSTALL_FLAGS) \
146                 $(if $(1), $(1), install);
147 endef
148
149 define Build/Dist/Default
150         $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" dist)
151 endef
152
153 define Build/DistCheck/Default
154         $(call Build/Compile/Default, DESTDIR="$(PKG_BUILD_DIR)/tmp" CC="$(TARGET_CC)" distcheck)
155 endef