Need help with makefile for multiple source files

Panyasantisuk Jarunan Jarunan.Panyasantisuk at eleves.ec-nantes.fr
Thu Jun 4 12:45:15 CDT 2009


Hi,

I did something like this.

RM		 = /bin/rm
MYOBJ            = main.o module.o

include ${PETSC_DIR}/conf/base

test: $(MYOBJS)
	${FLINKER} -o test $(MYOBJS) ${PETSC_KSP_LIB}
	${RM} *.o

.F90.o:
         $(FCOMPILE) -c -o $@ $<

$(MYOBJS): incl.h

include ${PETSC_DIR}/conf/test


good luck
Jarunan

-- 
Jarunan PANYASANTISUK
MSc. in Computational Mechanics
Erasmus Mundus Master Program
Ecole Centrale de Nantes
1, rue de la noë, 44321 NANTES, FRANCE



Randall Mackie <rlmackie862 at gmail.com> a écrit :

> Hi Xiaoyin,
>
> I'm not sure what I do is the most elegant, but it works well for me.
> First, I use a program called makedepf90, which you can find here:
>
> http://personal.inet.fi/private/erikedelmann/makedepf90/
>
> This program was designed for f90 and modules and it creates the
> dependency list you need to compile f90 programs. It puts this
> in a .depend file.
>
> Then, my makefile is simple:
>
>
> ==============================================================================
> # Include the dependency-list created by makedepf90 below
>
> include .depend
>
>
> CFLAGS         =
> FFLAGS         =
> CPPFLAGS         =
> FPPFLAGS         =
>
> include ${PETSC_DIR}/conf/base
>
> csemfwd: ${FOBJ}  chkopts
> 	-${FLINKER} -o csemfwd ${FOBJ} ${PETSC_FORTRAN_LIB} ${PETSC_KSP_LIB}
>
>
> depend .depend:
> 	makedepf90 -o DO_NOT_COMPILE *.f *.F > .depend
>
> ==============================================================================
>
>
> Of course, you can modify this to suit your own needs.
>
>
> Good luck,
>
> Randy M.
>
>
> xiaoyin ji wrote:
>> Hi,
>>
>> I've got a .F90 code using PETSc ksp solver working, and now I'm
>> trying to separate the module (which contains parameter define and
>> PETSc include files) and main program into two .F90 files. I have
>> trouble with the makefile now because I cannot find the example
>> makefile for such purpose, it seems all PETSc example makefiles are
>> for single code only.
>>
>> Thank you very much!
>>
>> Best,
>>
>> Xiaoyin Ji
>>
>> ----------------------------------------------
>>
>> Xiaoyin Ji
>> Graduate Student
>> Department of Materials Science and Engineering
>> North Carolina State University
>





More information about the petsc-users mailing list