summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile98
1 files changed, 98 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..38bef66
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,98 @@
+# Copyright 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net>.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+prefix=/usr
+bindir=$(libexecdir)/$(PACKAGE)
+libexecdir=$(libdir)
+sysconfdir=/etc
+
+PACKAGE = parabola-hackers
+sysusersdir=$(prefix)/lib/sysusers.d
+systemunitdir=$(prefix)/lib/systemd/system
+conf_file = $(sysconfdir)/$(PACKAGE).yml
+NET ?=
+#NET ?= FORCE
+user = nshd
+CFLAGS += -Wall -Wextra -Werror -pedantic
+CC = gcc -std=c99
+
+MAKEFLAGS += --no-builtin-rules
+topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+topoutdir := $(topsrcdir)
+include $(topsrcdir)/build-aux/Makefile.head.mk
+
+CGO_CPPFLAGS = $(CPPFLAGS) -U_FORTIFY_SOURCE
+CGO_CFLAGS = $(CFLAGS) -O0 -Wno-unused-parameter
+CGO_ENABLED = 1
+
+at.subdirs += src/lukeshu.com/git/go/libnslcd.git/proto
+
+scripts = $(filter-out common.rb common.rb.in,$(notdir $(wildcard $(srcdir)/scripts/*))) common.rb
+
+std.gen_files += LICENSE.lgpl-2.1.txt LICENSE.gpl-2.txt LICENSE.apache-2.0.txt
+std.out_files += bin/cmd-nshd nshd.service nshd.sysusers scripts/common.rb test/runner
+std.sys_files += $(addprefix $(bindir)/,nshd $(scripts)) $(systemunitdir)/nshd.socket $(systemunitdir)/nshd.service $(sysusersdir)/nshd.conf $(conf_file)
+std.clean_files += test/*.o pkg/ .tmp* .var* $(_out)
+
+$(srcdir)/LICENSE.lgpl-2.1.txt: $(NET)
+ curl https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt > $@
+$(srcdir)/LICENSE.gpl-2.txt: $(NET)
+ curl https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt > $@
+$(srcdir)/LICENSE.apache-2.0.txt: $(NET)
+ curl https://www.apache.org/licenses/LICENSE-2.0 > $@
+$(srcdir)/LICENSE.wtfpl-2.txt: $(NET)
+ curl http://www.wtfpl.net/txt/copying/ > $@
+
+_gen += src/lukeshu.com/git/go/libnslcd.git/proto/server/interface_backend.go
+_gen += src/lukeshu.com/git/go/libnslcd.git/proto/server/func_handlerequest.go
+_gen += src/lukeshu.com/git/go/libnslcd.git/proto/server/type_nilbackend.go
+_out += src/parabola_hackers/load_all_users.go
+_out += src/cmd-nshd/main.go
+$(outdir)/bin/%-nshd: $(call golang.src,$(srcdir)) $(_gen) $(_out)
+ $(call golang.install,$(topsrcdir),cmd-nshd)
+
+$(outdir)/%.o: $(srcdir)/%.c $(var)CC $(var)CPPFLAGS $(var)CFLAGS
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(filter-out $(var)%,$^)
+$(outdir)/%: $(outdir)/%.o $(var)CC $(var)LDFLAGS
+ $(CC) $(LDFLAGS) -o $@ $(filter-out $(var)%,$^)
+
+$(outdir)/%: $(srcdir)/%.in
+ < $< sed $(foreach v,$(patsubst $(var)%,%,$(filter $(var)%,$^)), -e 's|@$v@|$($v)|g' ) > $@
+
+$(outdir)/nshd.service: $(var)user $(var)bindir
+$(outdir)/nshd.sysusers: $(var)user
+$(outdir)/scripts/common.rb: $(var)conf_file
+$(outdir)/src/cmd-nshd/main.go: $(var)conf_file
+$(outdir)/src/parabola_hackers/load_all_users.go: $(var)bindir
+
+$(DESTDIR)$(bindir)/%: $(outdir)/bin/cmd-%
+ install -TDm755 $< $@
+$(DESTDIR)$(bindir)/%: $(srcdir)/scripts/%
+ install -TDm755 $< $@
+$(DESTDIR)$(bindir)/common.rb: $(srcdir)/scripts/common.rb
+ install -TDm644 $< $@
+$(DESTDIR)$(systemunitdir)/%.socket: $(outdir)/%.socket
+ install -TDm644 $< $@
+$(DESTDIR)$(systemunitdir)/%.service: $(outdir)/%.service
+ install -TDm644 $< $@
+$(DESTDIR)$(sysusersdir)/%.conf: $(outdir)/%.sysusers
+ install -TDm644 $< $@
+$(DESTDIR)$(conf_file): $(srcdir)/parabola-hackers.yml
+ install -TDm644 $< $@
+
+.PHONY: FORCE
+.SECONDARY:
+.DELETE_ON_ERROR:
+include $(topsrcdir)/build-aux/Makefile.tail.mk