Makefile question

C

Carson

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
 
R

Rouben Rostamian

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Makefile with source code in 2 directory 5
Makefile doesn't detect header file change 5
Question about makefile 5
Makefile Linux 24
Makefile 2
[OT] Makefile 4
makefile variable 1
Makefile Help 5

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top