Silverfrost Forums

Welcome to our forums

Pre-Processing source files via Makefile

13 Jun 2013 8:58 #12384

Hello,

in a current project, I have two groups of source files:

  • Group A files must be pre-processed with an external preprocessor before being compiled and linked.
  • Group B files will be compiled and linked just like normal.

It is important, however, to save the pre-processed files under new filenames, as the original files must be kept.

So, for a single Group A file arclen.for, I would do:

fcomp = c:\\Program Files (x86)\\FTN95\\ftn95
fpp = c:\\Program Files (x86)\\Intel\\Compiler\\11.1\\065\\bin\\intel64\\fpp

arclen__PP.for : arclen.for
			$(fpp) $(fppargs) /P arclen.for arclen__PP.for

arclen__PP.obj : arclen__PP.for
		  $(fcomp) arclen__PP.for $(fd)

with fppargs, fd being some fixed parameters for compiler/preprocessor.

But since I need many Group A files to be pre-processed, I would need an automated way to specify input and output filenames for the preprocessor and hand them on to the compiler.

I tried doing things such as

ppedfiles : $(ppfiles)
			  $(foreach file,$(ppfiles),$(fpp) $(fppargs)	/P $(file) $(file)__PP)

but it didn't work.

I'm new to makefiles so I'd gladly appreciate some help.

*** Note: I know that ftn95 can pre-process, too (/CFPP), but it doesn't support all the options I need.

To be more specific, I need to handle

#ifdef __INTEL_
#define dot(a,b,n) ddot(n,a,1,b,1)
#endif

in a number of source files, but the Ftn95 pre-processor doesn't like the second line of this, even if the whole block should be omitted anyway, as it is only relevant when using the Intel compiler.

13 Jun 2013 12:20 #12385

I doubt if I can help but which MAKE utility are you using, Silverfrost MK32 or something else?

13 Jun 2013 4:04 #12393

Yes, I'm using Mk32.

13 Jun 2013 4:26 #12397

OK. What MK32 instruction did you try, what did it aim to do and what was the failure message?

14 Jun 2013 8:29 #12407

Okay, so the first thing I need to do is specify filenames for in- and output for the preprocessor.

ppfiles = arclen.for dynamics.for ext.for [...]

Now for each file in ppfiles, the preprocessor fpp must generate an output file $(name)__PP.for.

ppedfiles = $(ppfiles:.for=__PP.for)

However, this doesn't seem to work:

all : $(ppfiles)
		@echo $(ppedfiles)

yields the following output ... $(ppedfiles) seems to be empty.

Now for each file in ppfiles, the preprocessor fpp must generate an output file $(name)__PP.for.

ppedfiles = $(ppfiles:.for=__PP.for)

However, this doesn't seem to work:

all : $(ppfiles)
  	@echo $(ppedfiles)

yields the following output ... $(ppedfiles) seems to be empty. [quote:d0479b6e93][Salford MK/Win32 Version 3.89, Copyright (c) Silverfrost Ltd. 1996-2006] ECHO ist eingeschaltet (ON).

I tried it in a different way, $(fpp) and $(fppargs) being path and parameters for the preprocessor, so my full makefile would be this:

fpp = c:\\Program Files (x86)\\Intel\\Compiler\\11.1\\065\\bin\\intel64\\fpp
fppargs= /D__SALFORD_

ppfiles = arclen.for

all : $(ppfiles)
    $(foreach file,$(ppfiles),$(fpp) $(fppargs)	/P $(file) $(file)__PP)

In this case, Mk32 displays its startup message and then just freezes.

14 Jun 2013 2:18 #12410

It is a long time since I did much with MAKEFILEs but I offer the following comments

  1. 'all' and 'foreach' will not be recognised by MK32 unless you define them.

  2. The 'ECHO' in the failure report will be generated by a batch file.

Please login to reply.