Makefile question

Discussion in 'C Programming' started by Carson, Jul 4, 2005.

  1. Carson

    Carson Guest

    Hi,

    I have a problem with Makefile.

    I have a piece of c code, which is stored in my unix account. I wrote
    a Makefile for that particular compilation (using gcc), and it works
    fine.

    But sometimes, I need to compile the code in windows, therefore I
    downloaded mingw32 to compile the code. However, I need to manually
    change the variable of CC in my makefile from CC=gcc to CC=ming32-gcc.

    Is there any way for the Makefile to detect which OS it is
    (win/linux/sunos) so that it will switch the CC accordingly?

    Thank you,

    Carson
    Carson, Jul 4, 2005
    #1
    1. Advertising

  2. In article <>,
    Carson <> wrote:
    >
    > I have a piece of c code, which is stored in my unix account. I wrote
    >a Makefile for that particular compilation (using gcc), and it works
    >fine.
    >
    > But sometimes, I need to compile the code in windows, therefore I
    >downloaded mingw32 to compile the code. However, I need to manually
    >change the variable of CC in my makefile from CC=gcc to CC=ming32-gcc.
    >
    > Is there any way for the Makefile to detect which OS it is
    >(win/linux/sunos) so that it will switch the CC accordingly?


    This is not really a C question. You may get better advice
    in comp.unix.programmer and in a Microsoft-related group
    for Windows.

    <OFF TOPIC>

    Here is an off-topic answer to get you going, but consult
    those other groups if you need further help.

    "make" recognizes the environment variables CC and CFLAGS.
    Therefore don't define then within the Makefile; define them
    as environment variables.

    Alternatively, you may specify them on the command
    line, as in "make CC=gcc CFLAGS=-Wall".

    With GNU make, the "ifeq" conditional may be of some use.
    Look up the manual.

    </OFF TOPIC>

    --
    Rouben Rostamian
    Rouben Rostamian, Jul 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Pieroth

    Makefile question

    Matthias Pieroth, Mar 4, 2004, in forum: C++
    Replies:
    3
    Views:
    331
    Jorge Rivera
    Mar 5, 2004
  2. jose luis fernandez diaz

    Question about simple gmake Makefile

    jose luis fernandez diaz, Apr 29, 2004, in forum: C++
    Replies:
    1
    Views:
    1,272
    Christopher Benson-Manica
    Apr 29, 2004
  3. Dan Bishop

    Python in Makefile Question

    Dan Bishop, Feb 11, 2005, in forum: Python
    Replies:
    4
    Views:
    485
    Bart van Deenen
    Feb 11, 2005
  4. Replies:
    2
    Views:
    300
  5. xz

    Makefile question.

    xz, Jan 9, 2008, in forum: C++
    Replies:
    8
    Views:
    373
    Victor Bazarov
    Jan 14, 2008
Loading...

Share This Page