1

I have a custom shell script to make twitter bootstrap from source and then move the files to my node.js app's /lib file:

rm -r bootstrap
make bootstrap
mv -f bootstrap/css/* ../../lib/public/css
mv -f bootstrap/img/* ../../lib/public/img
mv -f bootstrap/js/* ../../lib/public/js

Running this from the shell works just fine using ./make_bootstrap.sh

Now I've created a Makefile for my full app (mainly compiling coffeescript and easy test initialization) and want to have a command that executes this custom shell script to build bootstrap. Here is my makefile

REPORTER = spec

all: build

build:
    @./node_modules/coffee-script/bin/coffee \
        -c \
        -o lib src

bootstrap:
    @./src/bootstrap \
        ./make_bootstrap.sh

clean:
    rm -rf lib
    mkdir lib

watch:
    @./node_modules/coffee-script/bin/coffee \
        -o lib \
        -cw src

test:
    @./node_modules/mocha/bin/mocha \
        --reporter $(REPORTER) \
        test/*.coffee

.PHONY: build bootstrap clean watch test

with the relevant command being 'make bootstrap'. However when I run make bootstrap from the command line all I get is this error:

make: ./src/bootstrap: Permission denied
make: *** [bootstrap] Error 1

Originally I had assumed that it was a permission error but even setting all permissions on files (chmod 777) results in nothing. Files I have given full permissions at this point include the root Makefile, my custom shell script in the bootstrap folder and the makefile within the bootstrap folder itself.

4

1 回答 1

3

EDIT:

Based on the comments I have refactored to this

bootstrap:
    rm -r src/bootstrap/bootstrap
    $(MAKE) -C ./src/bootstrap bootstrap
    mv -f src/bootstrap/bootstrap/css/* lib/public/css
    mv -f src/bootstrap/bootstrap/img/* lib/public/img
    mv -f src/bootstrap/bootstrap/js/* lib/public/js

This duplicates the functionality of the shell script I had before (moving files for my custom project) and still uses the standard makefile that Twitter Bootstrap ships with. Much cleaner... I'm going to live the original answer below so people can see the evolution and refactor.

OLD ANSWER

Ok thank you guys in the comments for pointing my in the right direction. This solution works:

bootstrap:
    cd ./src/bootstrap; \
        ./make_bootstrap.sh

What happens is it executes the change directory (in a sub process so it doesn't affect where I run make from) and then executes the custom script. It seems as if I probably shouldn't be using something like this in a makefile since it feels 'dirty'; perhaps a more clean way to do it would be to invoke the LESS compiler myself and mimic the makefile provided by bootstrap. I'm using this for a tiny personal project though so it does the job.

于 2012-09-06T02:07:48.857 回答