0

I am working on an automatic build and continuous integration environment for embedded C codebase. I am using Keil's Real View Compiler (windows executable) as the cross compiler, and am building the entire continuous integration environment using Cygwin.

Keil's documentation says if using Cygwin, one has to set CYGPATH environment variable appropriately for the the compiler (i.e. the windows executable) to understand the Cygwin paths for stuff like include files. (http://www.keil.com/support/man/docs/ARMINTRO/armintro_pge1362395716635.htm)

The makefile looks something like this:

INCLUDE_DIR=-I$(PATH_TO_KEIL)/MDK-Middleware \
            -I$(PATH_TO_KEIL)/ARM 


a.o : a.c
    echo
    echo Compiling $<....;
    echo cc -c $(INCLUDE_DIR) -o a.o a.c ;
    cc -c $(INCLUDE_DIR) -o a.o  a.c ;

When I execute $cc -c -I/cygdrive/c/Keil_v5/MDK-Middleware -I/cygdrive/c/Keil_v5/ARM -o a.o a.c directly on the Cygwin terminal, the cross compilation takes place successfully.

However, despite defining PATH_TO_KEIL as /cygdrive/c/Keil_v5 ,when running the makefile compiler complains that it cannot find the include file.(i.e.the one present in /cygdrive/c/Keil_v5/ARM or C:\Keil_v5)

Also, if it helps, I have no problems running cross compiling if I give the relative path of the include file.

adkaizer7
  • 41
  • 3
  • Where your include dir is located ???? Inside cygwin directory ??? – Oleg Gopkolov Sep 28 '15 at 18:43
  • The include files and directory are inside a separate folder where the Keil toolchain is installed. This might be in different locations for different people depending on how and where they installed the Keil MDK. – adkaizer7 Sep 28 '15 at 18:53
  • Please, put here exact path you use – Oleg Gopkolov Sep 28 '15 at 20:07
  • I have corrected answer. See it. – Oleg Gopkolov Sep 28 '15 at 20:35
  • `$cc -c -I/cygwin/c/Keil_v5/MDK-Middleware -I/cygwin/c/Keil_v5/ARM -o a.o a.c` this don't like for me................Change `cygwin` to `cygdrive` – Oleg Gopkolov Sep 28 '15 at 20:49
  • Oleg, please see the edited question. The point is, when typed directly on the terminal, the compiler runs without any error. However, when run through the make file, the compiler cannot find the necessary header files – adkaizer7 Sep 28 '15 at 22:06
  • Maybe it's just a typo, but your recipe in the example makefile has `cc -c $(INCLUDE_DIR) ...`. Using make variables greater than one character in length need to have `()` around them, so `$(CC)` – Russ Schultz Sep 29 '15 at 03:02
  • Next, add `$(info CYGPATH=$(CYGPATH))` somewhere in your make file to see what the make environment thinks that variable is. – Russ Schultz Sep 29 '15 at 03:04
  • Finally, make a batch wrapper (or tcl, or whatever you want) for the keil compiler that prints out the value of the `CYGPATH` system variable prior to invoking the compiler with the right args. See where this path is breaking down. – Russ Schultz Sep 29 '15 at 03:05
  • Well, actually, finally, (or maybe firstly) avoid cygwin. It's always the root of all obscure make and build incompatibilities. We've actually banned cygwin in our shop because of all the time wasted trying to resolve oddities like this. – Russ Schultz Sep 29 '15 at 03:08
  • @adkaizer7 You invoke `make` from cygwin console or from windows console – Oleg Gopkolov Sep 29 '15 at 04:42
  • @adkaizer7 Where are you ??? What's up with your problem ???? – Oleg Gopkolov Sep 29 '15 at 18:39
  • @OlegGopkolov, I was not able to solve the problem. The cross compilation errs only when being executed through the makefile and only when absolute paths are mentioned. So I wrote a wrapper python script to convert the absolute path to relative paths and then pass that to my makefile. – adkaizer7 Oct 07 '15 at 21:33

1 Answers1

0

You must declare var in the Makefile which will point to your include dir. For example,

INCLUDE_DIR = c:/path/to/include/ and hence your makefile target will be:

$armcc.exe -I$(INCLUDE_DIR) foo.c

Oleg Gopkolov
  • 1,684
  • 10
  • 17
  • That's how my makefile is structured. It doesn't seem to work. – adkaizer7 Sep 28 '15 at 19:34
  • Why you have written `$armcc.exe -I/cygdrive/c/path/to/include/file foo.c` ?????? – Oleg Gopkolov Sep 28 '15 at 19:41
  • @adkaizer7 with `-I` option you say to compiler `where your DIR with include files is located` . You don't need to write `file` in this option. Your makefile string must be `$armcc.exe -I$(INCLUDE_DIR) foo.c` – Oleg Gopkolov Sep 28 '15 at 19:54
  • I apologize if that was confusing. I have edited the question to reflect the change. I have included my makefile in the question to lend more clarity. – adkaizer7 Sep 28 '15 at 20:22
  • Make should import any system variables and expose them as make variables, so you don't need to explicitly set these inside the makefile. – Russ Schultz Sep 29 '15 at 02:56
  • @adkaizer7 All works for me. Try slash (symbol "/" ) instead of backslash ( symbol "\") in the path and move to Windows path................ Look , must be `INCLUDE_DIR = c:/path/to/include/` – Oleg Gopkolov Sep 29 '15 at 05:10