Specifying targets for makefile command -


i'm new makefiles i'm having bit of trouble distinguishing target path versus make file exists

here's makefile

babel-ready:     make babel-install-preset module=es2015     make babel-install-preset module=stage-2  babel-install-preset:     npm install --save-dev babel-preset-$(module)     ${curdir}/node_modules/.bin/json -i -f package.json -e 'if (!this.babel) this.babel = {}' ;\     ${curdir}/node_modules/.bin/json -i -f package.json -e 'if (!this.babel.presets) this.babel.presets = []' ;\     ${curdir}/node_modules/.bin/json -i -f package.json -e 'this.babel.presets.push("'$(module)'")' ;\ 

here's dir structure:

- node_modules   - .bin/     - json - makefile - packages/   - my-package/         - package.json  - package.json 

i'd use makefile in 3 ways.

one specify target this.

./ $ make babel-ready package=my-package 

two run on root package.json.

./ $ make babel-ready  

third in package , run command.

./packages/my-package $ make -c ../../ babel-ready 

i'd if 3 use same base code well.

i keep using cd change directory within commands keeps messing me up, because once cd loose access make command, , have use make -c ${curdir} loose access correct package.json file, seems can't work.

you seem looking make -f ../../makefile babel-ready in last example. -c option loses current directory, discovered.

(unclear me whether commands correctly use ${curdir}, might need additional tweaks.)