Patch to fix cross-compiling
I've created a patch against your SVN trunk which uses ax_cc_for_build.m4 to provide CC_FOR_BUILD which is then used in auparse/Makefile.am and lib/Makefile.am to build the utilities that run on the build machine.
I was able to use this patch to cross-compile audit for my ARM platform. I'm still in the process of testing audit on the ARM platform.
Comments, questions and critiques welcome.
Regards,
George McCollister
From 851be06769db3c21df166900aa1a281cf32324ec Mon Sep 17 00:00:00 2001
From: George McCollister <[email protected]>
Date: Thu, 1 Nov 2012 13:28:49 -0500
Subject: [PATCH] Use CC_FOR_BUILD to make cross-compiling work
--- auparse/Makefile.am | 129 ++++++++++++++++++++++++++++--------------------- autogen.sh | 2 +- configure.ac | 1 + lib/Makefile.am | 91 ++++++++++++++++++---------------- m4/ax_cc_for_build.m4 | 77 +++++++++++++++++++++++++++++ 5 files changed, 200 insertions(+), 100 deletions(-) create mode 100644 m4/ax_cc_for_build.m4
auparse/Makefile.am +73 -56
@@ -47,125 +47,142 @@ BUILT_SOURCES = captabs.h clocktabs.h clone-flagtabs.h epoll_ctls.h famtabs.h \ mmaptabs.h mounttabs.h nfprototabs.h open-flagtabs.h \ persontabs.h prottabs.h ptracetabs.h rlimittabs.h recvtabs.h \ signaltabs.h socktabs.h socktypetabs.h typetabs.h -noinst_PROGRAMS = gen_captabs_h gen_clock_h gen_clone-flagtabs_h \ - gen_epoll_ctls_h gen_famtabs_h \ - gen_fcntl-cmdtabs_h gen_flagtabs_h \ - gen_icmptypetabs_h gen_ipctabs_h gen_nfprototabs_h \ - gen_mmaptabs_h gen_mounttabs_h \ - gen_open-flagtabs_h gen_persontabs_h gen_prottabs_h \ - gen_recvtabs_h gen_rlimit_h gen_ptracetabs_h \ - gen_signals_h gen_socktabs_h gen_socktypetabs_h gen_typetabs_h - -gen_captabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h captab.h -gen_captabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="captab.h"' + +gen_captabs_h: ../lib/gen_tables.c ../lib/gen_tables.h captab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"captab.h\" \ + -o $@ ../lib/gen_tables.c captabs.h: gen_captabs_h Makefile ./gen_captabs_h --i2s cap > $@ -gen_clock_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h clocktab.h -gen_clock_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="clocktab.h"' +gen_clock_h: ../lib/gen_tables.c ../lib/gen_tables.h clocktab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"clocktab.h\" \ + -o $@ ../lib/gen_tables.c clocktabs.h: gen_clock_h Makefile ./gen_clock_h --i2s clock > $@ -gen_clone_flagtabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h \ - clone-flagtab.h -gen_clone_flagtabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="clone-flagtab.h"' +gen_clone-flagtabs_h: ../lib/gen_tables.c ../lib/gen_tables.h \ + clone-flagtab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) \ + -DTABLE_H=\"clone-flagtab.h\" -o $@ ../lib/gen_tables.c clone-flagtabs.h: gen_clone-flagtabs_h Makefile ./gen_clone-flagtabs_h --i2s-transtab clone_flag > $@ -gen_epoll_ctls_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h epoll_ctl.h -gen_epoll_ctls_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="epoll_ctl.h"' +gen_epoll_ctls_h: ../lib/gen_tables.c ../lib/gen_tables.h epoll_ctl.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"epoll_ctl.h\" \ + -o $@ ../lib/gen_tables.c epoll_ctls.h: gen_epoll_ctls_h Makefile ./gen_epoll_ctls_h --i2s epoll_ctl > $@ -gen_famtabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h famtab.h -gen_famtabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="famtab.h"' +gen_famtabs_h: ../lib/gen_tables.c ../lib/gen_tables.h famtab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"famtab.h\" \ + -o $@ ../lib/gen_tables.c famtabs.h: gen_famtabs_h Makefile ./gen_famtabs_h --i2s fam > $@ -gen_flagtabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h flagtab.h # ../auparse/ is used to avoid using ../lib/flagtab.h -gen_flagtabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="../auparse/flagtab.h"' +gen_flagtabs_h: ../lib/gen_tables.c ../lib/gen_tables.h flagtab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) \ + -DTABLE_H=\"../auparse/flagtab.h\" -o $@ ../lib/gen_tables.c flagtabs.h: gen_flagtabs_h Makefile ./gen_flagtabs_h --i2s-transtab flag > $@ -gen_fcntl_cmdtabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h \ - fcntl-cmdtab.h -gen_fcntl_cmdtabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="fcntl-cmdtab.h"' +gen_fcntl-cmdtabs_h: ../lib/gen_tables.c ../lib/gen_tables.h fcntl-cmdtab.h \ + Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"fcntl-cmdtab.h\" \ + -o $@ ../lib/gen_tables.c fcntl-cmdtabs.h: gen_fcntl-cmdtabs_h Makefile ./gen_fcntl-cmdtabs_h --i2s fcntl > $@ -gen_icmptypetabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h icmptypetab.h -gen_icmptypetabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="icmptypetab.h"' +gen_icmptypetabs_h: ../lib/gen_tables.c ../lib/gen_tables.h icmptypetab.h \ + Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"icmptypetab.h\" \ + -o $@ ../lib/gen_tables.c icmptypetabs.h: gen_icmptypetabs_h Makefile ./gen_icmptypetabs_h --i2s icmptype > $@ -gen_ipctabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h ipctab.h -gen_ipctabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="ipctab.h"' +gen_ipctabs_h: ../lib/gen_tables.c ../lib/gen_tables.h ipctab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"ipctab.h\" \ + -o $@ ../lib/gen_tables.c ipctabs.h: gen_ipctabs_h Makefile ./gen_ipctabs_h --i2s ipc > $@ -gen_mmaptabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h mmaptab.h -gen_mmaptabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="mmaptab.h"' +gen_mmaptabs_h: ../lib/gen_tables.c ../lib/gen_tables.h mmaptab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"mmaptab.h\" \ + -o $@ ../lib/gen_tables.c mmaptabs.h: gen_mmaptabs_h Makefile ./gen_mmaptabs_h --i2s-transtab mmap > $@ -gen_mounttabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h mounttab.h -gen_mounttabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="mounttab.h"' +gen_mounttabs_h: ../lib/gen_tables.c ../lib/gen_tables.h mounttab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"mounttab.h\" \ + -o $@ ../lib/gen_tables.c mounttabs.h: gen_mounttabs_h Makefile ./gen_mounttabs_h --i2s-transtab mount > $@ -gen_nfprototabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h nfprototab.h -gen_nfprototabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="nfprototab.h"' +gen_nfprototabs_h: ../lib/gen_tables.c ../lib/gen_tables.h nfprototab.h \ + Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"nfprototab.h\" \ + -o $@ ../lib/gen_tables.c nfprototabs.h: gen_nfprototabs_h Makefile ./gen_nfprototabs_h --i2s nfproto > $@ -gen_open_flagtabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h \ - open-flagtab.h -gen_open_flagtabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="open-flagtab.h"' +gen_open-flagtabs_h: ../lib/gen_tables.c ../lib/gen_tables.h open-flagtab.h \ + Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"open-flagtab.h\" \ + -o $@ ../lib/gen_tables.c open-flagtabs.h: gen_open-flagtabs_h Makefile ./gen_open-flagtabs_h --i2s-transtab open_flag > $@ -gen_persontabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h persontab.h -gen_persontabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="persontab.h"' +gen_persontabs_h: ../lib/gen_tables.c ../lib/gen_tables.h persontab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"persontab.h\" \ + -o $@ ../lib/gen_tables.c persontabs.h: gen_persontabs_h Makefile ./gen_persontabs_h --i2s person > $@ -gen_ptracetabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h ptracetab.h -gen_ptracetabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="ptracetab.h"' +gen_ptracetabs_h: ../lib/gen_tables.c ../lib/gen_tables.h ptracetab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"ptracetab.h\" \ + -o $@ ../lib/gen_tables.c ptracetabs.h: gen_ptracetabs_h Makefile ./gen_ptracetabs_h --i2s ptrace > $@ -gen_prottabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h prottab.h -gen_prottabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="prottab.h"' +gen_prottabs_h: ../lib/gen_tables.c ../lib/gen_tables.h prottab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"prottab.h\" \ + -o $@ ../lib/gen_tables.c prottabs.h: gen_prottabs_h Makefile ./gen_prottabs_h --i2s-transtab prot > $@ -gen_recvtabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h recvtab.h -gen_recvtabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="recvtab.h"' +gen_recvtabs_h: ../lib/gen_tables.c ../lib/gen_tables.h recvtab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"recvtab.h\" \ + -o $@ ../lib/gen_tables.c recvtabs.h: gen_recvtabs_h Makefile ./gen_recvtabs_h --i2s-transtab recv > $@ -gen_rlimit_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h rlimittab.h -gen_rlimit_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="rlimittab.h"' +gen_rlimit_h: ../lib/gen_tables.c ../lib/gen_tables.h rlimittab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"rlimittab.h\" \ + -o $@ ../lib/gen_tables.c rlimittabs.h: gen_rlimit_h Makefile ./gen_rlimit_h --i2s rlimit > $@ -gen_signals_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h signaltab.h -gen_signals_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="signaltab.h"' +gen_signals_h: ../lib/gen_tables.c ../lib/gen_tables.h signaltab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"signaltab.h\" \ + -o $@ ../lib/gen_tables.c signaltabs.h: gen_signals_h Makefile ./gen_signals_h --i2s signal > $@ -gen_socktabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h socktab.h -gen_socktabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="socktab.h"' +gen_socktabs_h: ../lib/gen_tables.c ../lib/gen_tables.h socktab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"socktab.h\" \ + -o $@ ../lib/gen_tables.c socktabs.h: gen_socktabs_h Makefile ./gen_socktabs_h --i2s sock > $@ -gen_socktypetabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h socktypetab.h -gen_socktypetabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="socktypetab.h"' +gen_socktypetabs_h: ../lib/gen_tables.c ../lib/gen_tables.h socktypetab.h \ + Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"socktypetab.h\" \ + -o $@ ../lib/gen_tables.c socktypetabs.h: gen_socktypetabs_h Makefile ./gen_socktypetabs_h --i2s sock_type > $@ -gen_typetabs_h_SOURCES = ../lib/gen_tables.c ../lib/gen_tables.h typetab.h -gen_typetabs_h_CFLAGS = $(AM_CFLAGS) '-DTABLE_H="typetab.h"' +gen_typetabs_h: ../lib/gen_tables.c ../lib/gen_tables.h typetab.h Makefile + $(CC_FOR_BUILD) $(INCLUDES) $(AM_CFLAGS) -DTABLE_H=\"typetab.h\" \ + -o $@ ../lib/gen_tables.c typetabs.h: gen_typetabs_h Makefile ./gen_typetabs_h --s2i type > $@
autogen.sh +1 -1
@@ -1,5 +1,5 @@ #! /bin/sh set -x -e # --no-recursive is available only in recent autoconf versions -autoreconf -fv --install +autoreconf -fv --install -I m4 mv INSTALL.tmp INSTALL
configure.ac +1 -0
@@ -51,6 +51,7 @@ echo Checking for programs AC_PROG_CC AC_PROG_INSTALL AC_PROG_AWK +AX_CC_FOR_BUILD echo . echo Checking for header files
lib/Makefile.am +48 -43
147 lines not on this page · raw message
m4/ax_cc_for_build.m4 new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 9 lines · George McCollister
I've created a patch against your SVN trunk which uses ax_cc_for_build.m4 to provide
CC_FOR_BUILDwhich is then used in auparse/Makefile.am andlib/Makefile.amto build the utilities that run on the build machine.I was able to use this patch to cross-compile audit for my ARM platform. I'm still in the process of testing audit on the ARM platform.
Comments, questions and critiques welcome.
Well...it breaks the normal build on x86_64:
config.status: creating tools/aulastlog/Makefile
config.status: creating tools/ausyscall/Makefile
config.status: creating tools/auvirt/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
.
Auditd Version: 2.2.2
Target: x86_64-unknown-linux-gnu
Installation prefix: /usr
Compiler: gcc
Compiler flags:
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic+ make -j4
make all-recursive
make[1]: Entering directory `/home/sgrubb/working/BUILD/audit-2.2.2' Making all in lib
make[2]: Entering directory /home/sgrubb/working/BUILD/audit-2.2.2/lib' make[2]: *** No rule to make target gen_tables.c', needed by `gen_actiontabs_h'. Stop.
make[2]: Leaving directory `/home/sgrubb/working/BUILD/audit-2.2.2/lib' make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sgrubb/working/BUILD/audit-2.2.2'
make: *** [all] Error 2
error: Bad exit status from /home/sgrubb/working/tmp/rpm-tmp.XYWHYB (%build)
RPM build errors:
Bad exit status from /home/sgrubb/working/tmp/rpm-tmp.XYWHYB (%build)
Done
Quoted 1 line · Steve Grubb
Well...it breaks the normal build on
x86_64:
Works for me on x86_64. Did you remember to run autogen.sh so configure gets regenerated before running configure? If that doesn't help it would be helpful to get your lib/Makefile so I could analyze it.
Thanks,
George
Quoted 5 lines · George McCollister
Quoted 1 line · Steve Grubb
Well...it breaks the normal build on
x86_64:Works for me on
x86_64. Did you remember to runautogen.shso configure gets regenerated before running configure? If that doesn't help it would be helpful to get your lib/Makefile so I could analyze it.
I have a script that I use for testing all patches wrt the build. It have 2 modes, one that pulls a fresh copy from svn to check for missing files and one that just uses the local svn cache so I can test prior to pushing. It does something like this:
cwd=pwd
mkdir audt
cd audit
cp -r $trunk/* .
./autogen.sh
./configure --with-prelude -with-libwrap
make -j 8 dist
mv audit-$release.tar.gz ~/working/audit/
cd $cwd
rpmbuild -ba ../audit/audit.spec
Its failing under the rpmbuild which does not use the autogen script.
But there is another problem I didn't notice right away...it adds a new file, m4/ax_cc_for_build.m4. In it is this:
+# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version.
The audit package is strictly GPL/LGPL v2.
-Steve
Quoted 1 line · Steve Grubb
The audit package is strictly GPL/LGPL v2.
I'll try to find a different solution.
Regards,
George