Sponsored Content
Full Discussion: Problem running a makefile
Top Forums Programming Problem running a makefile Post 302755829 by kristinu on Monday 14th of January 2013 04:57:37 PM
Old 01-14-2013
I have now changed things a little bit

Top directory has

Code:
BUILD_DIR  documents  examples  Makefile  README  sources

The makefile is updated to this

Code:
# Source directory
fd_prgdir = ./sources/programs
fd_libdir = ./sources/library/fd
plot_libdir = ./sources/library/pltlib

# Include directory
 fd_incdir = ./sources/library/fd/include/

# Object directory
obj_dir = ./BUILD_DIR/obj

# Program directory
bin_dir = ./BUILD_DIR/bin

# Set Fortran compiler
fortran_compiler = gfortran

# Set Fortran compiler options
fortran_compiler_opts = -O -Wall -fbacktrace -fno-align-commons -I./sources/library/fd/include -c -o

# Source files
sources = $(fd_prgdir)/fd.f \
    $(fd_libdir)/model.f \
    $(fd_libdir)/time.f \
    $(fd_libdir)/findiff.f \
    $(fd_libdir)/findiff2d.f \
    $(fd_libdir)/stencils.f \
    $(fd_libdir)/stencils2d.f \
    $(fd_libdir)/misc.f \
    $(fd_libdir)/plt.f \
    $(fd_libdir)/blkdat.f \
    $(plot_libdir)/nopltlib.f

includes = $(fd_incdir)/fd.par \
    $(fd_incdir)/fd.com \

# Object files
objects= $(obj_dir)/fd.o \
    $(obj_dir)/model.o \
    $(obj_dir)/time.o \
    $(obj_dir)/findiff.o  \
    $(obj_dir)/findiff2d.o \
    $(obj_dir)/stencils.o \
    $(obj_dir)/stencils2d.o \
    $(obj_dir)/misc.o \
    $(obj_dir)/plt.o \
    $(obj_dir)/blkdat.o \
    $(obj_dir)/nopltlib.o

nfd: fd
fd: $(objects)
    $(fortran_compiler) -o test $(objects)
    mv test $(prog_dir)

# Rule for generating the .o file by compiling the .f file using the fortran compiler
%.o: %.f $(includes)
    $(fortran_compiler) $(fortran_compiler_opts) $(sources)

Contents of sources is

Code:
tree sources/
sources/
├── library
│   ├── fd
│   │   ├── blkdat.f
│   │   ├── findiff2d.f
│   │   ├── findiff.f
│   │   ├── include
│   │   │   ├── fd.com
│   │   │   └── fd.par
│   │   ├── misc.f
│   │   ├── model.f
│   │   ├── plt.f
│   │   ├── stencils2d.f
│   │   ├── stencils.f
│   │   └── time.f
│   └── pltlib
│       ├── colors
│       ├── nopltlib.f
│       ├── pltsub.f
│       ├── xbuplot.c
│       ├── xbuplot_icon
│       └── xpltlib.f
└── programs
    ├── fd.f
    ├── ray.f
    └── zslice.f

Contents of BUILD_DIR is

Code:
tree BUILD_DIR
BUILD_DIR
├── bin
└── obj

---------- Post updated at 02:32 PM ---------- Previous update was at 01:29 PM ----------

---------- Post updated at 04:57 PM ---------- Previous update was at 02:32 PM ----------

I can now compile. However the object file ase created in the local directory rather than sent to ./BUILD_DIR/obj

Code:
# Source code paths

PRGDIR = ./sources/programs
FDLIBDIR = ./sources/library/fd
PLOTLIBDIR = ./sources/library/pltlib

INCDIR = ./sources/library/fd/include/
OBJDIR = ./BUILD_DIR/obj
BINDIR = ./BUILD_DIR/bin

# Set Fortran compiler
fortran_compiler = gfortran

# Set Fortran compiler options
compile_opts = -O -Wall -fbacktrace -fno-align-commons -I./sources/library/fd/include

# Set Fortran compiler options
linking_opts = -O -Wall -fbacktrace -fno-align-commons -I./sources/library/fd/include

# Source files

FDPRG_SRC = $(PRGDIR)/fd.f

FDLIB_SRC = $(FDLIBDIR)/model.f \
    $(FDLIBDIR)/time.f \
    $(FDLIBDIR)/findiff.f \
    $(FDLIBDIR)/findiff2d.f \
    $(FDLIBDIR)/stencils.f \
    $(FDLIBDIR)/stencils2d.f \
    $(FDLIBDIR)/misc.f \
    $(FDLIBDIR)/plt.f \
    $(FDLIBDIR)/blkdat.f

PLOTLIB_SRC = $(PLOTLIBDIR)/nopltlib.f

INCLIB_SRC = $(INCDIR)/fd.par \
    $(INCDIR)/fd.com

# Object files

FDPRG_OBJ = $(OBJDIR)/fd.o

FDLIB_OBJ = $(OBJDIR)/model.o \
    $(OBJDIR)/time.o \
    $(OBJDIR)/findiff.o  \
    $(OBJDIR)/findiff2d.o \
    $(OBJDIR)/stencils.o \
    $(OBJDIR)/stencils2d.o \
    $(OBJDIR)/misc.o \
    $(OBJDIR)/plt.o \
    $(OBJDIR)/blkdat.o

PLOTLIB_OBJ = $(OBJDIR)/nopltlib.o

ALL_OBJ = $(FDPRG_OBJ) $(FDLIB_OBJ) $(PLOTLIB_OBJ) 

# Program name
PROG = $(BINDIR)/fdtest

nfd : $(ALL_OBJ) $(INCLIB_SRC)
    $(fortran_compiler) $(linking_opts) $(ALL_OBJ) -o $(PROG)

# Compiling main program
$(FDPRG_OBJ) : $(FDPRG_SRC) $(INCLIB_SRC)
    $(fortran_compiler) $(compile_opts) -c $(FDPRG_SRC)

# Compiling FD Library
$(FDLIB_OBJ) : $(FDLIB_SRC) $(INCLIB_SRC)
    $(fortran_compiler) $(compile_opts) -c $(FDLIB_SRC) 

# Compiling PLOT Library
$(PLOTLIB_OBJ) : $(PLOTLIB_SRC) $(INCLIB_SRC)
    $(fortran_compiler) $(compile_opts) -c $(PLOTLIB_SRC)

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

problem with Makefile

Hi, I have a makefile which looks like this ProcessA : commands touch pro1 ProcessB : pro1 commands touch pro2 ProcessC: pro3 commands and after some runs, i wish only pro3 to run and I check that "pro1" and "pro2" are there in the directory, but still, if i give make... (3 Replies)
Discussion started by: sskb
3 Replies

2. Programming

Problem with a Makefile

Hi, I am very new with makefile topics , maybe this is a very symple question... I have this code wich compile very good ( I get it from the net), I will call it code A. I have to add it with a program that is all ready in use, (code B) that also compile good. When I put together it doesnt... (7 Replies)
Discussion started by: pmoren
7 Replies

3. Programming

Problem with makefile

My make file is CFLAGS = -Wall -g LDFLAGS = -lm CC = g++ all: server client rc4.o: rc4.cpp rc4.h ${CC} ${CFLAGS} -c rc4.cpp server.o: server.cpp rc4.h ${CC} ${CFLAGS} -c .cpp client.o: client.cpp rc4.h ${CC} ${CFLAGS} -c client.cpp server: server.o... (2 Replies)
Discussion started by: neerajgoyal12
2 Replies

4. UNIX for Dummies Questions & Answers

error while running a makefile

any good website to know about makefiles (3 Replies)
Discussion started by: raviravula
3 Replies

5. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

6. Programming

please help me with this big makefile problem

I need to create an executable with these two makefiles(they both have libaries i need(qt and ruby)) i have extconf.rb gui.ui gui_include.h main.cpp ScaleIM_client.rb ui_gui.h i want to combine them all into one executable please!... (2 Replies)
Discussion started by: gjgfuj
2 Replies

7. Programming

Problem with Makefile

Hi, Here is my makefile http://pastie.org/1104332. I am trying to compile different .c files and .s files (assembly files) from different sub directories into E:/em35x/build/mfg-sample-app-cortexm3-iar-em357-em3xx-dev0680/ then the linker should link all the .o files from the build directory... (1 Reply)
Discussion started by: blade2008
1 Replies

8. Emergency UNIX and Linux Support

Problem With Makefile

I had created a Makefile for my project. my project file hierarchy is like this: 1. a source folder with main.c and Makefile in it 2. and a top level Makefile here is the Makefile in src folder all: program program: main.c gcc -o program main.c clean: rm programand here is top... (3 Replies)
Discussion started by: majid.merkava
3 Replies

9. Programming

Problem creating a makefile

hello, I'm trying to create a makefile to run multiple c files. I am able to run one c file only with the code I have when I tried to run 2 or more c files I'm not able. here is my code # $Source: /home/hectormasencio/make/Makefile,v $ # $Date: 2012/11/27 11:35:30 $ CC= gcc OBJS= temp.o... (3 Replies)
Discussion started by: Hector M.
3 Replies

10. UNIX for Beginners Questions & Answers

Help running a Makefile from within a .sh script?

Hi there! I am a undergraduate student and recently submitted an assignment for my coursework - however there was one function I could not get to work properly before the due date. Although I don't need to complete this work anymore I would still like to in order to know what was going wrong. If... (11 Replies)
Discussion started by: cherryTango
11 Replies
All times are GMT -4. The time now is 10:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy