delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/09/24/04:07:24

From: vance AT deneb DOT com (Stephen Vance)
Subject: Re: gcc produces foo.exe, not foo
24 Sep 1998 04:07:24 -0700 :
Message-ID: <36090582.6A5A33FD.cygnus.gnu-win32@deneb.com>
References: <Pine DOT HPP DOT 3 DOT 95 DOT 980923002730 DOT 28557A-100000 AT grimer DOT diku DOT dk>
Mime-Version: 1.0
To: Arne Glenstrup <panic AT diku DOT dk>
Cc: gnu-win32 AT cygnus DOT com

Arne Glenstrup wrote:

> Hello,
>
> Apologies if this question has been answered many times before, but I
> didn't seem to be able to find it in the mailing list archives via the
> search function.
>
> The problem is that it seems that when running
>
>   gcc -o foo foo.c
>
> it produces not a file named foo, but a file named foo.exe. This has
> caused me problems when writing a Makefile somewhat like
>
>   bar: foo.c
>           gcc -o foo foo.c
>           mv foo bar
>
> because it complains when trying to mv file foo.
>
> What is the standard way of circumventing this problem? Simply writing
>
>           mv foo.exe bar.exe
>
> is not a full solution, because that is not portable. Is it necessary to
> write some autoconf stuff to check what the extension of the executable
> resulting from calling gcc is?
>
> Thanx,
>
> -- Arne.
>
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request AT cygnus DOT com" with one line of text: "help".

We tend to deal with this in the following way.

1) Define an environment variable to contain some platform identifier (e.g.
ARCH=Cygwin32)
2) Create a file like the following called Cygwin32.mk

OBJ=.obj
EXE=.exe

The Unix equivalent (e.g. Sun5.mk) might be

OBJ=.o
EXE=

3)  Create your makefiles to include the platform makefile and use its
macros.

include $(ARCH).mk

bar$(EXE): foo.c
    gcc -o foo$(EXE) foo.c
    mv foo$(EXE) bar$(EXE)

Obviously, there are improvements to be applied in the use of make, the
$(ARCH).mk files can be put in a central location, you can do similar things
with compiler and linker flags, provide a means for directory-specific
platform settings, etc. to extend this to a full-fledged make environment,
but this is the basic technique.

--
Stephen Vance                           |  http://www.deneb.com
Deneb Robotics, Inc.                    |  mailto:vance AT deneb DOT com
5500 New King Street                    |  Phone: (248) 267-9696
Troy, MI 48098-2615                     |  Fax:   (248) 267-8585

What is done well is done quickly enough. -Augustus Caesar



-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019