Porting LXDM to FreeBSD

All questions and problems regarding the installation and upgrades of LXDE from USB Stick, Live CD or Web.
Locked
AntumDeluge
Posts: 6
Joined: Mon Aug 25, 2014 5:38 pm

Porting LXDM to FreeBSD

Post by AntumDeluge »

Note: I have also posted this to the FreeBSD forums: https://forums.freebsd.org/viewtopic.ph ... 4&p=266770

LXDE is already ported to FreeBSD but not LXDM. So far with some help from the users of #bsdports on the EFNet IRC channel, I have been able to compile LXDM. But, I am now having problems linking. I will name some of the fixes that I have used (some are ugly hacks):

Error 1:
WARNING: sysconfdir is not /etc.
Solution 1:

Set --sysconfdir flag to /usr/local/etc:

Code: Select all

./configure --sysconfdir=$PREFIX/etc
Error 2:
invalid application of 'sizeof' to incomplete type 'LXDM_CRED'
Solution 2:

Define _WANT_UCRED in src/lxcom.h or src/lxcom.c before the sys/ucred.h include

Include sys/param.h in src/lxcom.h & change all defined(__NetBSD__) except the first one to defined(BSD) in src/lxcom.c:

src/lxcom.h:

Code: Select all

  #ifndef _LXCOM_H_
  #define LXCOM_H_

+ #if defined(__unix__) || defined(unix)
+ #include <sys/param.h>
+ #endif
+
+ #if !defined(_WANT_UCRED)
+   #define _WANT_UCRED
+ #endif

void lxcom_init(const char *sock);
...
...
src/lxcom.c:

Code: Select all

  #endif

- #if defined(__NetBSD__)
+ #if defined(BSD)
  typedef struct sockcred LXDM_CRED;
Error 3:
src/lxcom.c:147:11: error: 'cred' undeclared (first use in this function)
Solution 3:

Replace cred * with struct sockcred for FreeBSD in src/lxcom.c:

src/lxcom.c:

Code: Select all

...
...
+ #if defined(__FreeBSD__)
+ size = SOCKCREDSIZE(((struct sockcred *)CMSG_DATA(cmptr))->sc_ngroups);
+ #else
  size = SOCKCREDSIZE(((cred *)CMSG_DATA(cmptr))->sc_ngroups);
+ #endif /* __FreeBSD__ */
...
...
Error 4:
src/lxcom.c:158:71: error: called object '1' is not a function
Solution 4:

Remove the (c) from LXDM_PEER_PID for FreeBSD in src/lxcom.c:

src/lxcom.c:

Code: Select all

...
...
+ #if defined(__FreeBSD__)
+ res=((LXComFunc)callback)(user_data,LXDM_PEER_UID(c),LXDM_PEER_PID,argc,argv);
+ #else
  res=((LXComFunc)callback)(user_data,LXDM_PEER_UID(c),LXDM_PEER_PID(c),argc,argv);
+ #endif /* __FreeBSD__ */
...
...
Error 5:
src/lxcom.c:294:43: error: 'SO_PASSCRED' undeclared (first use in this function)
Solution 5: HACK

Define SO_PASSCRED as 16 (for i386 & amd64, may need to be different for other platforms) in src/lxcom.h.

src/lxcom.h:

Code: Select all

...
...
  #endif

+ #if !defined(SO_PASSCRED)
+   #define SO_PASSCRED 16
+ #endif

  void lxcom_init(const char *sock);
...
...
Error 6:
src/pam.c:48:20: fatal error: shadow.h: No such file or directory
compilation terminated.
Solution 6:

Include xorg/shadow.h for FreeBSD in src/pam.c, src/lxdm.c, & src/auth.c.

src/pam.c:

Code: Select all

...
...
  #include <grp.h>

+ #if defined(__FreeBSD__)
+ #include <xorg/shadow.h>
+ #else
  #include <shadow.h>
+ #endif

  #include <glib.h>
...
...
Error 7:
/usr/local/include/xorg/miscstruct.h:53:20: fatal error: pixman.h: No such file or directory
Solution 7: HACK

Add in include to the pixman-1 directory.

Code: Select all

$ make CFLAGS="-I/usr/local/include/pixman-1"
Error 8:
src/lxdm.c:54:20: fatal error: sys/vt.h: No such file or directory
Solution 8: HACK

Remove the include of sys/vt.h from src/lxdm.c for FreeBSD & create a new struct & two new defines in src/lxdm.h.

src/lxdm.c:

Code: Select all

...
...
#include <glib/gstdio.h>

#if !defined(__FreeBSD__)
#include <sys/vt.h>
#endif

#include <sys/ioctl.h>
...
...
src/lxdm.h:

Code: Select all

...
...
void free_xsessions(GSList *);

struct vt_stat {
	unsigned short v_active;	/* active vt */
	unsigned short v_signal;	/* signal to send */
	unsigned short v_state;		/* vt bitmask */
};

#define VT_GETSTATE	0x5603
#define VT_ACTIVATE	0x5606

G_END_DECLS
...
...
Linker errors:

Those solutions fixed the compile errors. But now I am left with a load of linker errors:
lxdm_binary-lxdm.o: In function `lxsession_stop':
lxdm.c:(.text+0x7d0): undefined reference to `xconn_clean'
lxdm_binary-lxdm.o: In function `lxsession_free':
lxdm.c:(.text+0x8c8): undefined reference to `xconn_close'
lxdm_binary-lxdm.o: In function `on_xserver_stop':
lxdm.c:(.text+0x1be8): undefined reference to `xconn_close'
lxdm_binary-lxdm.o: In function `lxdm_startx':
lxdm.c:(.text+0x1dbe): undefined reference to `xconn_open'
lxdm_binary-lxdm.o: In function `log_sigsegv':
lxdm.c:(.text+0x3386): undefined reference to `backtrace'
lxdm.c:(.text+0x33a0): undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
Any help with these errors is much appreciated.
AntumDeluge
Posts: 6
Joined: Mon Aug 25, 2014 5:38 pm

Re: Porting LXDM to FreeBSD

Post by AntumDeluge »

I was able to get rid of the backtrace errors by adding -lexecinfo to LDFLAGS:

Code: Select all

make CFLAGS="-I/usr/local/include/pixman-1" LDFLAGS="-lexecinfo"
Credit: JX8P

But I am still unable to fix the xconn_ errors. This is the gcc command where the linking error is occurring:
gcc -I/usr/local/include/glib-2.0 -I/usr/local/include -DCONFIG_FILE=\"/etc/lxdm/lxdm.conf\" -DXSESSIONS_DIR=\"/usr/local/share/xsessions\" -DLXDM_DATA_DIR=/usr/local/share/lxdm -DLXDM_NUMLOCK_PATH=\"/usr/local/libexec/lxdm-numlock\" -DLXDM_SESSION_PATH=\"/usr/local/libexec/lxdm-session\" -I/usr/local/include/ConsoleKit/ck-connector -I/usr/local/include/dbus-1.0 -I/usr/local/include/dbus-1.0/include -Werror-implicit-function-declaration -Wall -I/usr/local/include/pixman-1 -lexecinfo -o lxdm-binary lxdm_binary-lxdm.o lxdm_binary-ui.o lxdm_binary-lxcom.o lxdm_binary-xconn.o lxdm_binary-auth.o -L/usr/local/lib -lglib-2.0 -lintl -L/usr/local/lib -lxcb -lck-connector -L/usr/local/lib -ldbus-1 -lck-connector -lpam -lcrypt
lxdm_binary-lxdm.o: In function `lxsession_stop':
lxdm.c:(.text+0x7d0): undefined reference to `xconn_clean'
lxdm_binary-lxdm.o: In function `lxsession_free':
lxdm.c:(.text+0x8c8): undefined reference to `xconn_close'
lxdm_binary-lxdm.o: In function `on_xserver_stop':
lxdm.c:(.text+0x1be8): undefined reference to `xconn_close'
lxdm_binary-lxdm.o: In function `lxdm_startx':
lxdm.c:(.text+0x1dbe): undefined reference to `xconn_open'
collect2: error: ld returned 1 exit status
*** Error code 1
The error occurs when trying to build the executable lxdm-binary. The xconn_close, ]xconn_clean, & xconn_open functions are defined in the created object file src/lxdm_binary-lxdm.o, which appears to be included in the command:
$ grep -r "xconn_close" ./
Binary file ./src/lxdm_binary-lxdm.o matches
Locked