diff options
Diffstat (limited to 'src/nslcd_proto/Makefile')
-rw-r--r-- | src/nslcd_proto/Makefile | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/nslcd_proto/Makefile b/src/nslcd_proto/Makefile index 2014bdd..fcb46d6 100644 --- a/src/nslcd_proto/Makefile +++ b/src/nslcd_proto/Makefile @@ -1,31 +1,44 @@ -all: struct_backend.go func_handlerequest.go +_ := $(MAKEFILE_LIST) +d := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) + +generate := $d/interface_backend.go $d/func_handlerequest.go $d/struct_null_backend.go +secondary := $d/enumerator-list.mk $d/requests.txt $d/responses.txt $d/enumerator@*.go + +ifeq (,$(filter clean,$(MAKECMDGOALS))) +-include $d/enumerator-list.mk +endif + +ifeq (1,$(words $_)) + +all: generate .PHONY: all +generate: $(generate) +.PHONY: generate + clean: - rm -f -- struct_backend.go func_handlerequest.go enumerator@*.go - rm -f -- enumerator-list.mk requests.txt responses.txt + rm -f -- $(generate) $(secondary) .PHONY: clean -ifeq (,$(filter clean,$(MAKECMDGOALS))) --include enumerator-list.mk endif - -enumerator@%.go: enumerator@T.got + +$d/enumerator@%.go: $d/enumerator@T.got < $< sed 's/<T>/$*/g' > $@ -enumerator-list.mk: responses.txt Makefile - < $< sed -rn 's/.*/all: enumerator@&.go/p' > $@ +$d/enumerator-list.mk: $d/responses.txt $d/Makefile + < $< sed -rn 's|.*|generate += $$d/enumerator@&.go|p' > $@ -requests.txt: nslcd_h.go Makefile +$d/requests.txt: $d/nslcd_h.go $d/Makefile < $< grep -Eo 'Request_([^_ ]+)(_\S+)?' | sed 's/^Request_//' > $@ -responses.txt: struct_backend.go Makefile +$d/responses.txt: $d/interface_backend.go $d/Makefile < $< sed -rn 's/.* (\S+)_Enumerator$$/\1/p' | sort -u > $@ %.go: %.go.sh ./$^ > $@ -struct_backend.go: requests.txt -func_handlerequest.go: requests.txt +$d/interface_backend.go: $d/requests.txt +$d/func_handlerequest.go: $d/requests.txt +$d/struct_null_backend.go: $d/interface_backend.go .DELETE_ON_ERROR: .SECONDARY: |