- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to set up a makefile to, when compiling each source file,
look through three directories in order, and compile the first version
it finds. The .PATH.c macro shown here
is an example of what I want to do, but that syntax is for Opus make,
and doesn't work for me. I'm using the nmake that came with the Fortran 9.0 compiler (I think this is the Microsoft nmake,
not the ATT or Lucent nmake?). Is there a way to do this in regular make,
or my version of nmake? I've searched through previous questions here, and I've tried to google the answer, but between
the different versions of nmake, and the indecipherable Microsoft MSDN reference site, I'm stumped.
I have the code compiling in the IDE for 32 bit windows, but I need to also compile the code for 64 bit windows, where there are only a few differences. I'd like to make a directory with just the makefile and the code that differs, and have the directories searched in order, e.g. c:maindir64bitcode, c:maindir, c:maindircommon, with the first match found used. There are a lot of source code files, but only a few that need to change for the 64 bit version.
Currently, I'm just copying all the source code to a separate directory, and I have a makefile working that way, but I have to be careful to not overwrite the 64 bit-only source files with changed 32 bit source files.
I have the code compiling in the IDE for 32 bit windows, but I need to also compile the code for 64 bit windows, where there are only a few differences. I'd like to make a directory with just the makefile and the code that differs, and have the directories searched in order, e.g. c:maindir64bitcode, c:maindir, c:maindircommon, with the first match found used. There are a lot of source code files, but only a few that need to change for the 64 bit version.
Currently, I'm just copying all the source code to a separate directory, and I have a makefile working that way, but I have to be careful to not overwrite the 64 bit-only source files with changed 32 bit source files.
Link Copied
10 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A google search for nmake ".PATH." gives this MSDN forum thread, which leads to this MSDN entry. Is that [similar to] what you've been looking for (admittedly I'm not an expert on the issue)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...in other words, a generic solution should look similar to (untested):
INTDIR = .Debug
SRCDIRS = {.64bitcode; .; .common} #Assuming that makefile lies in C:maindirMSG_F90 = echo "Compiling Fortran ($@)"
F90 = ifort
F90_OPTS= /c /debug /O0 /include:$(INTDIR) /module $(INTDIR)
...
$(INTDIR)source1.obj : $(SRCDIRS)source1.f90
@ $(MSG_F90)
@ $(F90) $(F90_OPTS) $(SRCDIRS)source1.f90
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see how that's going to work - the compiler would see a semicolon-separated list for the input file and won't know what to make of it.
What you COULD do is something like this. Have the main source be the following:
INCLUDE 'real_source_1.f90'
Now you can specify a list of folders for /INCLUDE and the compiler will pick the first 'real_source_1.f90' it finds.
What you COULD do is something like this. Have the main source be the following:
INCLUDE 'real_source_1.f90'
Now you can specify a list of folders for /INCLUDE and the compiler will pick the first 'real_source_1.f90' it finds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MADsblionel:
I don't see how that's going to work - the compiler would see a semicolon-separated list for the input file and won't know what to make of it.
It's not just a semicolon-separated list -- the curly braces [are supposed to] make the difference. With the braces, NMAKE should search through the directories in order and substitute the first one which does contain the source file, then give it to the compiler. At least according to [my reading of] MSDN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Jugoslav. I've come across that page, which is part of where the "indecipherable" comment came from. I don't really understand what it means, since the example has zero context. I'm trying your suggestions from your next post, but no luck yet.
Is there any kind of manual for the nmake command, especially for the makefile it uses? The Fortran help in the IDE just gives the command line usage, but doesn't say anything about the format in the makefile. I haven't found anything online specifically for nmake, just other versions of make that don't work the same for this particular problem.
Is there any kind of manual for the nmake command, especially for the makefile it uses? The Fortran help in the IDE just gives the command line usage, but doesn't say anything about the format in the makefile. I haven't found anything online specifically for nmake, just other versions of make that don't work the same for this particular problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(This is reply to Steve Lionel. I thought it would quote him, but it didn't)
Wouldn't I have to do this for every file? Otherwise, if I lumped all the includes into one reallyBigFile.for, every time I changed one one file, wouldn't everything get recompiled to make reallyBigFile.obj?
Wouldn't I have to do this for every file? Otherwise, if I lumped all the includes into one reallyBigFile.for, every time I changed one one file, wouldn't everything get recompiled to make reallyBigFile.obj?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you'd have to do that for every file that was different.
NMAKE is documented as part of Visual Studio. See the MSDN Library documentation.
Have you considered conditional compilation as an alternative?
NMAKE is documented as part of Visual Studio. See the MSDN Library documentation.
Have you considered conditional compilation as an alternative?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
blischke:
Thanks Jugoslav. I've come across that page, which is part of where the "indecipherable" comment came from. I don't really understand what it means, since the example has zero context. I'm trying your suggestions from your next post, but no luck yet.
Yes, the nmake documentation is quite dense. My suggested code doesn't work indeed: while the directories are searched for dependents, ifort gets a wrong command line (as Steve predicted).
I played with inference rules instead (see the samples ), and I managed to get a solution that works; see the attachment. Rather than the mentioned macro, it spells out the inference rules for each folder. Nmake will find the appropriate source file and pass it to the compiler.
Caveat: when Source.f90 exists in several directories, Nmake seems to apply the rules in reverse order, i.e. when inference rule for Folder1 is specified first, it has the lowest search priority. I'm not sure whether you can depend on that though, and whether it's portable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see a lot more usage of gnu make than other brands, even on Windows. I don't entirely sympathize with such a big effort to use a utility which is incompatible with standards (and with supporting software on more than one operating system). I started with another of the commercial make utilities for Windows, but never found sufficient advantages in any non-standard make. My customers haven't found Microsoft more willing to support nmake.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
JugoslavDujic:
I played with inference rules instead (see the samples ), and I managed to get a solution that works; see the attachment. Rather than the mentioned macro, it spells out the inference rules for each folder. Nmake will find the appropriate source file and pass it to the compiler.
Caveat: when Source.f90 exists in several directories, Nmake seems to apply the rules in reverse order, i.e. when inference rule for Folder1 is specified first, it has the lowest search priority. I'm not sure whether you can depend on that though, and whether it's portable.
Excellent! Thank you very much.
So anyone else reading this doesn't have to download JugoslavDujic's attachment (or if it isn't there later), the key is, instead of the rule
.f90{$(INTDIR)}.obj :
$(F90) $(F90_OPTS) $<
use one rule per source folder, (with Folder2 searched before Folder1)
#inference rule for folder1
{.Folder1}.f90{$(INTDIR)}.obj :
$(F90) $(F90_OPTS) $<
#inference rule for folder2
{.Folder2}.f90{$(INTDIR)}.obj :
$(F90) $(F90_OPTS) $<
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page