Re: Script to compile all files with a given extension?



Dances With Crows <danSPANceswithTRAPcrows@xxxxxxxxx> writes:

sk8terg1rl staggered into the Black Sun and said:
On Jun 29, 11:39 pm, The Natural Philosopher <a...@xxx> wrote:
sk8terg1rl wrote:
Quite often I move source code between CPU architectures and need to
recompile it. Since discovering the joys of bootstrapping my
programs, I no longer have one big program but many smaller
interconnected ones.

Identify all the files with .for and .f90 extensions
Execute the commands:
'ifort program.for -o program'
'ifort program2.f90 -o program2'
Write a Makefile and use make?
Found out what make does with man make just now ;-) Unfortunately I
don't think this would help much. Depending on the purpose of the
programs, they have different names. This would mean I would need a
makefile for each subset of programs.

Makefiles can have multiple dependencies and action lines. Like so:

OBJS=crud.o barf.o junk.o
SRCS=crud.c barf.c junk.c

See my other post.

The last 2 lines above come from trying to
create a lowest common denominator makefile.
Since we're talking GNUMAKE here,

Once you have $(SRC)
$(OBJS) is simply:

OBJS:=$(subst .c,.o,$(SRC))

HDRS=thing.h

all: $(OBJS) $(HDRS)
$(CC) $(CFLAGS) -o program $(OBJS)
OBJS: $(SRCS) $(HDRS)
$(CC) $(CFLAGS) -c $*.c

"all" seems to be missing the target "program".

This assumes 1 program and many subs.
I prefer something like:

SRCS:=$(wildcard *.c)
MAINS:=program.c program2.c
SUBS:=$(filter-out $(MAINS),$(SRCS))

Then you need specific rules for the mains
and generic rules for the subs.

Separating the list of subs into a list for
each main can mean that you have to revert to
specific lists.
.



Relevant Pages

  • Re: Script to compile all files with a given extension?
    ... Write a Makefile and use make? ... all: $(OBJS) $ ... This assumes 1 program and many subs. ... specific lists. ...
    (comp.os.linux.misc)
  • Re: Makefile and $(addprefix) SOLVED
    ... I'm trying to use $build lists of source files and ... object files containing the relative paths for each. ... I've fixed my Makefile. ...
    (freebsd-questions)
  • Re: order of building .f90 files
    ... fortran files ... > have to be built in order. ... > in a makefile that figures this out. ... program for automatic creation of Makefile dependency lists for Fortran ...
    (comp.lang.fortran)
  • Re: Dead-module etiquette
    ... then lists that module as a prerequisite in the README / Makefile? ... Saskatchewan Government Insurance ...
    (perl.beginners)
  • Re: error message with hello.exe
    ... When I start the program with the Windows Vista execute prompt I get a console box for the program without "Hello" ... jacob at jacob point remcomp point fr ... On linking I get an errormessage Circular dependency from Makefile. ... $: $(OBJS) Makefile ...
    (comp.compilers.lcc)