Skip to content

Instantly share code, notes, and snippets.

@pwwang
Created September 28, 2019 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwwang/59bb3a790d96aca397d9ae1c472f3161 to your computer and use it in GitHub Desktop.
Save pwwang/59bb3a790d96aca397d9ae1c472f3161 to your computer and use it in GitHub Desktop.
A proxy Makefile to subdirectory's Makefile
# get all targets from subdirectory
SUBDIR := subdir
TARGETS := $(shell make -C $(SUBDIR) -rpn | sed -n -e "/^$$/ { n ; /^[^ .\#%][^ ]\*:/ { s/:.\*$$// ; p ; } ; }" )
# default target
all:
# pass all targets to subdirectory
%:
make -C $(SUBDIR) $@
@pwwang
Copy link
Author

pwwang commented Sep 28, 2019

Suppose you have a subdirectory subdir under current, then any make command you do is just like you do it under subdir
For example:
make is the same as make -C subdir
make clean is the same as make -C subdir clean
Same for other targets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment