%.o : %.f90
	@printf "\nGenerate $*.o from $<\n"
	ifort -c $<

(%.o) : %.o
	@printf "\nAdd $*.o in $@\n"
	@if [ -e "$@" ]; then \
	  printf "ar r $@ $*.o\n" ; \
          ar r $@ $*.o ; \
	else \
	  printf "ar cr $@ $*.o\n" ; \
	  ar cr $@ $*.o ; \
	fi

libtest.a: libtest.a(hello_world.o use_mod.o)
	@printf "\n"
	ranlib libtest.a
	@printf "\n"

hello_world.o : libtest.a(use_mod.o)

hello_world.exe : libtest.a
	ifort $< -o hello_world.exe

all : hello_world.exe

clean :
	\rm -rf *.o *.mod *~ hello_world.exe libtest.a

tar :
	tar cvfz arch_dep.tar.gz Makefile Makefile2 use_mod.f90 hello_world.f90
