# Tellstick



## pat (Mar 22, 2010)

Today I plugged a TellStick on FreeBSD 8.0-STABLE :

```
Mar 22 10:38:50 atx kernel: ugen0.5: <Telldus> at usbus0
Mar 22 10:38:50 atx root: Unknown USB device: vendor 0x1781 product 0x0c30 bus uhub0
Mar 22 10:38:50 atx uhidd[28880]: terminated
```
So far so good ... I continued with 
	
	



```
svn co http://svn.telldus.se/telldus/trunk/telldus-core
```
 ... then 
	
	



```
cd telldus-core
```
.
Following instructions at TellStick installation - Linux and messing with cmake options, I finally got the code compiled: 
	
	



```
cmake -DBUILD_LIBTELLDUS-CORE=1 -DBUILD_TDTOOL=1 -DBUILD_RFCMD_WITH_LIBFTDI=0 -DBUILD_LIBTELLDUS-CORE_AS_SERVICE=FALSE
```
, installed: 
	
	



```
make && sudo make install
```
 and actually working: 
	
	



```
sudo tdtool -v 125 -d 16
```
 ... dimming a lamp in the terrarium.
It needs:
devel/cmake, devel/libftdi and finally devel/libconfuse.
However, install stage is not clean enough to be packaged yet: I'looking for someone with porting and cmake background to get this cute piece of software properly ported at last.


----------



## pat (Mar 22, 2010)

*preliminary port Makefile*

`svn co [url]http://svn.telldus.se/telldus/trunk/telldus-core[/url] --revision 490`
`mv telldus-core telldus-core-devel`
`tar czf telldus-core-devel-2.0.900rev490.tar.gz telldus-core-devel`
`sudo cp telldus-core-devel-2.0.900rev490.tar.gz /usr/ports/distfiles/`
telldus-core-devel.shar

```
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       .
#       ./telldus-core-devel
#       ./telldus-core-devel/Makefile
#       ./telldus-core-devel/files
#       ./telldus-core-devel/files/patch-driver_libtelldus-core_SettingsConfuse.cpp.patch
#       ./telldus-core-devel/files/patch-driver_libtelldus-core_CMakeLists.txt.patch
#       ./telldus-core-devel/pkg-plist
#       ./telldus-core-devel/pkg-descr
#
echo c - .
mkdir -p . > /dev/null 2>&1
echo c - ./telldus-core-devel
mkdir -p ./telldus-core-devel > /dev/null 2>&1
echo x - ./telldus-core-devel/Makefile
sed 's/^X//' >./telldus-core-devel/Makefile << '9b6a8544d2b7bbde2f3a0a6ae1ac3b1d'
X# New ports collection makefile for:   telldus-core-devel
X# Date created:        22 march 2010
X# $FreeBSD$
X#
X
XPORTNAME=      telldus-core-devel
XPORTVERSION=   2.0.900rev490
XCATEGORIES=    comms
XMASTER_SITES=  http://download.telldus.se/TellStick/Software/telldus-core/
XMAINTAINER=    nobody
XCOMMENT=       Utilities for a Telldus TellStick.
X
XWRKSRC=      ${WRKDIR}/${PORTNAME}
X
XUSE_CMAKE=yes
XLIB_DEPENDS= ftdi.18:${PORTSDIR}/devel/libftdi
XLIB_DEPENDS+= confuse.0:${PORTSDIR}/devel/libconfuse
X
XSTATEDIR?=/var/db
X
XCMAKE_ARGS+=   -DBUILD_LIBTELLDUS-CORE=1
XCMAKE_ARGS+=   -DBUILD_TDTOOL=1
XCMAKE_ARGS+=   -DBUILD_RFCMD_WITH_LIBFTDI=0
XCMAKE_ARGS+=   -DBUILD_LIBTELLDUS-CORE_AS_SERVICE=FALSE
XCMAKE_ARGS+=   -DSYSCONF_INSTALL_DIR="${LOCALBASE}/etc"
XCMAKE_ARGS+=   -DSTATE_INSTALL_DIR="${STATEDIR}"
X
X
X.include <bsd.port.mk>
9b6a8544d2b7bbde2f3a0a6ae1ac3b1d
echo c - ./telldus-core-devel/files
mkdir -p ./telldus-core-devel/files > /dev/null 2>&1
echo x - ./telldus-core-devel/files/patch-driver_libtelldus-core_SettingsConfuse.cpp.patch
sed 's/^X//' >./telldus-core-devel/files/patch-driver_libtelldus-core_SettingsConfuse.cpp.patch << 'a3cc0017abb3a1c385a52ff83ae73078'
X--- driver/libtelldus-core/SettingsConfuse.cpp.orig    2010-04-07 05:58:00.000000000 +0200
X+++ driver/libtelldus-core/SettingsConfuse.cpp 2010-04-07 05:58:49.000000000 +0200
X@@ -26,10 +26,11 @@
X bool readConfig(cfg_t **cfg);
X bool readVarConfig(cfg_t **cfg);
X 
X-const char* CONFIG_FILE = "/etc/tellstick.conf";
X #ifdef __FreeBSD__
X-const char* VAR_CONFIG_FILE = "/var/spool/telldus-core.conf";
X+const char* CONFIG_FILE = "/usr/local/etc/tellstick.conf";
X+const char* VAR_CONFIG_FILE = "/var/db/telldus-core.conf";
X #else
X+const char* CONFIG_FILE = "/etc/tellstick.conf";
X const char* VAR_CONFIG_FILE = "/var/state/telldus-core.conf";
X #endif
X 
a3cc0017abb3a1c385a52ff83ae73078
echo x - ./telldus-core-devel/files/patch-driver_libtelldus-core_CMakeLists.txt.patch
sed 's/^X//' >./telldus-core-devel/files/patch-driver_libtelldus-core_CMakeLists.txt.patch << 'c47c7b9287bab09c099b070415e74288'
X--- driver/libtelldus-core/CMakeLists.txt.orig 2010-03-22 17:36:32.000000000 +0100
X+++ driver/libtelldus-core/CMakeLists.txt      2010-03-23 07:15:08.000000000 +0100
X@@ -211,18 +211,19 @@
X ENDIF (UNIX)
X 
X IF (UNIX AND NOT APPLE)
X-      SET(SYSCONF_INSTALL_DIR "/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
X-      SET(STATE_INSTALL_DIR   "/var/state" CACHE PATH "The directory to store state information of the devices" )
X-      SET(UDEV_RULES_DIR      "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
X+      SET(SYSCONF_INSTALL_DIR "/usr/local/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
X+      SET(STATE_INSTALL_DIR   "/var/db" CACHE PATH "The directory to store state information of the devices" )
X+#     SET(UDEV_RULES_DIR      "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
X 
X-      INSTALL(FILES tellstick.conf
X+      CONFIGURE_FILE(tellstick.conf tellstick.conf.sample COPYONLY)
X+      INSTALL(FILES tellstick.conf.sample
X               DESTINATION ${SYSCONF_INSTALL_DIR}
X       )
X       INSTALL(FILES telldus-core.conf
X               DESTINATION ${STATE_INSTALL_DIR}
X               PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
X       )
X-      INSTALL(FILES 99-tellstick.rules
X-              DESTINATION ${UDEV_RULES_DIR}
X-      )
X+#     INSTALL(FILES 99-tellstick.rules
X+#             DESTINATION ${UDEV_RULES_DIR}
X+#     )
X ENDIF (UNIX AND NOT APPLE)
c47c7b9287bab09c099b070415e74288
echo x - ./telldus-core-devel/pkg-plist
sed 's/^X//' >./telldus-core-devel/pkg-plist << '27c9d6033f5188ee01c946b6e173956c'
Xlib/libtelldus-core.so.2.0.900
Xlib/libtelldus-core.so.2
Xlib/libtelldus-core.so
Xinclude/telldus-core.h
Xinclude/telldus-core-service.h
Xetc/tellstick.conf.sample
Xbin/tdtool
Xbin/rfcmd
X%STATEDIR%telldus-core.conf
27c9d6033f5188ee01c946b6e173956c
echo x - ./telldus-core-devel/pkg-descr
sed 's/^X//' >./telldus-core-devel/pkg-descr << '8a8b1c44f9912f46c89d19162e7e8e35'
XTellStick is a USB-connected transmitter allowing users to control remote receivers from the computer. It is the link
Xbetween the computer and the electronics of the home or the office. By supporting most 433.92 MHz wireless
Xreceivers, TellStick offers a flexible solution. Focusing on simplicity ...
8a8b1c44f9912f46c89d19162e7e8e35
exit
```


----------



## phoenix (Mar 23, 2010)

pat said:
			
		

> Makefile
> 
> ```
> # New ports collection makefile for:   telldus-core
> ...



Remove ${LOCALBASE}/lib from the above, and convert them to LIB_DEPENDS.



> ```
> STATEDIR?=/var/db
> 
> CMAKE_ARGS=-DBUILD_LIBTELLDUS-CORE=1 -DBUILD_TDTOOL=1 -DBUILD_RFCMD_WITH_LIBFTDI=0 \
> ...



You patch the cmakefile (or whatever it's called).  The general process is along the lines of:

```
# cd /usr/ports/category/port
# mkdir files
# make extract
# cd work/source-dir/
# cp cmakefile cmakefile.orig
# ee cmakefile
<edit as needed>
# diff -u cmakefile.orig cmakefile > ../../files/patch-cmakefile
```

Then you can do a "make clean" and "make patch" to see if the patch works.



> In driver/libtelldus-core/SettingsConfuse.cpp: telldus-core.conf
> - where should telldus-core.conf go : in /var/db or /var/spool​- it's another tellstick.conf, as I understood it was supposed to store devices states​



If these are user-editable config files, they should go under /usr/local/etc.  If they are internal config files that the user never sees, then possibly /var/db/telldus or /usr/share/telldus depending on what their purpose is.



> I wish devd to link /dev/ugen to /dev/tellstick on-the-fly ...
> a simple ln in a devd attach action script should be enough (?)



Have a read through devd.conf(5) and devfs.conf(5).  Then run *tail -f /var/run/devd.pipe* and plug-in then un-plug the device and see what devd outputs.  Using that, you can come up with a devd.conf entry to automate things.  I believe devd works with config files under /usr/local/etc/ as well.



> Right now the distfile is a simple svn checkout tarballed



If you are going to maintain this as a port, then you will need to provide a tarball with a version number (a date or svn revision number) that can be hosted either on your own server or on the FreeBSD FTP server.  You can't just put in "svn co" commands in the port Makefile.  

If there are no stable releases yet, perhaps only create a telldus-devel port that you update every couple of weeks.  Then, when there's a real, stable release, ask for a repo-copy of the telldus-devel port to telldus, and update that with the release version.


----------



## mickeprag (Apr 6, 2010)

I would recommend to use the released tarballs and not compile from trunk. Trunk might be broken from time to time.

You can find them here:
http://download.telldus.se/TellStick/Software/telldus-core/

Latest (2010-04-06) is 2.0.2:
http://download.telldus.se/TellStick/Software/telldus-core/telldus-core-2.0.2.tar.gz


----------



## pat (Apr 15, 2010)

*telldus-core-devel port*

Mickeprag is right of course ... but I'm lazy and lack free time with Baby coming along. svn rev 490 compiles like a charm, making it the ideal candidate for a port draft.
By the way, following Phoenix advises, here is my /usr/local/etc/devd/telldus.conf:

```
attach 10 {
        device-name "ugen[0-9]+";
        match "vendor"  "0x1781";
        match "product" "0x0c30";
        action "/bin/ln -fs /dev/$device-name /dev/tellstick";
};
```


----------



## mix_room (May 19, 2010)

pat said:
			
		

> Mickeprag is right of course ... but I'm lazy and lack free time with Baby coming along. svn rev 490 compiles like a charm, making it the ideal candidate for a port draft.



I agree. Svn revision 490 compiles wonderfully for me aswell. The tarball suggested by Mickeprag does not compile without patches. Would be very pleased if this could be included in ports. 

Mickeprag: could you release revision 490 as a tar-ball?


----------



## mickeprag (May 20, 2010)

Please provide us with the patches so we can include them in upcoming releases.


----------



## mix_room (May 20, 2010)

trunk revision 509 builds, but with warnings. Please see below: 


```
svn co http://svn.telldus.se/telldus/trunk/telldus-core
Checked out revision 509.
```


```
# make
[  4%] Building CXX object driver/libtelldus-core/CMakeFiles/telldus-core.dir/SettingsConfuse.cpp.o
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp: In function 'bool readConfig(cfg_t**)':
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:313: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:327: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:337: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:343: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:343: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:343: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp: In function 'bool readVarConfig(cfg_t**)':
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:360: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:360: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:360: warning: deprecated conversion from string constant to 'char*'
/home/mix_room/BUILD/telldus-core/driver/libtelldus-core/SettingsConfuse.cpp:365: warning: deprecated conversion from string constant to 'char*'
```


----------



## mickeprag (May 21, 2010)

These warnings should be there in 490 aswell, right?

We are using a C-library (libconfuse) and gcc doesn't like it's makros when building as C++. I am not sure how to fix it.


----------



## mix_room (May 21, 2010)

mickeprag said:
			
		

> These warnings should be there in 490 aswell, right?



Yes, they show up in 490 aswell.


----------



## pat (May 21, 2010)

mickeprag said:
			
		

> We are using a C-library (libconfuse) and gcc doesn't like it's makros when building as C++. I am not sure how to fix it.


How bad would it be to set the 
	
	



```
-Wno-write-strings
```
 gcc flag on a stable release when compiling SettingsConfuse.cpp ?
I'm flirting with the edge of my gcc knowledge here :e


----------



## rg (Jan 28, 2012)

Is there a package available by now? I would like to try this on a pfSense gateway. If not I would have to set up a complete development environment for this, just to try it.

RenÃ©


----------



## SnuRRe (Feb 20, 2012)

Old thread.. but I'm really interested in this too. Is there a package? Or any plans of getting it into ports?


----------



## mix_room (Feb 20, 2012)

Their newest release compiled nicely last time I tried. The build instructions are on their homepage.


----------



## SnuRRe (Feb 22, 2012)

Yeah, I was a little too quick here.. 
Thanks anyway!


----------



## mix_room (Feb 23, 2012)

SnuRRe said:
			
		

> Yeah, I was a little too quick here..



Now you only need to create the port.


----------



## SnuRRe (Feb 24, 2012)

mix_room said:
			
		

> Now you only need to create the port.



Hehe well, I've never done that before. So I think someone else can have the honor of doing it :e


----------



## fegu (Jan 7, 2014)

While there is no port yet, this software compiles fine. I just tested v2.1.1.
It requires 
cmake
libftdi
libconfuse
argp-standalone

When those are present, just fetch the latest tarball, unpack and do

```
cmake .
make
make install
```
The last one as root.

Remember to start telldusd before trying tdtool.


----------



## tingo (Apr 7, 2014)

Unfortunately, telldus-core 2.1.2 (released on April 3rd, 2014) doesn't compile as easily:

```
tingo@kg-v2$ pwd
/home/tingo/work/telldus-core-2.1.2
tingo@kg-v2$ cmake .
-- The C compiler identification is GNU 4.2.1
-- The CXX compiler identification is GNU 4.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/CC
-- Check for working CXX compiler: /usr/bin/CC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28")
-- checking for one of the modules 'libftdi'
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.3.1")
CMake Error: File /home/tingo/work/telldus-core-2.1.2/Doxyfile.in does not exist.
CMake Error at CMakeLists.txt:64 (CONFIGURE_FILE):
  configure_file Problem configuring file


-- Configuring incomplete, errors occurred!
```
I'm no CMake expert, but there are no "Doxyfiles" here:

```
tingo@kg-v2$ find . -name '*Doxy*' -print
tingo@kg-v2$
```
This is on

```
tingo@kg-v2$ uname -a
FreeBSD kg-v2.kg4.no 8.4-STABLE FreeBSD 8.4-STABLE #7 r256430: Sun Oct 13 19:43:35 CEST 2013
     root@kg-v2.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64
```
Yes, version 2.1.1 compiled fine.


----------



## fegu (Apr 7, 2014)

I tried on  FreeBSD 9.2-RELEASE #0 i386.

`cmake .` goes fine, but `make` fails with


```
/root/telldus/telldus-core-2.1.2/common/EventHandler_unix.cpp:82: error: integer constant is too large for 'long' type
*** [common/CMakeFiles/TelldusCommon.dir/EventHandler_unix.cpp.o] Error code 1
```

Perhaps it needs a 64bit system. I need to upgrade my home automation server to try that.


----------



## jstrom (Apr 8, 2014)

Hi, 

just got a working port, at least working on 9.2 amd64. I have not seen the "integer constant is too large for 'long' type" error though..

For details, please see http://www.telldus.com/forum/viewtopic. ... 646#p25646 

/Johan


----------



## mix_room (Apr 28, 2014)

@jstrom: the port doesn't build on 10.0-RELEASE. 

Errors: 
	
	



```
===>  Building for telldus-core-2.1.2
Scanning dependencies of target TelldusCommon
[  1%] Building CXX object common/CMakeFiles/TelldusCommon.dir/Event.cpp.o
In file included from /usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Event.cpp:7:
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Event.h:35:15: error: no member named 'tr1' in namespace 'std'
        typedef std::tr1::shared_ptr<EventData> EventDataRef;
                ~~~~~^
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Event.h:35:30: error: expected unqualified-id
        typedef std::tr1::shared_ptr<EventData> EventDataRef;
```

I am looking into why this happens. This error is removed when 
	
	



```
USE_GCC= yes
```
 is included in the Makefile. 

It now stops on: 
	
	



```
[ 15%] Building CXX object common/CMakeFiles/TelldusCommon.dir/Socket_unix.cpp.o
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp: In member function 'void TelldusCore::Socket::connect(const wstring&)':
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp:75:8: error: 'strlen' was not declared in this scope
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp: In member function 'std::wstring TelldusCore::Socket::read(int)':
/usr/ports/comms/telldus-core/work/telldus-core-2.1.2/common/Socket_unix.cpp:113:37: error: 'memset' was not declared in this scope
*** Error code 1
```

Which can be fixed by including 
	
	



```
#include <cstring>
```
 in common/Socket_unix.cpp and service/ConnectionListener_unix.cpp


Have you submitted your port for inclusion in the ports tree? That is a lot easier than applying your script.


----------



## jstrom (Apr 28, 2014)

Hi,

first of, no I have not submitted it yet. Wanted at least _someone_ else to try it before sent of. Thanks for that  But submission is absolutely planned. 

Regarding 10.0 problems, I think a friend of mine had those problems.. he managed to patch it away with some brute force hacking (he's not a programmer), so the result wasn't as clean. But it basically boiled down to some includes which needed adding, and removing "tr1" in some places..

Not too familiar with 10.0 and gcc/clang/C++11 and so on, so I'm not sure how a "proper" code fix for the tr1 issue would look, but surely there must be some way for pre-c11 code (which uses ::tr1) to be compiled using a c11-aware compiler?


----------



## mix_room (Apr 28, 2014)

I added some stuff to my previous post. The errors are gone using a forced GCC compile and two include statements.

It seems to be working.


----------



## jstrom (Apr 28, 2014)

Ah, simple include fix yes. Thanks!

I think it should be able to compile with clang though, if those ::tr1 things are fixed.. GCC is not installed by default on FreeBSD 10 if I've understood correctly? Which means we'd want it to build with clang if possible.
I don't have a system to test on yet, unfortunately :/ Might have soon though.


----------



## mix_room (Apr 28, 2014)

I managed to get rid of the dependency on GCC, and patched some additional include statements. Patches are included, should just be to drop them into the files/ folder.

Detail 1: removed tr1:: as they seem to have become part of C++11.
Detail 2: added some includes which were not defined before.


----------



## jstrom (Apr 29, 2014)

Thanks!

I've added the patches to the port, the tr1 stuff as a conditional patch on >= 10.0. Would you mind testing it to make sure it applies properly?


----------



## mix_room (Apr 30, 2014)

The `make` process complains about including <bsd.port.pre.mk>, so I changed it to <bsd.port.options.mk>. 


Now it appears to be applying, and building, cleanly (at least without obvious errors). However my poudriere machine is still having trouble building it, can't find an ICONV library. Probably some dependency that is missing. I'll have a look into it and let you know.


----------



## jstrom (Apr 30, 2014)

Hm, I might have made a mistake there; should probably be bsd.port.pre.mk, and the last line should be changed from bsd.port.mk to bsd.port.post.mk (ref http://www.freebsd.org/doc/en/books/porters-handbook/dads-after-port-mk.html). Can you try that instead of including options (which is probably not the correct thing to do)?

Weird about iconv, I can build it successfully in poudriere without that as an explicit dep.. However the binary is linked to iconv.. weird! 
Should be a quick fix though, just add USES+=ICONV I think


----------



## mix_room (Apr 30, 2014)

```
-.include <bsd.port.pre.mk>
+.include <bsd.port.options.mk>
```

does a much better job for me than using bsd.port.pre.mk and bsd.port.post.mk

For some reason 'USES+=iconv' doesn't work for me. Very odd.

The errors from when ICONV isn't being found is below. 

```
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
ICONV_LIBRARY
    linked by target "TelldusCommon" in directory /wrkdirs/usr/ports/misc/telldus-core/work/telldus-core-2.1.2/common

-- Configuring incomplete, errors occurred!
See also "/wrkdirs/usr/ports/misc/telldus-core/work/telldus-core-2.1.2/CMakeFiles/CMakeOutput.log".
*** Error code 1

Stop.
make: stopped in /usr/ports/misc/telldus-core
===>  Cleaning for telldus-core-2.1.2_2
build of /usr/ports/misc/telldus-core ended at Wed Apr 30 13:09:11 CEST 2014
build time: 00:00:06
```


----------



## jstrom (Apr 30, 2014)

Okay, well that works on 9.2 as well, and http://lists.freebsd.org/pipermail/free ... 85982.html seems to indicate that it's fine.. So I guess we do that  


USES+=iconv doesn't do anything neither good or bad here, except what I'd expect: 

```
===>   telldus-core-2.1.2_2 depends on shared library: libiconv.so.3 - found
```
 
After cmake has executed, CMakeCache.txt in work dir has the following:

```
ICONV_LIBRARY:FILEPATH=/usr/local/lib/libiconv.so
```


----------



## mix_room (Apr 30, 2014)

jstrom said:
			
		

> Okay, well that works on 9.2 as well, and http://lists.freebsd.org/pipermail/free ... 85982.html seems to indicate that it's fine.. So I guess we do that


Suits me. 



> After cmake has executed, CMakeCache.txt in work dir has the following:
> ICONV_LIBRARY:FILEPATH=/usr/local/lib/libiconv.so



That works fine as long as I don't try to compile it with poudriere. It compiles properly on my other 10.0-RELEASE machine, just not with the package builder.
However I still think the port is quite good, probably the fault is somewhere in my settings.

EDIT: Adding libiconv as a dependency works with poudriere aswell, but it is an ugly hack as 10.0-RELEASE should have a native iconv installed. 


```
# <HACK> to make building on poudriere easier. 
LIB_DEPENDS+=libiconv.so:${PORTSDIR}/converters/libiconv
```


----------



## jstrom (May 1, 2014)

Can you test this patch and see if it helps? (remove the LIB_DEPENDS hack in the Makefile):


```
--- common/CMakeLists.txt
+++ common/CMakeLists.txt
@@ -54,7 +54,7 @@ ELSEIF (WIN32)
        )
 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
        #### FreeBSD ####
-       FIND_LIBRARY(ICONV_LIBRARY iconv)
+       FIND_LIBRARY(ICONV_LIBRARY iconv PATHS /usr/local/lib /usr/lib)
        ADD_DEFINITIONS( -D_FREEBSD )
        LIST(APPEND  telldus-common_SRCS
                Event_unix.cpp
```


----------



## mix_room (May 1, 2014)

Doesn't work. 
I already tried something similar. 

Seeing as the dependency on libiconv works, I think its best to run with that.


----------



## jstrom (May 1, 2014)

Looked into it a bit more, and got a 10.x box up and running to test on. The issue is that FreeBSD 10 does not have a libiconv.so, but rather ships the iconv code in libc. The following patch seems to build fine on both 10.0 and 9.2 (remove any previous iconv patches):


```
--- common/CMakeLists.txt
+++ common/CMakeLists.txt
@@ -54,16 +54,22 @@ ELSEIF (WIN32)
        )
 ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
        #### FreeBSD ####
-       FIND_LIBRARY(ICONV_LIBRARY iconv)
+       string(REGEX MATCH "(([0-9]+)\\.([0-9]+))-([A-Z0-9])+" FREEBSD "${CMAKE_SYSTEM_VERSION}")
+       set( FREEBSD_RELEASE "${CMAKE_MATCH_1}" )
        ADD_DEFINITIONS( -D_FREEBSD )
        LIST(APPEND  telldus-common_SRCS
                Event_unix.cpp
                EventHandler_unix.cpp
                Socket_unix.cpp
        )
-       LIST(APPEND telldus-common_LIBRARIES
-               ${ICONV_LIBRARY}
-       )
+
+       # FreeBSD 10 has iconv built in to libc
+       IF(FREEBSD_RELEASE LESS 10)
+               FIND_LIBRARY(ICONV_LIBRARY iconv)
+               LIST(APPEND telldus-common_LIBRARIES
+                       ${ICONV_LIBRARY}
+               )
+       ENDIF ()
```

Regarding the poudriere issue, on a fresh 10.0 it fails to build outside too, so most likely your base system just have libiconv installed as a dep from some other port, which cmake found and used.

Full port attached, including above patch.


----------



## mix_room (May 2, 2014)

That builds without error. 

And basic functionality check also works. 

Seems good to go.


----------



## jstrom (May 2, 2014)

Great! I'll submit this to ports then, thanks for your help and feedback 

Update: http://www.freebsd.org/cgi/query-pr.cgi?pr=189221


----------



## mix_room (May 2, 2014)

Great! Finally I don't need to compile it by hand any more. 

Post a message if you want any more testing done.


----------



## fegu (Jun 16, 2014)

On my 10.0-RELEASE FreeBSD 10.0-RELEASE #0 with generic amd64 kernel I am unable to get this to work. I have tried the patchset linked to here, both from the ports and the tar.gz above. It always fails while doing make on 88% progress (having compiled telldusd it wants to link it):


```
Linking CXX executable telldusd
../common/libTelldusCommon.a(Strings.cpp.o): In function `TelldusCore::charToWstring(char const*)':
/root/telldus/telldus-core/work/telldus-core-2.1.2/common/Strings.cpp:(.text+0xa2): undefined reference to `libiconv_open'
```

I have iconv and libiconv installed. What could be missing here?


----------



## fegu (Jun 16, 2014)

I got this to work my adding 
	
	



```
USES+=libtool
```
 in the Makefile (just below USES+=iconv).

You will need the ports collection installed, at least this fix failed until I did `portsnap fetch extract`.

I was also required to change the user/group in /usr/local/etc/tellstick.conf. Without changing this (try root/wheel first), `tdtool -l` forever reported no sensors present.


----------



## jstrom (Jun 17, 2014)

fegu said:
			
		

> I got this to work my adding
> 
> 
> 
> ...



Some googling on the libiconv_open error gives a possible conflict between iconv from ports and base. On FreeBSD 10.x, you shouldn't need to install iconv from ports at all, if I understand things correctly.

If you uninstall the iconv port, does it link properly (without the libtool fix)?

Regarding the tellstick.conf problem, can you try the following pkg-plist patch?


```
--- pkg-plist     2014-06-17 12:55:17.229192083 +0200
+++ pkg-plist   2014-06-17 13:07:35.227751723 +0200
@@ -1,13 +1,16 @@
 etc/devd/tellstick.conf

+@group dialer
+@mode 664
 @unexec if cmp %D/etc/tellstick.conf.sample %D/etc/tellstick.conf; then rm -vf %D/etc/tellstick.conf; fi
 etc/tellstick.conf.sample
 @exec [ -f %D/etc/tellstick.conf ] || cp -v %D/etc/tellstick.conf.sample %D/etc/tellstick.conf
-
 @exec mkdir -p %D/var/telldus && chown nobody:dialer %D/var/telldus
 @unexec if [ ! -s %D/var/telldus/telldus-core.conf ]; then rm -vf %D/var/telldus/telldus-core.conf; fi
 @exec [ -f %D/var/telldus/telldus-core.conf ] || touch %D/var/telldus/telldus-core.conf && chown nobody:dialer %D/var/telldus/telldus-core.conf
 @dirrmtry var/telldus
+@group
+@mode
 @dirrmtry var

 bin/tdtool
```

This should make sure that the conf files have group ID dialer, and 664 permissions... Should probably go for a specific telldus user but..


----------



## jstrom (Aug 15, 2014)

Hi,

I'm happy to report that this port is now in the ports tree! After lots of work by committer John Marino, it finally made it today: http://www.freshports.org/comms/telldus-core/

For some learning, regarding general porting and also how to "properly" solve the tr1 issue (at least on FreeBSD ports), see https://bugs.freebsd.org/bugzilla/show_ ... ?id=189221

/Johan


----------



## mix_room (Aug 20, 2014)

Great news.
Thanks for the good work.


----------

