summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--proto/Makefile31
-rw-r--r--proto/common.mk50
2 files changed, 34 insertions, 47 deletions
diff --git a/proto/Makefile b/proto/Makefile
index 6c15198..4b81a28 100644
--- a/proto/Makefile
+++ b/proto/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -15,23 +15,32 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
+ifeq ($(origin topsrcdir),undefined)
srcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
-
-generate += $(srcdir)/server/interface_backend.go
-generate += $(srcdir)/server/func_handlerequest.go
-generate += $(srcdir)/server/type_nilbackend.go
-generate_secondary += $(srcdir)/requests.txt
-
-ifeq (1,$(words $(MAKEFILE_LIST)))
- include common.mk
+.DEFAULT_GOAL = all
+else
+include $(topsrcdir)/build-aux/Makefile.head.mk
endif
+std.gen_files += server/interface_backend.go
+std.gen_files += server/func_handlerequest.go
+std.gen_files += server/type_nilbackend.go
+std.secondary_gen_files += requests.txt
+
$(srcdir)/requests.txt: $(srcdir)/nslcd_h.go $(srcdir)/Makefile
< $< grep -Eo '\btype Request_([^_ ]+)(_\S+)?' | sed 's/^type Request_//' > $@
-%.go: %.go.sh
- $(call rel,$^) > $@
+_nslcd.srcdir := $(srcdir)
+_nslcd.rel=$(patsubst $(abspath $(_nslcd.srcdir))/%,./%,$(abspath $1))
+$(srcdir)/%.go: $(srcdir)/%.go.sh
+ cd $(srcdir) && $(call _nslcd.rel,$^) > $(call _nslcd.rel,$@)
$(srcdir)/server/interface_backend.go: $(srcdir)/requests.txt
$(srcdir)/server/func_handlerequest.go: $(srcdir)/requests.txt
$(srcdir)/server/type_nilbackend.go: $(srcdir)/server/interface_backend.go
+
+ifeq ($(origin topsrcdir),undefined)
+include $(srcdir)/common.mk
+else
+include $(topsrcdir)/build-aux/Makefile.tail.mk
+endif
diff --git a/proto/common.mk b/proto/common.mk
index 41f5c79..1496356 100644
--- a/proto/common.mk
+++ b/proto/common.mk
@@ -1,55 +1,33 @@
-# Copyright © 2015 Luke Shumaker
+# Copyright © 2015-2016 Luke Shumaker
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
-rel = $(patsubst $(abspath .)/%,./%,$(abspath $1))
-
all: build
.PHONY: all
-include $(addsuffix /Makefile,$(subdirs))
-
-generate: $(generate)
+generate: $(addprefix $(srcdir)/,$(std.gen_files))
.PHONY: generate
-configure: generate $(configure)
+configure: generate $(addprefix $(outdir)/,$(std.cfg_files))
.PHONY: configure
-build: configure $(build)
+build: configure $(addprefix $(outdir)/,$(std.out_files))
.PHONY: build
-install: build $(install)
+install: build $(addprefix $(DESTDIR),$(std.sys_files))
.PHONY: install
-# un-build
-clean:
- rm -rf -- $(build) $(build_secondary)
-.PHONY: clean
+maintainer-clean: private files=$(addprefix $(srcdir)/,$(std.gen_files) $(std.secondary_gen_files)) # un-generate
+distclean : private files=$(addprefix $(outdir)/,$(std.cfg_files) $(std.secondary_cfg_files)) # un-configure
+clean : private files=$(addprefix $(outdir)/,$(std.out_files) $(std.secondary_out_files)) # un-build
+uninstall : private files=$(addprefix $(DESTDIR),$(std.sys_files) ) # un-install
-# un-configure
distclean: clean
- rm -rf -- $(configure) $(configure_secondary)
-.PHONY: distclean
-
-# un-generate
maintainer-clean: distclean
- rm -rf -- $(generate) $(generate_secondary)
-.PHONY: maintainer-clean
-
-# un-install
-uninstall:
- rm -f -- $(install)
- rmdir -p -- $(sort $(dir $(install))) 2>/dev/null || true
-.PHONY: uninstall
-
-
-# Now, this is magic. It stores the values of environment variables,
-# so that if you change them in a way that would cause something to be
-# rebuilt, then Make knows.
-.var.%: FORCE
- $(Q)printf '%s' '$($*)' > .tmp$@ && { cmp -s .tmp$@ $@ && rm -f -- .tmp$@ || mv -Tf .tmp$@ $@; } || { rm -f -- .tmp$@; false; }
-.DELETE_ON_ERROR:
-.SECONDARY:
-.PHONY: FORCE
+clean distclean maintainer-clean uninstall:
+ rm -f -- $(sort $(filter-out %/,$(files)))
+ rm -f -r -- $(sort $(filter %/,$(files)))
+ rmdir -p -- $(sort $(dir $(files))) 2>/dev/null || true
+.PHONY: clean distclean maintainer-clean uninstall