# * -*- makefile -*-
# *_________________________________________________________________________*
# *      MEAM: MODEFIED EMBEDDED ATOM METHOD                                *
# *      DESCRIPTION: SEE READ-ME                                           *
# *      FILE NAME: Makefile                                                *
# *      AUTHORS: Greg Wagner, Sandia National Laboratories                 * 
# *      CONTACT: gjwagne@sandia.gov                                        *
# *_________________________________________________________________________*/

SHELL = /bin/sh

# which file will be copied to Makefile.lammps

EXTRAMAKE = Makefile.lammps.gfortran

# ------ FILES ------

SRC = meam_data.F meam_setup_done.F meam_setup_global.F meam_setup_param.F meam_dens_init.F meam_dens_final.F meam_force.F meam_cleanup.F

FILES = $(SRC) Makefile 

# ------ DEFINITIONS ------

DIR = Obj_mingw64/
LIB = $(DIR)libmeam.a
OBJ = $(SRC:%.F=$(DIR)%.o)

# ------ SETTINGS ------

F90 =           x86_64-w64-mingw32-gfortran
F90FLAGS =      -O3 -march=core2 -mtune=core2 -msse2 -mpc64  \
		-ffast-math -funroll-loops -fstrict-aliasing -J$(DIR) \
		-Wall -W -Wno-uninitialized -fno-second-underscore
#F90FLAGS =      -O 
ARCHIVE =	x86_64-w64-mingw32-ar
ARCHFLAG =	-rcs
LINK =         	x86_64-w64-mingw32-g++
LINKFLAGS =	-O
USRLIB =
SYSLIB =

# ------ MAKE PROCEDURE ------

default: $(DIR) $(LIB)

$(DIR):
	-mkdir $(DIR)

$(LIB):  $(OBJ)
	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
	@cp $(EXTRAMAKE) Makefile.lammps

# ------ COMPILE RULES ------

$(DIR)%.o:%.F
	$(F90) $(F90FLAGS) -c $< -o $@

# ------ CLEAN ------

clean:
	-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
	-rmdir $(DIR)

tar:
	-tar -cvf ../MEAM.tar $(FILES)
