How this works.
It is very simple you just have to specify input and output files and actions which should be performed to obtain the output. Schematically it looks like this:
resultfile(s): inputfile(s)
action
Note that the tabs are important.
Also you can specify ierarchical dependance, I like this feature very much:
...
result2 : result1
action2
result : result1
action1
all : result
Here is the example Makefile that I've created for that project.
##############Makefile
#set variables, compilers, libs, and others if you'll need them
CXX = pgCC
FC = pgf90
CXXFLAGS = -O2 -g -c
FCFLAGS = -i8 -r8 -byteswapio -c
OBJS = meshrouteX11.o readccc.o
CFILES = meshrouteX11.cpp
FORTRANFILES = readccc.f90
LIBS = -lg2c -pgf90libs $(CLIMLIB)/lib/losub.a -lm
TARGET = meshroute.exe
#create object files
$(OBJS): $(CFILES) $(FORTRANFILES)
$(CXX) $(CXXFLAGS) $(CFILES)
$(FC) $(FCFLAGS) $(FORTRANFILES)
#resultfile: inputfile
# action
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
Another simple example of the Makefile
##############Makefile
FC = gfortran
*.o : *.f90
$(FC) -c *.f90
all : *.o
$(FC) *.o -o demo.exe
clean:
rm -rf *.exe
rm -rf *.o
No comments:
Post a Comment