| Hi All, 
 I recently cross-compiled Mosquitto 1.3 for an embedded ARM/Linux
    board, and although it wasn't too difficult, it did require a
    modification to the Makfiles to do an "install," and it might be
    nice to update the build files to make the process easier.
 
 Cross-compiling the binaries was easy. It just required setting all
    of the variables for the build tools. Assuming a cross-compiler
    prefix of "arm-linux-" I did this:
 
 
      
      $ make CC=arm-linux-gcc CXX=arm-linux-g++ \That worked great. Then I tried to install the binaries to a staging
    directory, but the build uses the install "-s" switch to strip the
    binaries of debug symbols. This is the desired behavior, but, by
    default, it uses the native (x86) strip program. We need the one
    from the cross compiler. So I did a global search/replace in all the
    Makefiles of "$(INSTALL) -s" with:AR=arm-linux-ar LD=arm-linux-ld
 
 
 
      
      $(INSTALL) -s --strip-program=$(STRIP)And then I did the install with:
 
 
      
      
       $ make STRIP=arm-linux-strip DESTDIR=$PWD/_install
        install And that put all the cross-compiled binaries into ./_install, which
    I then copied onto the board.
 
 So anyway, I was thinking that it might be kind of nice to have a
    "CROSS_COMPILE" variable in the config.mk to automate this. Perhaps,
    like with the Linux kernel, just set this to the GCC prefix, and
    have the tool variables set automatically. Maybe it can be added
    this to config.mk like:
 
 # Uncomment to cross-compile the broker. That could then be used to set the variables:# Set to the proper compiler prefix for the target board.
 #CROSS_COMPILE:=arm-linux-
 
 
 CC=$(CROSS_COMPILE)gccAnd  then, maybe to prevent someone from accidentally installing
    cross-compiled binaries onto their host, also update the DESTDIR to
    something local, perhaps using the compiler prefix to come up with a
    staging directory name:CXX=$(CROSS_COMPILE)g++
 AR=$(CROSS_COMPILE)ar
 LD=$(CROSS_COMPILE)ld
 STRIP-$(CROSS_COMPILE)strip
 
 
 ifdef CROSS_COMPILEThanks,DESTDIR ?= $(PWD)/$(CROSS_COMPILE)build
 endif
 
 
 Frank
 
 
 
 |