nxp-archive / openil_linuxptp

PTP IEEE 1588 stack for Linux
GNU General Public License v2.0
136 stars 60 forks source link

how to cross compile #23

Closed Dazzingdusk closed 3 years ago

Dazzingdusk commented 3 years ago

HI, I modified the source code and tried to cross-compile, but at present, it seems that there is a problem with the reference path of the header file, which will cause the build to fail. modify patch:

diff --git a/incdefs.sh b/incdefs.sh
old mode 100755
new mode 100644
diff --git a/makefile b/makefile
index 27c4d78..b4d5c10 100644
--- a/makefile
+++ b/makefile
@@ -16,7 +16,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

 KBUILD_OUTPUT =
-
+CROSS_COMPILE = arm-none-eabi-
 DEBUG  =
 CC = $(CROSS_COMPILE)gcc
 VER     = -DVER=$(version)
@@ -43,7 +43,8 @@ incdefs := $(shell $(srcdir)/incdefs.sh)
 version := $(shell $(srcdir)/version.sh $(srcdir))
 VPATH  = $(srcdir)

-prefix = /usr/local
+# prefix   = /usr/local
+prefix = $(pwd)/ptp/
 sbindir    = $(prefix)/sbin
 mandir = $(prefix)/man
 man8dir    = $(mandir)/man8
Dazzingdusk commented 3 years ago

error log:

In file included from clockadj.c:25:0:
missing.h:79:40: error: missing binary operator before token "("
 #if LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0)
                                        ^
DEPEND clock.c
In file included from clock.c:35:0:
missing.h:79:40: error: missing binary operator before token "("
 #if LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0)
                                        ^
DEPEND bmc.c
arm-none-eabi-gcc -Wall -DVER=3.1.1-g4367d83-dirty  -D_GNU_SOURCE -DHAVE_CLOCK_ADJTIME -DHAVE_POSIX_SPAWN -DHAVE_ONESTEP_SYNC     -c -o ptp4l.o ptp4l.c
In file included from filter.h:23:0,
                 from ds.h:25,
                 from clock.h:24,
                 from ptp4l.c:26:
tmv.h:23:10: fatal error: linux/ptp_clock.h: No such file or directory
 #include <linux/ptp_clock.h>
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
<builtin>: recipe for target 'ptp4l.o' failed
make: *** [ptp4l.o] Error 1
Dazzingdusk commented 3 years ago

Just replace the cross compiler that supports glibc, for example arm-linux-.....; instead of arm-none-.....