| 1 | ########################################################### |
|---|
| 2 | # |
|---|
| 3 | # coreutils |
|---|
| 4 | # |
|---|
| 5 | ########################################################### |
|---|
| 6 | |
|---|
| 7 | # You must replace "coreutils" and "COREUTILS" with the lower case name and |
|---|
| 8 | # upper case name of your new package. Some places below will say |
|---|
| 9 | # "Do not change this" - that does not include this global change, |
|---|
| 10 | # which must always be done to ensure we have unique names. |
|---|
| 11 | |
|---|
| 12 | # |
|---|
| 13 | # COREUTILS_VERSION, COREUTILS_SITE and COREUTILS_SOURCE define |
|---|
| 14 | # the upstream location of the source code for the package. |
|---|
| 15 | # COREUTILS_DIR is the directory which is created when the source |
|---|
| 16 | # archive is unpacked. |
|---|
| 17 | # COREUTILS_UNZIP is the command used to unzip the source. |
|---|
| 18 | # It is usually "zcat" (for .gz) or "bzcat" (for .bz2) |
|---|
| 19 | # |
|---|
| 20 | # You should change all these variables to suit your package. |
|---|
| 21 | # |
|---|
| 22 | COREUTILS_SITE=http://ftp.gnu.org/pub/gnu/coreutils |
|---|
| 23 | COREUTILS_VERSION=6.12 |
|---|
| 24 | COREUTILS_SOURCE=coreutils-$(COREUTILS_VERSION).tar.gz |
|---|
| 25 | COREUTILS_DIR=coreutils-$(COREUTILS_VERSION) |
|---|
| 26 | COREUTILS_UNZIP=zcat |
|---|
| 27 | COREUTILS_MAINTAINER=NSLU2 Linux <nslu2-linux@yahoogroups.com> |
|---|
| 28 | COREUTILS_DESCRIPTION=Bunch of heavyweight *nix core utilities |
|---|
| 29 | COREUTILS_SECTION=core |
|---|
| 30 | COREUTILS_PRIORITY=optional |
|---|
| 31 | ifeq (libiconv, $(filter libiconv, $(PACKAGES))) |
|---|
| 32 | COREUTILS_DEPENDS=libiconv |
|---|
| 33 | else |
|---|
| 34 | COREUTILS_DEPENDS= |
|---|
| 35 | endif |
|---|
| 36 | ifeq (enable, $(GETTEXT_NLS)) |
|---|
| 37 | COREUTILS_DEPENDS+=, gettext |
|---|
| 38 | endif |
|---|
| 39 | COREUTILS_CONFLICTS= |
|---|
| 40 | |
|---|
| 41 | # |
|---|
| 42 | # COREUTILS_IPK_VERSION should be incremented when the ipk changes. |
|---|
| 43 | # |
|---|
| 44 | COREUTILS_IPK_VERSION=2 |
|---|
| 45 | |
|---|
| 46 | # |
|---|
| 47 | # COREUTILS_PATCHES should list any patches, in the the order in |
|---|
| 48 | # which they should be applied to the source code. |
|---|
| 49 | # |
|---|
| 50 | COREUTILS_PATCHES=$(COREUTILS_SOURCE_DIR)/mountlist.patch |
|---|
| 51 | #COREUTILS_PATCHES+=$(COREUTILS_SOURCE_DIR)/coreutils-futimens.patch |
|---|
| 52 | |
|---|
| 53 | # Assume that all uclibc systems are the same |
|---|
| 54 | ifeq ($(LIBC_STYLE), uclibc) |
|---|
| 55 | ifeq ($(OPTWARE_TARGET), openwrt-brcm24) |
|---|
| 56 | COREUTILS_AC_CACHE=$(COREUTILS_SOURCE_DIR)/config-brcm24.cache |
|---|
| 57 | else |
|---|
| 58 | COREUTILS_AC_CACHE=$(COREUTILS_SOURCE_DIR)/config-uclibc.cache |
|---|
| 59 | endif |
|---|
| 60 | else |
|---|
| 61 | COREUTILS_AC_CACHE=$(COREUTILS_SOURCE_DIR)/config.cache |
|---|
| 62 | endif |
|---|
| 63 | # |
|---|
| 64 | # If the compilation of the package requires additional |
|---|
| 65 | # compilation or linking flags, then list them here. |
|---|
| 66 | # |
|---|
| 67 | ifeq ($(OPTWARE_TARGET),wl500g) |
|---|
| 68 | COREUTILS_CPPFLAGS=-DMB_CUR_MAX=1 |
|---|
| 69 | COREUTILS_LDFLAGS=-lm |
|---|
| 70 | else |
|---|
| 71 | COREUTILS_CPPFLAGS= |
|---|
| 72 | COREUTILS_LDFLAGS= |
|---|
| 73 | endif |
|---|
| 74 | ifeq (libiconv, $(filter libiconv, $(PACKAGES))) |
|---|
| 75 | COREUTILS_LDFLAGS+= -liconv |
|---|
| 76 | endif |
|---|
| 77 | COREUTILS_CONFIG_ENVS=gl_cv_func_fflush_stdin=yes |
|---|
| 78 | ifeq ($(OPTWARE_TARGET), dns323) |
|---|
| 79 | # binutils too old, ld does not recognize --as-needed |
|---|
| 80 | COREUTILS_CONFIG_ENVS += gl_cv_ignore_unused_libraries=none |
|---|
| 81 | endif |
|---|
| 82 | |
|---|
| 83 | # |
|---|
| 84 | # COREUTILS_BUILD_DIR is the directory in which the build is done. |
|---|
| 85 | # COREUTILS_SOURCE_DIR is the directory which holds all the |
|---|
| 86 | # patches and ipkg control files. |
|---|
| 87 | # COREUTILS_IPK_DIR is the directory in which the ipk is built. |
|---|
| 88 | # COREUTILS_IPK is the name of the resulting ipk files. |
|---|
| 89 | # |
|---|
| 90 | # You should not change any of these variables. |
|---|
| 91 | # |
|---|
| 92 | COREUTILS_BUILD_DIR=$(BUILD_DIR)/coreutils |
|---|
| 93 | COREUTILS_SOURCE_DIR=$(SOURCE_DIR)/coreutils |
|---|
| 94 | COREUTILS_IPK_DIR=$(BUILD_DIR)/coreutils-$(COREUTILS_VERSION)-ipk |
|---|
| 95 | COREUTILS_IPK=$(BUILD_DIR)/coreutils_$(COREUTILS_VERSION)-$(COREUTILS_IPK_VERSION)_$(TARGET_ARCH).ipk |
|---|
| 96 | |
|---|
| 97 | .PHONY: coreutils-source coreutils-unpack coreutils coreutils-stage coreutils-ipk coreutils-clean coreutils-dirclean coreutils-check |
|---|
| 98 | |
|---|
| 99 | # |
|---|
| 100 | # This is the dependency on the source code. If the source is missing, |
|---|
| 101 | # then it will be fetched from the site using wget. |
|---|
| 102 | # |
|---|
| 103 | $(DL_DIR)/$(COREUTILS_SOURCE): |
|---|
| 104 | $(WGET) -P $(@D) $(COREUTILS_SITE)/$(@F) || \ |
|---|
| 105 | $(WGET) -P $(@D) $(SOURCES_NLO_SITE)/$(@F) |
|---|
| 106 | |
|---|
| 107 | # |
|---|
| 108 | # The source code depends on it existing within the download directory. |
|---|
| 109 | # This target will be called by the top level Makefile to download the |
|---|
| 110 | # source code's archive (.tar.gz, .bz2, etc.) |
|---|
| 111 | # |
|---|
| 112 | coreutils-source: $(DL_DIR)/$(COREUTILS_SOURCE) $(COREUTILS_PATCHES) |
|---|
| 113 | |
|---|
| 114 | # |
|---|
| 115 | # This target unpacks the source code in the build directory. |
|---|
| 116 | # If the source archive is not .tar.gz or .tar.bz2, then you will need |
|---|
| 117 | # to change the commands here. Patches to the source code are also |
|---|
| 118 | # applied in this target as required. |
|---|
| 119 | # |
|---|
| 120 | # This target also configures the build within the build directory. |
|---|
| 121 | # Flags such as LDFLAGS and CPPFLAGS should be passed into configure |
|---|
| 122 | # and NOT $(MAKE) below. Passing it to configure causes configure to |
|---|
| 123 | # correctly BUILD the Makefile with the right paths, where passing it |
|---|
| 124 | # to Make causes it to override the default search paths of the compiler. |
|---|
| 125 | # |
|---|
| 126 | # If the compilation of the package requires other packages to be staged |
|---|
| 127 | # first, then do that first (e.g. "$(MAKE) <bar>-stage <baz>-stage"). |
|---|
| 128 | # |
|---|
| 129 | $(COREUTILS_BUILD_DIR)/.configured: $(DL_DIR)/$(COREUTILS_SOURCE) $(COREUTILS_PATCHES) $(COREUTILS_AC_CACHE) make/coreutils.mk |
|---|
| 130 | ifeq (enable, $(GETTEXT_NLS)) |
|---|
| 131 | $(MAKE) gettext-stage |
|---|
| 132 | endif |
|---|
| 133 | ifeq (libiconv, $(filter libiconv, $(PACKAGES))) |
|---|
| 134 | $(MAKE) libiconv-stage |
|---|
| 135 | endif |
|---|
| 136 | rm -rf $(BUILD_DIR)/$(COREUTILS_DIR) $(@D) |
|---|
| 137 | $(COREUTILS_UNZIP) $(DL_DIR)/$(COREUTILS_SOURCE) | tar -C $(BUILD_DIR) -xvf - |
|---|
| 138 | cat $(COREUTILS_PATCHES) | patch -Z -d $(BUILD_DIR)/$(COREUTILS_DIR) -p1 |
|---|
| 139 | mv $(BUILD_DIR)/$(COREUTILS_DIR) $(@D) |
|---|
| 140 | cp $(COREUTILS_AC_CACHE) $(@D)/config.cache |
|---|
| 141 | sed -i -e '/binPROGRAMS_INSTALL=\.\/ginstall/s|./ginstall|install|' $(@D)/src/Makefile.in |
|---|
| 142 | ifeq ($(OPTWARE_TARGET), ts101) |
|---|
| 143 | sed -i -e "/ac_cv_func_clock_settime=/s|'yes'|'no'|" $(@D)/config.cache |
|---|
| 144 | endif |
|---|
| 145 | (cd $(@D); \ |
|---|
| 146 | $(TARGET_CONFIGURE_OPTS) \ |
|---|
| 147 | CPPFLAGS="$(STAGING_CPPFLAGS) $(COREUTILS_CPPFLAGS)" \ |
|---|
| 148 | LDFLAGS="$(STAGING_LDFLAGS) $(COREUTILS_LDFLAGS)" \ |
|---|
| 149 | $(COREUTILS_CONFIG_ENVS) \ |
|---|
| 150 | ./configure \ |
|---|
| 151 | --build=$(GNU_HOST_NAME) \ |
|---|
| 152 | --host=$(GNU_TARGET_NAME) \ |
|---|
| 153 | --target=$(GNU_TARGET_NAME) \ |
|---|
| 154 | --prefix=/opt \ |
|---|
| 155 | --datarootdir=/opt \ |
|---|
| 156 | --cache-file=config.cache \ |
|---|
| 157 | ) |
|---|
| 158 | touch $@ |
|---|
| 159 | |
|---|
| 160 | coreutils-unpack: $(COREUTILS_BUILD_DIR)/.configured |
|---|
| 161 | |
|---|
| 162 | # |
|---|
| 163 | # This builds the actual binary. You should change the target to refer |
|---|
| 164 | # directly to the main binary which is built. |
|---|
| 165 | # |
|---|
| 166 | $(COREUTILS_BUILD_DIR)/.built: $(COREUTILS_BUILD_DIR)/.configured |
|---|
| 167 | rm -f $@ |
|---|
| 168 | $(MAKE) -C $(COREUTILS_BUILD_DIR) |
|---|
| 169 | touch $@ |
|---|
| 170 | |
|---|
| 171 | # |
|---|
| 172 | # You should change the dependency to refer directly to the main binary |
|---|
| 173 | # which is built. |
|---|
| 174 | # |
|---|
| 175 | coreutils: $(COREUTILS_BUILD_DIR)/.built |
|---|
| 176 | |
|---|
| 177 | # |
|---|
| 178 | # If you are building a library, then you need to stage it too. |
|---|
| 179 | # |
|---|
| 180 | #$(STAGING_DIR)/opt/lib/libcoreutils.so.$(COREUTILS_VERSION): $(COREUTILS_BUILD_DIR)/.built |
|---|
| 181 | # install -d $(STAGING_DIR)/opt/include |
|---|
| 182 | # install -m 644 $(COREUTILS_BUILD_DIR)/coreutils.h $(STAGING_DIR)/opt/include |
|---|
| 183 | # install -d $(STAGING_DIR)/opt/lib |
|---|
| 184 | # install -m 644 $(COREUTILS_BUILD_DIR)/libcoreutils.a $(STAGING_DIR)/opt/lib |
|---|
| 185 | # install -m 644 $(COREUTILS_BUILD_DIR)/libcoreutils.so.$(COREUTILS_VERSION) $(STAGING_DIR)/opt/lib |
|---|
| 186 | # cd $(STAGING_DIR)/opt/lib && ln -fs libcoreutils.so.$(COREUTILS_VERSION) libcoreutils.so.1 |
|---|
| 187 | # cd $(STAGING_DIR)/opt/lib && ln -fs libcoreutils.so.$(COREUTILS_VERSION) libcoreutils.so |
|---|
| 188 | # |
|---|
| 189 | #coreutils-stage: $(STAGING_DIR)/opt/lib/libcoreutils.so.$(COREUTILS_VERSION) |
|---|
| 190 | |
|---|
| 191 | # |
|---|
| 192 | # This rule creates a control file for ipkg. It is no longer |
|---|
| 193 | # necessary to create a seperate control file under sources/coreutils |
|---|
| 194 | # |
|---|
| 195 | $(COREUTILS_IPK_DIR)/CONTROL/control: |
|---|
| 196 | @install -d $(@D) |
|---|
| 197 | @rm -f $@ |
|---|
| 198 | @echo "Package: coreutils" >>$@ |
|---|
| 199 | @echo "Architecture: $(TARGET_ARCH)" >>$@ |
|---|
| 200 | @echo "Priority: $(COREUTILS_PRIORITY)" >>$@ |
|---|
| 201 | @echo "Section: $(COREUTILS_SECTION)" >>$@ |
|---|
| 202 | @echo "Version: $(COREUTILS_VERSION)-$(COREUTILS_IPK_VERSION)" >>$@ |
|---|
| 203 | @echo "Maintainer: $(COREUTILS_MAINTAINER)" >>$@ |
|---|
| 204 | @echo "Source: $(COREUTILS_SITE)/$(COREUTILS_SOURCE)" >>$@ |
|---|
| 205 | @echo "Description: $(COREUTILS_DESCRIPTION)" >>$@ |
|---|
| 206 | @echo "Depends: $(COREUTILS_DEPENDS)" >>$@ |
|---|
| 207 | @echo "Conflicts: $(COREUTILS_CONFLICTS)" >>$@ |
|---|
| 208 | |
|---|
| 209 | # |
|---|
| 210 | # This builds the IPK file. |
|---|
| 211 | # |
|---|
| 212 | # Binaries should be installed into $(COREUTILS_IPK_DIR)/opt/sbin or $(COREUTILS_IPK_DIR)/opt/bin |
|---|
| 213 | # (use the location in a well-known Linux distro as a guide for choosing sbin or bin). |
|---|
| 214 | # Libraries and include files should be installed into $(COREUTILS_IPK_DIR)/opt/{lib,include} |
|---|
| 215 | # Configuration files should be installed in $(COREUTILS_IPK_DIR)/opt/etc/coreutils/... |
|---|
| 216 | # Documentation files should be installed in $(COREUTILS_IPK_DIR)/opt/doc/coreutils/... |
|---|
| 217 | # Daemon startup scripts should be installed in $(COREUTILS_IPK_DIR)/opt/etc/init.d/S??coreutils |
|---|
| 218 | # |
|---|
| 219 | # You may need to patch your application to make it use these locations. |
|---|
| 220 | # |
|---|
| 221 | $(COREUTILS_IPK): $(COREUTILS_BUILD_DIR)/.built |
|---|
| 222 | rm -rf $(COREUTILS_IPK_DIR) $(BUILD_DIR)/coreutils_*_$(TARGET_ARCH).ipk |
|---|
| 223 | # Install binaries |
|---|
| 224 | install -d $(COREUTILS_IPK_DIR)/opt/bin |
|---|
| 225 | $(MAKE) -C $(COREUTILS_BUILD_DIR) DESTDIR=$(COREUTILS_IPK_DIR) install-exec |
|---|
| 226 | # copy su - can't install it as install only works for root |
|---|
| 227 | cp -p $(COREUTILS_BUILD_DIR)/src/su $(COREUTILS_IPK_DIR)/opt/bin/su |
|---|
| 228 | # Install makefiles |
|---|
| 229 | install -d $(COREUTILS_IPK_DIR)/opt/man/man1 |
|---|
| 230 | $(MAKE) -C $(COREUTILS_BUILD_DIR)/man DESTDIR=$(COREUTILS_IPK_DIR) install |
|---|
| 231 | $(STRIP_COMMAND) $(COREUTILS_IPK_DIR)/opt/bin/* |
|---|
| 232 | $(MAKE) $(COREUTILS_IPK_DIR)/CONTROL/control |
|---|
| 233 | echo "#!/bin/sh" > $(COREUTILS_IPK_DIR)/CONTROL/postinst |
|---|
| 234 | (echo "/bin/chown 0:0 /opt/bin/coreutils-su"; \ |
|---|
| 235 | echo "/bin/chmod 4755 /opt/bin/coreutils-su"; \ |
|---|
| 236 | ) >> $(COREUTILS_IPK_DIR)/CONTROL/postinst |
|---|
| 237 | echo "#!/bin/sh" > $(COREUTILS_IPK_DIR)/CONTROL/prerm |
|---|
| 238 | cd $(COREUTILS_IPK_DIR)/opt/bin; \ |
|---|
| 239 | for p in *; do \ |
|---|
| 240 | if test "$$p" = "["; then \ |
|---|
| 241 | q=coreutils-lbracket; \ |
|---|
| 242 | else \ |
|---|
| 243 | q=coreutils-$$p; \ |
|---|
| 244 | fi; \ |
|---|
| 245 | mv $$p $$q; \ |
|---|
| 246 | echo "update-alternatives --install '/opt/bin/$$p' '$$p' '$$q' 50" \ |
|---|
| 247 | >> $(COREUTILS_IPK_DIR)/CONTROL/postinst; \ |
|---|
| 248 | echo "update-alternatives --remove '$$p' '$$q'" \ |
|---|
| 249 | >> $(COREUTILS_IPK_DIR)/CONTROL/prerm; \ |
|---|
| 250 | done |
|---|
| 251 | if test -n "$(UPD-ALT_PREFIX)"; then \ |
|---|
| 252 | sed -i -e '/^[ ]*update-alternatives /s|update-alternatives|$(UPD-ALT_PREFIX)/bin/&|' \ |
|---|
| 253 | $(COREUTILS_IPK_DIR)/CONTROL/postinst $(COREUTILS_IPK_DIR)/CONTROL/prerm; \ |
|---|
| 254 | fi |
|---|
| 255 | ifeq ($(OPTWARE_WRITE_OUTSIDE_OPT_ALLOWED),true) |
|---|
| 256 | install -d $(COREUTILS_IPK_DIR)/opt/etc/init.d |
|---|
| 257 | install -m 755 $(COREUTILS_SOURCE_DIR)/rc.coreutils $(COREUTILS_IPK_DIR)/opt/etc/init.d/S05coreutils |
|---|
| 258 | install -d $(COREUTILS_IPK_DIR)/usr/bin |
|---|
| 259 | ln -s /opt/bin/env $(COREUTILS_IPK_DIR)/usr/bin/env |
|---|
| 260 | endif |
|---|
| 261 | cd $(BUILD_DIR); $(IPKG_BUILD) $(COREUTILS_IPK_DIR) |
|---|
| 262 | |
|---|
| 263 | $(COREUTILS_BUILD_DIR)/.ipk: $(COREUTILS_IPK) |
|---|
| 264 | touch $@ |
|---|
| 265 | |
|---|
| 266 | # |
|---|
| 267 | # This is called from the top level makefile to create the IPK file. |
|---|
| 268 | # |
|---|
| 269 | coreutils-ipk: $(COREUTILS_IPK) |
|---|
| 270 | |
|---|
| 271 | # |
|---|
| 272 | # This is called from the top level makefile to clean all of the built files. |
|---|
| 273 | # |
|---|
| 274 | coreutils-clean: |
|---|
| 275 | -$(MAKE) -C $(COREUTILS_BUILD_DIR) clean |
|---|
| 276 | |
|---|
| 277 | # |
|---|
| 278 | # This is called from the top level makefile to clean all dynamically created |
|---|
| 279 | # directories. |
|---|
| 280 | # |
|---|
| 281 | coreutils-dirclean: |
|---|
| 282 | rm -rf $(BUILD_DIR)/$(COREUTILS_DIR) $(COREUTILS_BUILD_DIR) $(COREUTILS_IPK_DIR) $(COREUTILS_IPK) |
|---|
| 283 | |
|---|
| 284 | # |
|---|
| 285 | # Some sanity check for the package. |
|---|
| 286 | # |
|---|
| 287 | coreutils-check: $(COREUTILS_IPK) |
|---|
| 288 | perl scripts/optware-check-package.pl --target=$(OPTWARE_TARGET) $(COREUTILS_IPK) |
|---|