## MAKEFLAGS += -j2
VER=
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)

CXX_STD = CXX14

MYCXXFLAGS = -Wa,-mbig-obj

%.o: %.cpp
	$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) -c $< -o $@

all: liblandscape.a fl_statistics fl_generate $(SHLIB)

MAGELLAN_SRC = FitnessLandscape/gamma.c\
        FitnessLandscape/landscape.c \
        FitnessLandscape/random.c\
        FitnessLandscape/sort.c\
        FitnessLandscape/chain.c\
        FitnessLandscape/input.c\
        FitnessLandscape/genotypes.c\
        FitnessLandscape/ordered_pairs.c\
        FitnessLandscape/calculus.c\
        FitnessLandscape/vector.c\
        FitnessLandscape/generalized_chain.c\
        FitnessLandscape/LinearAlgebra.c\
        FitnessLandscape/summary_statistics.c\
        FitnessLandscape/epistasis_type.c\
        FitnessLandscape/decomposition.c\
        FitnessLandscape/models.c\
	FitnessLandscape/verbose.c
MAGELLAN_OBJECTS = $(MAGELLAN_SRC:.c=.o)

liblandscape.a: $(MAGELLAN_OBJECTS)
	$(AR) -r $@ $+ ;
	$(RANLIB) $@;

MAGELLAN_LIBS = liblandscape.a
MAGELLAN_LIBS_DIR = -L.
MAGELLAN_LFLAGS = -llandscape
MAGELLAN_INCLUDE_DIR = -I/FitnessLandscape/.
MAGELLAN_ALLCFLAGS= -O -Wall

fl_statistics: FitnessLandscape/main_fl_statistics.c $(MAGELLAN_LIBS)
	$(CC) $(MAGELLAN_ALLCFLAGS) -o $@ $(MAGELLAN_INCLUDE_DIR) $(MAGELLAN_LIBS_DIR) $< $(MAGELLAN_LFLAGS) -lm;

fl_generate: FitnessLandscape/main_fl_generate.c  $(MAGELLAN_LIBS)
	$(CC) $(MAGELLAN_ALLCFLAGS) -o $@ $(MAGELLAN_INCLUDE_DIR) $(MAGELLAN_LIBS_DIR) $< $(MAGELLAN_LFLAGS) -lm;



#########################################################
#########################################################
#########################################################

## Doing this in Windows

## Open the msys2 shell and do (change path to R, as needed)
## export PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH

## Install
## time /c/R/R-4.2.1/bin/R.exe CMD INSTALL --build OncoSimulR && time /c/R/R-4.2.1/bin/R.exe CMD INSTALL OncoSimulR_x.y.z.zip


## Build
## time /c/R/R-4.2.1/bin/R.exe CMD build --keep-empty-dirs --no-resave-data OncoSimulR

## Check
## time /c/R/R-4.2.1/bin/R.exe CMD check --no-multiarch --no-vignettes --timings OncoSimulR_x.y.z.tar.gz

## Build bin
## time /c/R/R-4.2.1/bin/R.exe CMD INSTALL --build OncoSimulR_x.y.z.tar.gz



## Recall I need pandoc (and git ---this already installed and in path)
## Install pandoc at C:/pandoc
## Add it to the path
## export PATH=$PATH:/c/Pandoc
## ##now, pdflatex or tinytex
## export PATH=$PATH:/c/Users/ramon/AppData/Roaming/TinyTeX/bin/win32
## And install rmarkdown and other suggests
## install.packages(c("Oncotree", "rmarkdown", "bookdown", "pander","testthat", "knitr"))
## BiocManager::install(version='devel')
## BiocManager::install("BiocStyle")