Re: compiling FreeBSD date on Linux
I added #include time.h to date .c but still get some errors: date.c: In function ‘setthetime’: date.c:192: warning: assignment makes pointer from integer without a cast /tmp/ccZTmvsY.o: In function `netsettime': netdate.c:(.text+0x1f1): undefined reference to `strlcpy' collect2: ld returned 1 exit status I tried downloading the source to strlcpy and compiling with everything else: gcc -o date date.c netdate.c vary.c strlcpy.c It compiles now with the warning: date.c: In function ‘setthetime’: date.c:192: warning: assignment makes pointer from integer without a cast ... but it doesn't work. The output of ./date is: %+ I'm going to keep playling with it... On Fri, May 22, 2009 at 4:58 AM, Roland Smith rsm...@xs4all.nl wrote: On Thu, May 21, 2009 at 09:08:31PM -0300, francis keyes wrote: I patched date.c and tried to compile but I get a few errors, as you suspected: In file included from date.c:59: vary.h:35: warning: *struct tm* declared inside parameter list vary.h:35: warning: its scope is only this definition or declaration, which is probably not what you want date.c: In function *main*: date.c:85: error: storage size of *lt* isn*t known Add #include time.h to date.c. Roland -- R.F.Smith http://www.xs4all.nl/~rsmith/http://www.xs4all.nl/%7Ersmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
On Sat, May 23, 2009 at 05:00:08PM -0300, francis keyes wrote: I added #include time.h to date .c but still get some errors: date.c: In function *setthetime*: date.c:192: warning: assignment makes pointer from integer without a cast /tmp/ccZTmvsY.o: In function `netsettime': netdate.c:(.text+0x1f1): undefined reference to `strlcpy' collect2: ld returned 1 exit status Try replacing strlcpy with strncpy. The latter is standard C, although somewhat less safe. Roland -- R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) pgp4c7nVoeYkE.pgp Description: PGP signature
Re: compiling FreeBSD date on Linux
Te strlcpy function is part of the system's C library, libc. It is declared in string.h. Did you #include string.h and check if the Linux C library has this function included? If it has, man strlcpy should mention it. Oh wait, when talking about Linux, it's possible that there is no manpage for this library function. The *l* string functions have been introduced in OpenBSD and FreeBSD to get rid of overflow problems when using strcpy and strcat, because they take a length parameter, which is size_t size. These are their signatures: size_t strlcpy(char *dst, const char *src, size_t size); size_t strlcat(char *dst, const char *src, size_t size); Check if Linux has them, too, and if yes, that they have the same parameter definition. -- Polytropon From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
On Thu, May 21, 2009 at 09:08:31PM -0300, francis keyes wrote: I patched date.c and tried to compile but I get a few errors, as you suspected: In file included from date.c:59: vary.h:35: warning: *struct tm* declared inside parameter list vary.h:35: warning: its scope is only this definition or declaration, which is probably not what you want date.c: In function *main*: date.c:85: error: storage size of *lt* isn*t known Add #include time.h to date.c. Roland -- R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) pgpgIVk88ORtA.pgp Description: PGP signature
Re: compiling FreeBSD date on Linux
I patched date.c and tried to compile but I get a few errors, as you suspected: In file included from date.c:59: vary.h:35: warning: ‘struct tm’ declared inside parameter list vary.h:35: warning: its scope is only this definition or declaration, which is probably not what you want date.c: In function ‘main’: date.c:85: error: storage size of ‘lt’ isn’t known date.c:163: error: invalid type argument of ‘unary *’ (have ‘int’) date.c:172: warning: incompatible implicit declaration of built-in function ‘strftime’ date.c: In function ‘setthetime’: date.c:190: warning: assignment makes pointer from integer without a cast date.c:191: warning: assignment makes pointer from integer without a cast date.c:211: warning: assignment makes pointer from integer without a cast date.c:217: error: dereferencing pointer to incomplete type date.c:218: error: dereferencing pointer to incomplete type date.c:221: error: dereferencing pointer to incomplete type date.c:227: error: dereferencing pointer to incomplete type date.c:232: error: dereferencing pointer to incomplete type date.c:234: error: dereferencing pointer to incomplete type date.c:235: error: dereferencing pointer to incomplete type date.c:236: error: dereferencing pointer to incomplete type date.c:238: error: dereferencing pointer to incomplete type date.c:242: error: dereferencing pointer to incomplete type date.c:243: error: dereferencing pointer to incomplete type date.c:245: error: dereferencing pointer to incomplete type date.c:248: error: dereferencing pointer to incomplete type date.c:249: error: dereferencing pointer to incomplete type date.c:253: error: dereferencing pointer to incomplete type date.c:254: error: dereferencing pointer to incomplete type date.c:258: error: dereferencing pointer to incomplete type date.c:259: error: dereferencing pointer to incomplete type date.c:268: error: dereferencing pointer to incomplete type On Wed, May 20, 2009 at 4:20 PM, Roland Smith rsm...@xs4all.nl wrote: On Wed, May 20, 2009 at 02:45:59PM -0300, francis keyes wrote: Hmm... the date program looks pretty simple but I don't understand the Makfile: #@(#)Makefile8.1 (Berkeley) 5/31/93 # $FreeBSD: src/bin/date/Makefile,v 1.11.30.1 2009/04/15 03:14:26 kensmith Exp $ PROG=date SRCS=date.c netdate.c vary.c DPADD=${LIBUTIL} LDADD=-lutil .include bsd.prog.mk Would it be possible to compile this without a makefile? Sure. A command like gcc -o date date.c netdate.c vary.c works, provided you patch date.c to remove the dependency on libutil (logwtmp function). This will stop date from logging to wtmp(5). - patch for date.c - --- date.c.orig 2009-05-04 22:09:01.0 +0200 +++ date.c 2009-05-20 21:05:32.0 +0200 @@ -48,7 +48,7 @@ #include ctype.h #include err.h #include locale.h -#include libutil.h +/*#include libutil.h*/ #include stdio.h #include stdlib.h #include string.h @@ -274,12 +274,12 @@ if (!jflag) { /* set the time */ if (nflag || netsettime(tval)) { - logwtmp(|, date, ); + /*logwtmp(|, date, );*/ tv.tv_sec = tval; tv.tv_usec = 0; if (settimeofday(tv, (struct timezone *)NULL)) err(1, settimeofday (timeval)); - logwtmp({, date, ); + /*logwtmp({, date, );*/ } if ((p = getlogin()) == NULL) - patch for date.c - With this patch, the executable only depends on libc. Note that I have only confirmed that it compiles _on FreeBSD_. There might be additional differences between FreeBSD libc and the GNU libc that is used on Linux that make further tinkering with the source necessary. Roland -- R.F.Smith http://www.xs4all.nl/~rsmith/http://www.xs4all.nl/%7Ersmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
Hmm... the date program looks pretty simple but I don't understand the Makfile: #@(#)Makefile8.1 (Berkeley) 5/31/93 # $FreeBSD: src/bin/date/Makefile,v 1.11.30.1 2009/04/15 03:14:26 kensmith Exp $ PROG=date SRCS=date.c netdate.c vary.c DPADD=${LIBUTIL} LDADD=-lutil .include bsd.prog.mk Would it be possible to compile this without a makefile? On Tue, May 19, 2009 at 9:38 PM, Chuck Robey chu...@telenix.org wrote: Polytropon wrote: On Tue, 19 May 2009 18:19:21 -0300, francis keyes fke...@gmail.com wrote: I would like to compile the FreeBSD date command for use on Linux because the FreeBSD version has some features that are not present in Linux. I downloaded all the files from http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/date/ and tried to compile it but I get an error from the Makefile: Makefile:9: *** missing separator. Stop. First of all, it seems that it's not that easy. FreeBSD's make is, if I am correct, a different one than the Linux make. It uses - if you look into date's Makefile, an include file, named bsd.prog.mk which is located outside of the date/ directory, this is /usr/share/mk/bsd.prog.mk or /usr/src/share/mk/bsd.prog.mk or /usr/src/tools/build/mk/bsd.prog.mk. You could try to write an own Makefile on Linux, or try to work without one... I suspect this is the first of many errors I will run into during this process. Can anyone help me out with this or tell me if there is an easier way to get this version of the date command running in Linux? I'm not sure, but it's possible that FreeBSD can be used to compile date so it will run on Linux (cross-compier). Because I never tried this, I can't tell you how to achieve this. Furthermore, I'm not sure in how far date hooks into the FreeBSD kernel in order to work. It's completely possible that it would be easier to implement FreeBSD's date functionality in Linux's date command itself (from scratch). The code isn't all that hard to port, unless you're at a very basic level with C. The compatibility level between the BSD Make (bmake) and the GNU Make (gmake) isn't all that great. One killer problem is that gmake hasn't got any concept of a single central include directory, for automatically building up a per machine make environment. Gmake can do the including (using a protocol which is unfortunately different than that of bmake) BUT you can't just rely on gmake looking into the bmake central directory (/usr/share/mk) for make include files. All of those are named like bsd.port.mk, in that they all begin with bsd. and end in .mk, and there isn't any portability between bmake and gmake on those include files. I have personally (in the past) written up a set of gmake compatible include files, so it CAN be done, but you getter have your hard hat on, it's not all that simple to do. The various timing commands in either the bsd libc or the Linux glibc look much alike, so the porting isn't all that hard, once you conquer the makefiles. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
On Wed, May 20, 2009 at 02:45:59PM -0300, francis keyes wrote: Hmm... the date program looks pretty simple but I don't understand the Makfile: #@(#)Makefile8.1 (Berkeley) 5/31/93 # $FreeBSD: src/bin/date/Makefile,v 1.11.30.1 2009/04/15 03:14:26 kensmith Exp $ PROG=date SRCS=date.c netdate.c vary.c DPADD=${LIBUTIL} LDADD=-lutil .include bsd.prog.mk Would it be possible to compile this without a makefile? Sure. A command like gcc -o date date.c netdate.c vary.c works, provided you patch date.c to remove the dependency on libutil (logwtmp function). This will stop date from logging to wtmp(5). - patch for date.c - --- date.c.orig 2009-05-04 22:09:01.0 +0200 +++ date.c 2009-05-20 21:05:32.0 +0200 @@ -48,7 +48,7 @@ #include ctype.h #include err.h #include locale.h -#include libutil.h +/*#include libutil.h*/ #include stdio.h #include stdlib.h #include string.h @@ -274,12 +274,12 @@ if (!jflag) { /* set the time */ if (nflag || netsettime(tval)) { - logwtmp(|, date, ); + /*logwtmp(|, date, );*/ tv.tv_sec = tval; tv.tv_usec = 0; if (settimeofday(tv, (struct timezone *)NULL)) err(1, settimeofday (timeval)); - logwtmp({, date, ); + /*logwtmp({, date, );*/ } if ((p = getlogin()) == NULL) - patch for date.c - With this patch, the executable only depends on libc. Note that I have only confirmed that it compiles _on FreeBSD_. There might be additional differences between FreeBSD libc and the GNU libc that is used on Linux that make further tinkering with the source necessary. Roland -- R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) pgpUB7NIpGWOc.pgp Description: PGP signature
Re: compiling FreeBSD date on Linux
On Wednesday 20 May 2009 19:45:59 francis keyes wrote: Hmm... the date program looks pretty simple but I don't understand the Makfile: #@(#)Makefile8.1 (Berkeley) 5/31/93 # $FreeBSD: src/bin/date/Makefile,v 1.11.30.1 2009/04/15 03:14:26 kensmith Exp $ PROG=date SRCS=date.c netdate.c vary.c DPADD=${LIBUTIL} LDADD=-lutil .include bsd.prog.mk Would it be possible to compile this without a makefile? This is because the under appreciated FreeBSD make system does a *lot* of work for you. - You need libutil: /usr/src/lib/libutil or (probably faster), see which functions from libutil date uses and re-implement them. - Resolve header issues in the above source files - And then it's most likely easiest to use cmake or autotools on linux to compile. -- Mel ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
On Wed, 20 May 2009 14:45:59 -0300, francis keyes fke...@gmail.com wrote: Hmm... the date program looks pretty simple but I don't understand the Makfile: #@(#)Makefile8.1 (Berkeley) 5/31/93 # $FreeBSD: src/bin/date/Makefile,v 1.11.30.1 2009/04/15 03:14:26 kensmith Exp $ PROG=date The final program name. SRCS=date.c netdate.c vary.c The source files it depends on. DPADD=${LIBUTIL} Needs to compile what ${LIBUTIL} point to, usually the libutil directory in the src/ tree. LDADD=-lutil Additional info for the linker: link against libutil. This indicates that libutil is a build dependency for the date program. .include bsd.prog.mk Definitions, variables and what to do is there. Would it be possible to compile this without a makefile? That was my initial idea. The date program seems to depend on two things: First the kernel interface which would be something similar in Linux, and the libutil library, which is maybe present on Linux, too. -- Polytropon From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
#warning Pedantic mode on #define TOPIC BSD build system tricks On Wednesday 20 May 2009 21:57:02 Polytropon wrote: DPADD=${LIBUTIL} Needs to compile what ${LIBUTIL} point to, usually the libutil directory in the src/ tree. This is the actual build dependency and the var is defined in bsd.libnames.mk. LDADD=-lutil Additional info for the linker: link against libutil. This indicates that libutil is a build dependency for the date program. It's a linker statement, while it's logical that libutil has to be built before it can be linked against, this does in fact not have to be the same libutil, so what this line really cares about is that libutil.so or libutil.a is resolvable via the various linker rules. One can in fact do: LDFLAGS=-L/usr/local/lib LDADD=${LIBUTIL} -lutil This will link the static libutil from bsd.libnames.mk and then try to link with /usr/local/lib/libutil.so, before looking elsewhere. -- Mel ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
On Wed, 20 May 2009 14:45:59 -0300, francis keyes fke...@gmail.com wrote: Hmm... the date program looks pretty simple but I don't understand the Makfile: #@(#)Makefile8.1 (Berkeley) 5/31/93 # $FreeBSD: src/bin/date/Makefile,v 1.11.30.1 2009/04/15 03:14:26 kensmith Exp $ PROG=date SRCS=date.c netdate.c vary.c DPADD=${LIBUTIL} LDADD=-lutil .include bsd.prog.mk Would it be possible to compile this without a makefile? Yes, but you will also need bits of code from libutil. If you have all the necessary bits in a new file, i.e. util.c, then you should be able to use: cc -o date date.c netdate.c vary.c util.c Extracting the minimal parts of libutil and writing the new util.c file is an interesting and amusing exercise for a budding C programmer, but it should be both possible and relatively ``easy''. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
On Tue, 19 May 2009 18:19:21 -0300, francis keyes fke...@gmail.com wrote: I would like to compile the FreeBSD date command for use on Linux because the FreeBSD version has some features that are not present in Linux. I downloaded all the files from http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/date/ and tried to compile it but I get an error from the Makefile: Makefile:9: *** missing separator. Stop. First of all, it seems that it's not that easy. FreeBSD's make is, if I am correct, a different one than the Linux make. It uses - if you look into date's Makefile, an include file, named bsd.prog.mk which is located outside of the date/ directory, this is /usr/share/mk/bsd.prog.mk or /usr/src/share/mk/bsd.prog.mk or /usr/src/tools/build/mk/bsd.prog.mk. You could try to write an own Makefile on Linux, or try to work without one... I suspect this is the first of many errors I will run into during this process. Can anyone help me out with this or tell me if there is an easier way to get this version of the date command running in Linux? I'm not sure, but it's possible that FreeBSD can be used to compile date so it will run on Linux (cross-compier). Because I never tried this, I can't tell you how to achieve this. Furthermore, I'm not sure in how far date hooks into the FreeBSD kernel in order to work. It's completely possible that it would be easier to implement FreeBSD's date functionality in Linux's date command itself (from scratch). -- Polytropon From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: compiling FreeBSD date on Linux
Polytropon wrote: On Tue, 19 May 2009 18:19:21 -0300, francis keyes fke...@gmail.com wrote: I would like to compile the FreeBSD date command for use on Linux because the FreeBSD version has some features that are not present in Linux. I downloaded all the files from http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/date/ and tried to compile it but I get an error from the Makefile: Makefile:9: *** missing separator. Stop. First of all, it seems that it's not that easy. FreeBSD's make is, if I am correct, a different one than the Linux make. It uses - if you look into date's Makefile, an include file, named bsd.prog.mk which is located outside of the date/ directory, this is /usr/share/mk/bsd.prog.mk or /usr/src/share/mk/bsd.prog.mk or /usr/src/tools/build/mk/bsd.prog.mk. You could try to write an own Makefile on Linux, or try to work without one... I suspect this is the first of many errors I will run into during this process. Can anyone help me out with this or tell me if there is an easier way to get this version of the date command running in Linux? I'm not sure, but it's possible that FreeBSD can be used to compile date so it will run on Linux (cross-compier). Because I never tried this, I can't tell you how to achieve this. Furthermore, I'm not sure in how far date hooks into the FreeBSD kernel in order to work. It's completely possible that it would be easier to implement FreeBSD's date functionality in Linux's date command itself (from scratch). The code isn't all that hard to port, unless you're at a very basic level with C. The compatibility level between the BSD Make (bmake) and the GNU Make (gmake) isn't all that great. One killer problem is that gmake hasn't got any concept of a single central include directory, for automatically building up a per machine make environment. Gmake can do the including (using a protocol which is unfortunately different than that of bmake) BUT you can't just rely on gmake looking into the bmake central directory (/usr/share/mk) for make include files. All of those are named like bsd.port.mk, in that they all begin with bsd. and end in .mk, and there isn't any portability between bmake and gmake on those include files. I have personally (in the past) written up a set of gmake compatible include files, so it CAN be done, but you getter have your hard hat on, it's not all that simple to do. The various timing commands in either the bsd libc or the Linux glibc look much alike, so the porting isn't all that hard, once you conquer the makefiles. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org