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

Discussion in 'C Programming' started by fl, Dec 24, 2011.

  1. fl

    fl Guest

    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
    fl, Dec 24, 2011
    #1
    1. Advertising

  2. fl <> wrote:
    > 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
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Dec 24, 2011
    #2
    1. Advertising

  3. On Saturday, December 24, 2011 10:13:25 PM UTC+8, Jens Thoms Toerring wrote:
    > fl <> wrote:
    > > 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
    > --
    > \ Jens Thoms Toerring ___
    > \__________________________ http://toerring.de


    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?
    88888 Dihedral, Dec 24, 2011
    #3
    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. Dave
    Replies:
    9
    Views:
    16,694
    RichardShepherd
    Jan 1, 2012
  2. Replies:
    3
    Views:
    920
    Nick Vargish
    Apr 20, 2005
  3. Replies:
    5
    Views:
    505
    Inyeol Lee
    Dec 3, 2005
  4. Dave
    Replies:
    7
    Views:
    525
    Phlip
    Aug 10, 2004
  5. Ben Giddings

    Embedded Ruby in a MSVC++ project?

    Ben Giddings, Sep 18, 2003, in forum: Ruby
    Replies:
    0
    Views:
    105
    Ben Giddings
    Sep 18, 2003
Loading...

Share This Page