How to convert a line in Makefile to MSVC project's setting

F

fl

Hi,
I get a C program on the web, which is originally under unix OS. I
would like to run it on Windows. The last line in the Makefile is an
argument setting. How to add the same functionality in MSVC project? I
guess I can do it in one line of #define. But I am puzzled on the
Makefile grammar: RAND_FILE is randfile (There is a 'randfile' in the
folder, or rand.c (There is a rand.c file there too). Could you
explain it to me? Thanks.


............................
modules:
$(COMPILE) rcode.c
$(COMPILE) distrib.c
$(COMPILE) -DRAND_FILE=\"`pwd`/randfile\" rand.c
 
J

Jens Thoms Toerring

fl said:
I get a C program on the web, which is originally under unix OS. I
would like to run it on Windows. The last line in the Makefile is an
argument setting. How to add the same functionality in MSVC project? I
guess I can do it in one line of #define. But I am puzzled on the
Makefile grammar: RAND_FILE is randfile (There is a 'randfile' in the
folder, or rand.c (There is a rand.c file there too). Could you
explain it to me? Thanks.
...........................
modules:
$(COMPILE) rcode.c
$(COMPILE) distrib.c
$(COMPILE) -DRAND_FILE=\"`pwd`/randfile\" rand.c

This defines a macro with the name 'RAND_FILE', setting it to
the string consisting of the (absolute path of the) current di-
rectory (i.e. the directory the make command was started in) and
the file name 'randfile' in that directory (the stuff within
backticks tells the shell the make file is run under to execute
the command 'pwd' - which returns the current directory - and
to insert the output of that command).

I have no ideawhat this is supposed to be good for and can only
suspect that it is meant to get at the name of a certain file -
rather likely a file named 'randfile' in the source directory
(unfortunatley, this isn't a very clever idea if that file is
needed by the program to be compiled when run since this will
break if the source directory doesn't exist anymore at the place
were the compilation happend).

The simplest fix is probably to add a line to the start of
rand.c with

#define RAND_FILE "c:whereever/the/sources/are/randfile"

or in the Makefile use

$(COMPILE) -DRAND_FILE=\"c:whereever/the/sources/are/randfile\" rand.c

Regards, Jens
 
8

88888 Dihedral

This defines a macro with the name 'RAND_FILE', setting it to
the string consisting of the (absolute path of the) current di-
rectory (i.e. the directory the make command was started in) and
the file name 'randfile' in that directory (the stuff within
backticks tells the shell the make file is run under to execute
the command 'pwd' - which returns the current directory - and
to insert the output of that command).

I have no ideawhat this is supposed to be good for and can only
suspect that it is meant to get at the name of a certain file -
rather likely a file named 'randfile' in the source directory
(unfortunatley, this isn't a very clever idea if that file is
needed by the program to be compiled when run since this will
break if the source directory doesn't exist anymore at the place
were the compilation happend).

The simplest fix is probably to add a line to the start of
rand.c with

#define RAND_FILE "c:whereever/the/sources/are/randfile"

or in the Makefile use

$(COMPILE) -DRAND_FILE=\"c:whereever/the/sources/are/randfile\" rand.c

Regards, Jens

Nowadays it is trivial to run co-linux under Windows and
to run Windows AP under Winehq http://www.winehq.org/ under unix or linux.

Does that mean those syntax differences in compilers matter too
much or too trivial at all for professional programmers?
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top