makefile (example)

This script removes old Fortran files and recompiles them:

#PROJ = project

#OBJS = test.o
FC = g77
FFLAGS = -O2 -malign-double #-march=prescott -mtune=generic #-mfpmath=sse

all: remove caffauns grid plot

caffauns:
    $(FC) $(FFLAGS) caffauns.f -o caffauns.out

grid:
    $(FC) $(FFLAGS) grid.f -o grid.out

plot:
    $(FC) $(FFLAGS) plot.f -o plot.out

remove:
    rm -f *.out *.o

Type makeall, makegrid, etc.

Here is an even more dynamic Makefile:

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp hello.cpp factorial.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS) 
    $(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
    $(CC) $(CFLAGS) $< -o $@
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License