Stuff for Windows cross compilation.
authorCameron Ball <c.ball1729@gmail.com>
Tue, 31 Mar 2015 15:57:29 +0000 (23:57 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Tue, 31 Mar 2015 15:57:29 +0000 (23:57 +0800)
Makefile
README.md
lib/inih/Makefile

index 4b4056a..03a2b12 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,15 @@
 GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags)
-CC = gcc -Wall -DVERSION=\"$(GIT_VERSION)\"
 lib_inih := lib/inih
 libs := $(lib_inih)
 
+ifeq ($(OS),Windows_NT)
+       CC = arm-linux-gnueabihf-gcc -Wall -IC:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\include -DVERSION=\"$(GIT_VERSION)\"
+    recursive_clean = for /D %%d in ($(libs)) do make --directory=%%d clean
+else
+       CC = gcc -Wall -DVERSION=\"$(GIT_VERSION)\"
+    recursive_clean = for d in $(libs); do make --directory=$$d clean; done
+endif
+
 all: hdmi-switcher
 
 hdmi-switcher: main.o config.o
@@ -19,4 +26,4 @@ inih:
 
 clean:
        rm -f *.o *.bak *.out ex
-       for d in $(libs); do make --directory=$$d clean; done
+       $(recursive_clean)
\ No newline at end of file
index 46701d5..e1933c3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,6 +3,16 @@ Setting Up
 - Install WiringPi. Easy instructions here http://wiringpi.com/download-and-install/
 - That's it at this stage. The makefile takes care of the rest.
 
+Cross Compiling on Windows
+==========================
+I am no expert on this but the following seems to work:
+
+- Download the tool chain here: http://gnutoolchains.com/raspberry/ (I used 4.6.3 universal, which requires a sysroot sync)
+- Do the sysroot sync (http://gnutoolchains.com/raspberry/tutorial/sysroot)
+- After the tool chain has synced, use mingw to run make and it should compile (I used git bash).
+
+NB: When syncing the sysroot, make sure WiringPi is installed on the Pi, otherwise the sysroot on Windows won't have it and compilation will fail.
+
 Running
 ======
 The pin numbers can be confusing. If you hold the Pi such that the GPIO header is on the *RIGHT* hand side of the board, the top left pin is refered to as pin 1, the pin directly to the right of it is pin 2. The pins continue to be named in this fashion.
index 15cf583..e112082 100644 (file)
@@ -1,4 +1,8 @@
-CC = gcc -Wall
+ifeq ($(OS),Windows_NT)
+    CC = arm-linux-gnueabihf-gcc -Wall
+else
+    CC = gcc -Wall
+endif
 
 all: ini.c ini.h
        $(CC) -O -c ini.c