| 1 |
########################################################### |
|---|
| 2 |
# |
|---|
| 3 |
# apcupsd |
|---|
| 4 |
# |
|---|
| 5 |
########################################################### |
|---|
| 6 |
# |
|---|
| 7 |
# APCUPSD_VERSION, APCUPSD_SITE and APCUPSD_SOURCE define |
|---|
| 8 |
# the upstream location of the source code for the package. |
|---|
| 9 |
# APCUPSD_DIR is the directory which is created when the source |
|---|
| 10 |
# archive is unpacked. |
|---|
| 11 |
# APCUPSD_UNZIP is the command used to unzip the source. |
|---|
| 12 |
# It is usually "zcat" (for .gz) or "bzcat" (for .bz2) |
|---|
| 13 |
# |
|---|
| 14 |
# You should change all these variables to suit your package. |
|---|
| 15 |
# Please make sure that you add a description, and that you |
|---|
| 16 |
# list all your packages' dependencies, seperated by commas. |
|---|
| 17 |
# |
|---|
| 18 |
# If you list yourself as MAINTAINER, please give a valid email |
|---|
| 19 |
# address, and indicate your irc nick if it cannot be easily deduced |
|---|
| 20 |
# from your name or email address. If you leave MAINTAINER set to |
|---|
| 21 |
# "NSLU2 Linux" other developers will feel free to edit. |
|---|
| 22 |
# |
|---|
| 23 |
APCUPSD_SITE=http://$(SOURCEFORGE_MIRROR)/sourceforge/apcupsd |
|---|
| 24 |
APCUPSD_VERSION=3.14.8 |
|---|
| 25 |
APCUPSD_SOURCE=apcupsd-$(APCUPSD_VERSION).tar.gz |
|---|
| 26 |
APCUPSD_DIR=apcupsd-$(APCUPSD_VERSION) |
|---|
| 27 |
APCUPSD_UNZIP=zcat |
|---|
| 28 |
APCUPSD_MAINTAINER=NSLU2 Linux <nslu2-linux@yahoogroups.com> |
|---|
| 29 |
APCUPSD_DESCRIPTION=A daemon for controlling APC UPSes |
|---|
| 30 |
APCUPSD_SECTION=sysadmin |
|---|
| 31 |
APCUPSD_PRIORITY=optional |
|---|
| 32 |
APCUPSD_DEPENDS= |
|---|
| 33 |
APCUPSD_SUGGESTS= |
|---|
| 34 |
APCUPSD_CONFLICTS= |
|---|
| 35 |
|
|---|
| 36 |
# |
|---|
| 37 |
# APCUPSD_IPK_VERSION should be incremented when the ipk changes. |
|---|
| 38 |
# |
|---|
| 39 |
APCUPSD_IPK_VERSION=1 |
|---|
| 40 |
|
|---|
| 41 |
# |
|---|
| 42 |
# APCUPSD_CONFFILES should be a list of user-editable files |
|---|
| 43 |
APCUPSD_CONFFILES=/opt/etc/apcupsd/apcupsd.conf |
|---|
| 44 |
#/opt/etc/init.d/SXXapcupsd |
|---|
| 45 |
|
|---|
| 46 |
# |
|---|
| 47 |
# APCUPSD_PATCHES should list any patches, in the the order in |
|---|
| 48 |
# which they should be applied to the source code. |
|---|
| 49 |
# |
|---|
| 50 |
#APCUPSD_PATCHES=$(APCUPSD_SOURCE_DIR)/configure.patch |
|---|
| 51 |
|
|---|
| 52 |
# |
|---|
| 53 |
# If the compilation of the package requires additional |
|---|
| 54 |
# compilation or linking flags, then list them here. |
|---|
| 55 |
# |
|---|
| 56 |
APCUPSD_CPPFLAGS= |
|---|
| 57 |
APCUPSD_LDFLAGS= |
|---|
| 58 |
|
|---|
| 59 |
# |
|---|
| 60 |
# APCUPSD_BUILD_DIR is the directory in which the build is done. |
|---|
| 61 |
# APCUPSD_SOURCE_DIR is the directory which holds all the |
|---|
| 62 |
# patches and ipkg control files. |
|---|
| 63 |
# APCUPSD_IPK_DIR is the directory in which the ipk is built. |
|---|
| 64 |
# APCUPSD_IPK is the name of the resulting ipk files. |
|---|
| 65 |
# |
|---|
| 66 |
# You should not change any of these variables. |
|---|
| 67 |
# |
|---|
| 68 |
APCUPSD_BUILD_DIR=$(BUILD_DIR)/apcupsd |
|---|
| 69 |
APCUPSD_SOURCE_DIR=$(SOURCE_DIR)/apcupsd |
|---|
| 70 |
|
|---|
| 71 |
APCUPSD_IPK_DIR=$(BUILD_DIR)/apcupsd-$(APCUPSD_VERSION)-ipk |
|---|
| 72 |
APCUPSD_IPK=$(BUILD_DIR)/apcupsd_$(APCUPSD_VERSION)-$(APCUPSD_IPK_VERSION)_$(TARGET_ARCH).ipk |
|---|
| 73 |
|
|---|
| 74 |
APCUPSD-CGI_IPK_DIR=$(BUILD_DIR)/apcupsd-cgi-$(APCUPSD_VERSION)-ipk |
|---|
| 75 |
APCUPSD-CGI_IPK=$(BUILD_DIR)/apcupsd-cgi_$(APCUPSD_VERSION)-$(APCUPSD_IPK_VERSION)_$(TARGET_ARCH).ipk |
|---|
| 76 |
|
|---|
| 77 |
.PHONY: apcupsd-source apcupsd-unpack apcupsd apcupsd-stage apcupsd-ipk apcupsd-clean apcupsd-dirclean apcupsd-check |
|---|
| 78 |
|
|---|
| 79 |
# |
|---|
| 80 |
# This is the dependency on the source code. If the source is missing, |
|---|
| 81 |
# then it will be fetched from the site using wget. |
|---|
| 82 |
# |
|---|
| 83 |
$(DL_DIR)/$(APCUPSD_SOURCE): |
|---|
| 84 |
$(WGET) -P $(@D) $(APCUPSD_SITE)/$(@F) || \ |
|---|
| 85 |
$(WGET) -P $(@D) $(SOURCES_NLO_SITE)/$(@F) |
|---|
| 86 |
|
|---|
| 87 |
# |
|---|
| 88 |
# The source code depends on it existing within the download directory. |
|---|
| 89 |
# This target will be called by the top level Makefile to download the |
|---|
| 90 |
# source code's archive (.tar.gz, .bz2, etc.) |
|---|
| 91 |
# |
|---|
| 92 |
apcupsd-source: $(DL_DIR)/$(APCUPSD_SOURCE) $(APCUPSD_PATCHES) |
|---|
| 93 |
|
|---|
| 94 |
# |
|---|
| 95 |
# This target unpacks the source code in the build directory. |
|---|
| 96 |
# If the source archive is not .tar.gz or .tar.bz2, then you will need |
|---|
| 97 |
# to change the commands here. Patches to the source code are also |
|---|
| 98 |
# applied in this target as required. |
|---|
| 99 |
# |
|---|
| 100 |
# This target also configures the build within the build directory. |
|---|
| 101 |
# Flags such as LDFLAGS and CPPFLAGS should be passed into configure |
|---|
| 102 |
# and NOT $(MAKE) below. Passing it to configure causes configure to |
|---|
| 103 |
# correctly BUILD the Makefile with the right paths, where passing it |
|---|
| 104 |
# to Make causes it to override the default search paths of the compiler. |
|---|
| 105 |
# |
|---|
| 106 |
# If the compilation of the package requires other packages to be staged |
|---|
| 107 |
# first, then do that first (e.g. "$(MAKE) <bar>-stage <baz>-stage"). |
|---|
| 108 |
# |
|---|
| 109 |
# If the package uses GNU libtool, you should invoke $(PATCH_LIBTOOL) as |
|---|
| 110 |
# shown below to make various patches to it. |
|---|
| 111 |
# |
|---|
| 112 |
$(APCUPSD_BUILD_DIR)/.configured: $(DL_DIR)/$(APCUPSD_SOURCE) $(APCUPSD_PATCHES) make/apcupsd.mk |
|---|
| 113 |
$(MAKE) libgd-stage |
|---|
| 114 |
# $(MAKE) tcpwrappers-stage |
|---|
| 115 |
rm -rf $(BUILD_DIR)/$(APCUPSD_DIR) $(@D) |
|---|
| 116 |
$(APCUPSD_UNZIP) $(DL_DIR)/$(APCUPSD_SOURCE) | tar -C $(BUILD_DIR) -xvf - |
|---|
| 117 |
if test -n "$(APCUPSD_PATCHES)" ; \ |
|---|
| 118 |
then cat $(APCUPSD_PATCHES) | \ |
|---|
| 119 |
patch -d $(BUILD_DIR)/$(APCUPSD_DIR) -p0 ; \ |
|---|
| 120 |
fi |
|---|
| 121 |
if test "$(BUILD_DIR)/$(APCUPSD_DIR)" != "$(@D)" ; \ |
|---|
| 122 |
then mv $(BUILD_DIR)/$(APCUPSD_DIR) $(@D) ; \ |
|---|
| 123 |
fi |
|---|
| 124 |
cp -f $(SOURCE_DIR)/common/config.* $(@D)/autoconf/ |
|---|
| 125 |
sed -i -e 's|prefix=NONE|prefix=/opt|; s|/usr/share/hal/|/opt/share/hal/|' $(@D)/configure |
|---|
| 126 |
sed -i -e 's/strchr/&2/' $(@D)/include/astring.h |
|---|
| 127 |
sed -i -e 's/astring::strchr/&2/' $(@D)/src/lib/astring.cpp |
|---|
| 128 |
(cd $(@D); \ |
|---|
| 129 |
$(TARGET_CONFIGURE_OPTS) \ |
|---|
| 130 |
LD=$(TARGET_CC) \ |
|---|
| 131 |
CPPFLAGS="$(STAGING_CPPFLAGS) $(APCUPSD_CPPFLAGS)" \ |
|---|
| 132 |
LDFLAGS="$(STAGING_LDFLAGS) $(APCUPSD_LDFLAGS)" \ |
|---|
| 133 |
ac_cv_func_setpgrp_void=yes \ |
|---|
| 134 |
ac_cv_lib_gd_gdImagePng=yes \ |
|---|
| 135 |
ac_cv_lib_gd_gdImageGif=yes \ |
|---|
| 136 |
./configure \ |
|---|
| 137 |
--build=$(GNU_HOST_NAME) \ |
|---|
| 138 |
--host=$(GNU_TARGET_NAME) \ |
|---|
| 139 |
--target=$(GNU_TARGET_NAME) \ |
|---|
| 140 |
--with-distname=unknown \ |
|---|
| 141 |
--prefix=/opt \ |
|---|
| 142 |
--sbindir=/opt/sbin \ |
|---|
| 143 |
--sysconfdir=/opt/etc/apcupsd \ |
|---|
| 144 |
--mandir=/opt/share/man \ |
|---|
| 145 |
--with-nologin=/opt/etc/apcupsd \ |
|---|
| 146 |
--with-pid-dir=/opt/var/run \ |
|---|
| 147 |
--with-log-dir=/opt/var/log \ |
|---|
| 148 |
--with-lock-dir=/opt/var/lock \ |
|---|
| 149 |
--enable-usb \ |
|---|
| 150 |
--enable-cgi \ |
|---|
| 151 |
--with-cgi-bin=/opt/share/www/cgi-bin \ |
|---|
| 152 |
--without-libwrap \ |
|---|
| 153 |
--without-x \ |
|---|
| 154 |
--disable-nls \ |
|---|
| 155 |
--disable-static \ |
|---|
| 156 |
) |
|---|
| 157 |
# --with-libwrap=$(STAGING_PREFIX) \ |
|---|
| 158 |
; |
|---|
| 159 |
touch $@ |
|---|
| 160 |
|
|---|
| 161 |
apcupsd-unpack: $(APCUPSD_BUILD_DIR)/.configured |
|---|
| 162 |
|
|---|
| 163 |
# |
|---|
| 164 |
# This builds the actual binary. |
|---|
| 165 |
# |
|---|
| 166 |
$(APCUPSD_BUILD_DIR)/.built: $(APCUPSD_BUILD_DIR)/.configured |
|---|
| 167 |
rm -f $@ |
|---|
| 168 |
$(MAKE) -C $(@D) |
|---|
| 169 |
touch $@ |
|---|
| 170 |
|
|---|
| 171 |
# |
|---|
| 172 |
# This is the build convenience target. |
|---|
| 173 |
# |
|---|
| 174 |
apcupsd: $(APCUPSD_BUILD_DIR)/.built |
|---|
| 175 |
|
|---|
| 176 |
# |
|---|
| 177 |
# If you are building a library, then you need to stage it too. |
|---|
| 178 |
# |
|---|
| 179 |
$(APCUPSD_BUILD_DIR)/.staged: $(APCUPSD_BUILD_DIR)/.built |
|---|
| 180 |
rm -f $@ |
|---|
| 181 |
$(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install |
|---|
| 182 |
touch $@ |
|---|
| 183 |
|
|---|
| 184 |
apcupsd-stage: $(APCUPSD_BUILD_DIR)/.staged |
|---|
| 185 |
|
|---|
| 186 |
# |
|---|
| 187 |
# This rule creates a control file for ipkg. It is no longer |
|---|
| 188 |
# necessary to create a seperate control file under sources/apcupsd |
|---|
| 189 |
# |
|---|
| 190 |
$(APCUPSD_IPK_DIR)/CONTROL/control: |
|---|
| 191 |
@install -d $(@D) |
|---|
| 192 |
@rm -f $@ |
|---|
| 193 |
@echo "Package: apcupsd" >>$@ |
|---|
| 194 |
@echo "Architecture: $(TARGET_ARCH)" >>$@ |
|---|
| 195 |
@echo "Priority: $(APCUPSD_PRIORITY)" >>$@ |
|---|
| 196 |
@echo "Section: $(APCUPSD_SECTION)" >>$@ |
|---|
| 197 |
@echo "Version: $(APCUPSD_VERSION)-$(APCUPSD_IPK_VERSION)" >>$@ |
|---|
| 198 |
@echo "Maintainer: $(APCUPSD_MAINTAINER)" >>$@ |
|---|
| 199 |
@echo "Source: $(APCUPSD_SITE)/$(APCUPSD_SOURCE)" >>$@ |
|---|
| 200 |
@echo "Description: $(APCUPSD_DESCRIPTION)" >>$@ |
|---|
| 201 |
@echo "Depends: $(APCUPSD_DEPENDS)" >>$@ |
|---|
| 202 |
@echo "Suggests: $(APCUPSD_SUGGESTS)" >>$@ |
|---|
| 203 |
@echo "Conflicts: $(APCUPSD_CONFLICTS)" >>$@ |
|---|
| 204 |
|
|---|
| 205 |
$(APCUPSD-CGI_IPK_DIR)/CONTROL/control: |
|---|
| 206 |
@install -d $(@D) |
|---|
| 207 |
@rm -f $@ |
|---|
| 208 |
@echo "Package: apcupsd-cgi" >>$@ |
|---|
| 209 |
@echo "Architecture: $(TARGET_ARCH)" >>$@ |
|---|
| 210 |
@echo "Priority: $(APCUPSD_PRIORITY)" >>$@ |
|---|
| 211 |
@echo "Section: $(APCUPSD_SECTION)" >>$@ |
|---|
| 212 |
@echo "Version: $(APCUPSD_VERSION)-$(APCUPSD_IPK_VERSION)" >>$@ |
|---|
| 213 |
@echo "Maintainer: $(APCUPSD_MAINTAINER)" >>$@ |
|---|
| 214 |
@echo "Source: $(APCUPSD_SITE)/$(APCUPSD_SOURCE)" >>$@ |
|---|
| 215 |
@echo "Description: $(APCUPSD_DESCRIPTION), web interface" >>$@ |
|---|
| 216 |
@echo "Depends: apcupsd, libgd" >>$@ |
|---|
| 217 |
@echo "Suggests: $(APCUPSD_SUGGESTS)" >>$@ |
|---|
| 218 |
@echo "Conflicts: $(APCUPSD_CONFLICTS)" >>$@ |
|---|
| 219 |
|
|---|
| 220 |
# |
|---|
| 221 |
# This builds the IPK file. |
|---|
| 222 |
# |
|---|
| 223 |
# Binaries should be installed into $(APCUPSD_IPK_DIR)/opt/sbin or $(APCUPSD_IPK_DIR)/opt/bin |
|---|
| 224 |
# (use the location in a well-known Linux distro as a guide for choosing sbin or bin). |
|---|
| 225 |
# Libraries and include files should be installed into $(APCUPSD_IPK_DIR)/opt/{lib,include} |
|---|
| 226 |
# Configuration files should be installed in $(APCUPSD_IPK_DIR)/opt/etc/apcupsd/... |
|---|
| 227 |
# Documentation files should be installed in $(APCUPSD_IPK_DIR)/opt/doc/apcupsd/... |
|---|
| 228 |
# Daemon startup scripts should be installed in $(APCUPSD_IPK_DIR)/opt/etc/init.d/S??apcupsd |
|---|
| 229 |
# |
|---|
| 230 |
# You may need to patch your application to make it use these locations. |
|---|
| 231 |
# |
|---|
| 232 |
$(APCUPSD_IPK) $(APCUPSD-CGI_IPK): $(APCUPSD_BUILD_DIR)/.built |
|---|
| 233 |
rm -rf $(APCUPSD_IPK_DIR) $(BUILD_DIR)/apcupsd_*_$(TARGET_ARCH).ipk |
|---|
| 234 |
rm -rf $(APCUPSD-CGI_IPK_DIR) $(BUILD_DIR)/apcupsd-cgi_*_$(TARGET_ARCH).ipk |
|---|
| 235 |
$(MAKE) -C $(APCUPSD_BUILD_DIR) DESTDIR=$(APCUPSD_IPK_DIR) install |
|---|
| 236 |
$(STRIP_COMMAND) $(APCUPSD_IPK_DIR)/opt/sbin/* $(APCUPSD_IPK_DIR)/opt/share/www/cgi-bin/* |
|---|
| 237 |
install -d $(APCUPSD-CGI_IPK_DIR)/opt/share $(APCUPSD-CGI_IPK_DIR)/opt/etc/apcupsd |
|---|
| 238 |
mv $(APCUPSD_IPK_DIR)/opt/share/www $(APCUPSD-CGI_IPK_DIR)/opt/share/ |
|---|
| 239 |
mv $(APCUPSD_IPK_DIR)/opt/etc/apcupsd/*.css $(APCUPSD-CGI_IPK_DIR)/opt/etc/apcupsd/ |
|---|
| 240 |
$(MAKE) $(APCUPSD_IPK_DIR)/CONTROL/control |
|---|
| 241 |
echo $(APCUPSD_CONFFILES) | sed -e 's/ /\n/g' > $(APCUPSD_IPK_DIR)/CONTROL/conffiles |
|---|
| 242 |
cd $(BUILD_DIR); $(IPKG_BUILD) $(APCUPSD_IPK_DIR) |
|---|
| 243 |
$(MAKE) $(APCUPSD-CGI_IPK_DIR)/CONTROL/control |
|---|
| 244 |
cd $(BUILD_DIR); $(IPKG_BUILD) $(APCUPSD-CGI_IPK_DIR) |
|---|
| 245 |
|
|---|
| 246 |
# |
|---|
| 247 |
# This is called from the top level makefile to create the IPK file. |
|---|
| 248 |
# |
|---|
| 249 |
apcupsd-ipk: $(APCUPSD_IPK) $(APCUPSD-CGI_IPK) |
|---|
| 250 |
|
|---|
| 251 |
# |
|---|
| 252 |
# This is called from the top level makefile to clean all of the built files. |
|---|
| 253 |
# |
|---|
| 254 |
apcupsd-clean: |
|---|
| 255 |
rm -f $(APCUPSD_BUILD_DIR)/.built |
|---|
| 256 |
-$(MAKE) -C $(APCUPSD_BUILD_DIR) clean |
|---|
| 257 |
|
|---|
| 258 |
# |
|---|
| 259 |
# This is called from the top level makefile to clean all dynamically created |
|---|
| 260 |
# directories. |
|---|
| 261 |
# |
|---|
| 262 |
apcupsd-dirclean: |
|---|
| 263 |
rm -rf $(BUILD_DIR)/$(APCUPSD_DIR) $(APCUPSD_BUILD_DIR) |
|---|
| 264 |
rm -rf $(APCUPSD_IPK_DIR) $(APCUPSD_IPK) |
|---|
| 265 |
rm -rf $(APCUPSD-CGI_IPK_DIR) $(APCUPSD-CGI_IPK) |
|---|
| 266 |
# |
|---|
| 267 |
# |
|---|
| 268 |
# Some sanity check for the package. |
|---|
| 269 |
# |
|---|
| 270 |
apcupsd-check: $(APCUPSD_IPK) $(APCUPSD-CGI_IPK) |
|---|
| 271 |
perl scripts/optware-check-package.pl --target=$(OPTWARE_TARGET) $^ |
|---|