Wed Jan 16 14:43:22 2019 UTC ()
Add a variant of the "sunwait" program, used to calculate sunset and
sunrise (usefull in semi automatic astro-photography or home automation).
With big help from leonardo.
(martin)
diff -r0 -r1.1 pkgsrc/misc/sunwait/DESCR
diff -r0 -r1.1 pkgsrc/misc/sunwait/Makefile
diff -r0 -r1.1 pkgsrc/misc/sunwait/PLIST
diff -r0 -r1.1 pkgsrc/misc/sunwait/distinfo
diff -r0 -r1.1 pkgsrc/misc/sunwait/patches/patch-Makefile
diff -r0 -r1.1 pkgsrc/misc/sunwait/patches/patch-sunriset.cpp
diff -r0 -r1.1 pkgsrc/misc/sunwait/patches/patch-sunwait.cpp
Sunwait is a small program for calculating sunrise and sunset,
as well as civil, nautical and astronimical twilight.
It has features that make it usefull for home automation
tasks.
# $NetBSD: Makefile,v 1.1 2019/01/16 14:43:22 martin Exp $
DISTNAME= sunwait-0.8
CATEGORIES= misc
MASTER_SITES= ${MASTER_SITE_GITHUB:=klada/}
MAINTAINER= martin@NetBSD.org
HOMEPAGE= https://github.com/klada/sunwait
COMMENT= Calculate sunrise, sunset and twilight
LICENSE= gnu-gpl-v2
USE_LANGUAGES+= c++11
.include "../../mk/bsd.pkg.mk"
@comment $NetBSD: PLIST,v 1.1 2019/01/16 14:43:22 martin Exp $
bin/sunwait
$NetBSD: distinfo,v 1.1 2019/01/16 14:43:22 martin Exp $
SHA1 (sunwait-0.8.tar.gz) = eed1453e288d03d200d4f74634324a343434f426
RMD160 (sunwait-0.8.tar.gz) = ffad86c063eac4952141016fde056056d44963b4
SHA512 (sunwait-0.8.tar.gz) = 974aec925e08d42f6b9d617cd033ab21af314b04a0bab100f9b473e038df7eb65a86de2240ef2d5308af5385c929607d591c6f7b738925622e38040af6368166
Size (sunwait-0.8.tar.gz) = 20302 bytes
SHA1 (patch-Makefile) = 63276adb2587a251d9bb896ec82cd5ba6b3d6c07
SHA1 (patch-sunriset.cpp) = 759aa1f2c0301f8fab3a264167d25a077ed205ee
SHA1 (patch-sunwait.cpp) = cf5b2251a4b0de5e95cdbd06a432824b623df42b
$NetBSD: patch-Makefile,v 1.1 2019/01/16 14:43:22 martin Exp $
- Use CC instead of C to specify the C compiler and do not hardcode gcc
- Honors user's {C,LD}FLAGS
- Make the install target more flexible
--- Makefile.orig 2015-09-20 14:07:55.000000000 +0000
+++ Makefile
@@ -5,23 +5,29 @@
#
-C=gcc
-CFLAGS=-c -Wall
-LDFLAGS= -lm -lstdc++
+CC=c++
+CFLAGS+=-c -Wall -D__linux__
+LDFLAGS+= -lm -lstdc++
SOURCES=sunwait.cpp sunriset.cpp print.cpp sunwait.h sunriset.h print.h
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=sunwait
+PREFIX?= /usr
+
+INSTALL_PROGRAM?= install -m 755
+INSTALL_PROGRAM_DIR?= install -d -m 755
+
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
- $(C) $(OBJECTS) -o $@ $(LDFLAGS)
+ $(CC) $(OBJECTS) -o $@ $(LDFLAGS)
.cpp.o:
- $(C) $(CFLAGS) $< -o $@
+ $(CC) $(CFLAGS) $< -o $@
clean:
rm -f *.o sunwait
install:
- install -D -m 755 sunwait $(DESTDIR)/usr/bin/sunwait
+ ${INSTALL_PROGRAM_DIR} $(DESTDIR)$(PREFIX)/bin
+ ${INSTALL_PROGRAM} sunwait $(DESTDIR)$(PREFIX)/bin/sunwait
$NetBSD: patch-sunriset.cpp,v 1.1 2019/01/16 14:43:22 martin Exp $
Use fabs() instead of integer abs() for double values.
--- sunriset.cpp.orig 2015-09-20 16:07:55.000000000 +0200
+++ sunriset.cpp 2018-07-19 14:17:06.794662715 +0200
@@ -92,7 +92,7 @@
/* compute the diurnal arc that the sun traverses to reach the specified altitide altit: */
double cost = (sind(altitude) - sind(pRun->latitude) * sind(sdec)) / (cosd(pRun->latitude) * cosd(sdec));
- if (abs(cost) < 1.0)
+ if (fabs(cost) < 1.0)
diurnalArc = 2*acosd(cost)/15.0; /* Diurnal arc, hours */
else if (cost>=1.0)
diurnalArc = 0.0; // Polar Night
$NetBSD: patch-sunwait.cpp,v 1.1 2019/01/16 14:43:22 martin Exp $
Fix typo that causes a warning from newer gcc.
--- sunwait.cpp.orig 2015-09-20 16:07:55.000000000 +0200
+++ sunwait.cpp 2018-07-19 14:15:25.334426961 +0200
@@ -661,7 +661,7 @@
if (pRun->debug == ONOFF_ON) printf ("Debug: argv[%d]: >%s<\n", i, arg);
// Strip any hyphen from arguments, but not negative signs of numbers
- if (arg[0] == '-' && arg[1] != '\0' && !isdigit(arg[1])) *arg++;
+ if (arg[0] == '-' && arg[1] != '\0' && !isdigit(arg[1])) arg++;
// Normal help or version info
if (!strcmp (arg, "v") ||