ComputationalProteomicsUnit / maker

Makefile for R packages
GNU General Public License v3.0
31 stars 5 forks source link

Additional targets via external Makefile(s) #8

Closed lbraglia closed 10 years ago

lbraglia commented 10 years ago

Hi,

Nice project, thanks.

Have you maybe considered allowing the user to add targets via external Makefiles?

eg this is a quick implementation, but has been quite handy to me

https://github.com/lbraglia/maker/blob/master/Makefile

currently additional Makefiles are stored in maker/makefiles and are sourced via make's include. Eg In my copy I use additional project-specific makefiles, that aim to ease working on other's R project on github eg

openxlsx_all:
    make help

openxlsx_get:
    rm -rf openxlsx* && \
    git clone https://github.com/lbraglia/openxlsx.git

openxlsx_remote:
    cd openxlsx && \
    git remote add upstream https://github.com/awalker89/openxlsx.git

openxlsx_setup: openxlsx_get openxlsx_remote

openxlsx_update:
    cd openxlsx && \
    git fetch upstream && \
    git checkout master &&  \
    git merge upstream/master && git push

openxlsx_test: 
    R -e "library(openxlsx); example(writeData, run.dontrun = TRUE)" && \
    libreoffice classTests.xlsx && \
    rm classTests.xlsx

Anyway, thanks.

Cheers, Luca

lgatto commented 10 years ago

That seems a great idea to me; I would favourably consider a pull request. Sebastian, any comments?

sgibb commented 10 years ago

Hi Luca,

that is an interesting use case and a great extension.

Maybe we don't need to include this extension into the maker Makefile. What do you think about including the following lines in your ~/.makerrc?

ADDMAKEFILESDIR := ${MAKERDIR}/makefiles/
include ${ADDMAKEFILESDIR}/Makefile.*

I would definitively consider a pull request if you can convince me that .makerrc is not the right place.

Best wishes,

Sebastian

lgatto commented 10 years ago

Yes, I like the .makerrc solution, as it allows to include any Makefile.

lbraglia commented 10 years ago

Ok for the makerrc solution.. i' m working on it asap (right now i don't have a www-connected pc here). Bye, luca

lbraglia commented 10 years ago

i've tried adding that 2 lines to makerrc (with unchanged Makefile) but it does not work for me (eg additional targets putted in makefiles dir are not available ) i've searched for unallowed recursive includeing in make, but that seems not to be the case. Maybe i'm missing something, but can you reproduce it?

sgibb commented 10 years ago

Do you really use ~/.makerrc (not ${MAKERDIR}/.makerrc)? Because these two lines in my ~/.makerrc do exactly what they should do:

~/.makerrc:

ADDMAKEFILESDIR := ${MAKERDIR}/makefiles/
include ${ADDMAKEFILESDIR}/Makefile.*

${MAKERDIR}/makefiles/Makefile.foo:

foo:
        @echo bar

Example run:

> make PKG=cleaver foo
bar
lbraglia commented 10 years ago

Yes i was changing ${MAKERDIR}/.makerrc. After a local copy refresh (to be like the original) I did the following but still I can't use it, any hint what i am doing wrong?

l@np350v5c:~/src/rpkg$ ls -a maker
.  ..  .git  include  LICENSE  Makefile  makefiles  .makerrc  README.md
l@np350v5c:~/src/rpkg$ cat .makerrc 
ADDMAKEFILESDIR := ${MAKERDIR}/makefiles/
include ${ADDMAKEFILESDIR}/Makefile.*
l@np350v5c:~/src/rpkg$ cat maker/.makerrc 
## configuration Makefile for maker

## don't build vignettes
VIG  := 0
## always use --as-cran
CRAN := 1
## specify output format for time (needs GNU time)
## see "man time" for details
# TIMEFORMAT := -f "time: %e"
l@np350v5c:~/src/rpkg$ cat maker/makefiles/Makefile.foo 
foo:
    @echo bar
l@np350v5c:~/src/rpkg$ make PKG=cleaver foo
make: ***  Nessuna regola per generare l'obiettivo "foo".  Arresto.
l@np350v5c:~/src/rpkg$ cd maker/
l@np350v5c:~/src/rpkg/maker$ git status 
Sul branch master
Your branch is up-to-date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    makefiles/

nothing added to commit but untracked files present (use "git add" to track)
sgibb commented 10 years ago

The .makerrc with the following to lines:

ADDMAKEFILESDIR := ${MAKERDIR}/makefiles/
include ${ADDMAKEFILESDIR}/Makefile.*

must be in your home directory (~/.makerrc), e.g.: /home/lbraglia/.makerrc.

lbraglia commented 10 years ago

lol, that was a quite stupid error :) ! thanks. bye, Luca