summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile92
1 files changed, 92 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7f98070
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,92 @@
+# Copyright 2015 Luke Shumaker <lukeshu@sbcglobal.net>.
+#
+# This is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# The GNU General Public License's references to "object code" and
+# "executables" are to be interpreted to also include the output of
+# any document formatting or typesetting system, including
+# intermediate and printed output.
+#
+# This software 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this manual; if not, see
+# <http://www.gnu.org/licenses/>.
+
+MAKEFLAGS += --no-builtin-rules
+
+prefix = /usr/local
+bindir = $(prefix)/bin
+libdir = $(prefix)/lib
+systemddir = $(libdir)/systemd
+
+Q ?= @
+#NET ?= FORCE
+
+user = nshd
+group = nshd
+
+CFLAGS = -std=c99 -Wall -Wextra -Werror -pedantic
+CGO_CFLAGS = $(CFLAGS) -Wno-unused-parameter
+CGO_ENABLED = 1
+
+deps += gopkg.in/yaml.v2
+deps += lukeshu.com/git/go/libgnulinux.git
+deps += lukeshu.com/git/go/libnslcd.git
+deps += lukeshu.com/git/go/libsystemd.git
+
+srcdir := $(abspath $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))))
+topdir := $(srcdir)
+
+subdirs = src/lukeshu.com/git/go/libnslcd.git/proto
+
+generate += $(addprefix $(topdir)/src/,$(deps))
+generate += $(topdir)/LICENSE.lgpl-2.1.txt $(topdir)/LICENSE.gpl-2.txt $(topdir)/LICENSE.apache-2.0.txt
+generate_secondary += $(topdir)/src/*.*/
+build += $(topdir)/bin/nshd $(topdir)/nshd.service $(topdir)/nshd.socket $(topdir)/test/runner
+build_secondary += $(topdir)/bin $(topdir)/pkg $(topdir)/test/*.o .var.*
+install += $(addprefix $(DESTDIR),$(bindir)/nshd $(systemddir)/system/nshd.socket $(systemddir)/system/nshd.service)
+
+ifeq (1,$(words $(MAKEFILE_LIST)))
+ include $(topdir)/common.mk
+endif
+src/lukeshu.com/git/go/libnslcd.git/proto/Makefile: $(topdir)/src/lukeshu.com/git/go/libnslcd.git
+
+$(topdir)/LICENSE.lgpl-2.1.txt: $(NET)
+ curl https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt > $@
+$(topdir)/LICENSE.gpl-2.txt: $(NET)
+ curl https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt > $@
+$(topdir)/LICENSE.apache-2.0.txt: $(NET)
+ curl https://www.apache.org/licenses/LICENSE-2.0 > $@
+$(topdir)/LICENSE.wtfpl-2.txt: $(NET)
+ curl http://www.wtfpl.net/txt/copying/ > $@
+
+include $(topdir)/golang.mk
+
+$(call goget,$(topdir),$(deps))
+
+$(topdir)/bin/nshd: $(generate) $(configure) $(call gosrc,$(topdir))
+ $(call goinstall,$(topdir),nshd)
+
+%.o: %.c .var.CC .var.CPPFLAGS .var.CFLAGS
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(filter-out .var.%,$^)
+%: %.o .var.CC .var.LDFLAGS .var.LOADLIBES .var.LDLIBS
+ $(CC) $(LDFLAGS) -o $@ $(filter-out .var.%,$^) $(LOADLIBES) $(LDLIBS)
+
+%: %.in
+ < $< sed $(foreach v,$(patsubst .var.%,%,$(filter .var.%,$^)), -e 's|@$v@|$($v)|g' ) > $@
+$(topdir)/nshd.service: .var.bindir .var.user .var.group
+$(topdir)/nshd.socket: .var.user .var.group
+
+$(DESTDIR)$(bindir)/%: bin/%
+ install -TDm755 $< $@
+$(DESTDIR)$(systemddir)/system/%.socket: %.socket
+ install -TDm644 $< $@
+$(DESTDIR)$(systemddir)/system/%.service: %.service
+ install -TDm644 $< $@