1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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/dl
deps += lukeshu.com/git/go/libgnulinux.git/getgr
deps += lukeshu.com/git/go/libgnulinux.git/inotify
deps += lukeshu.com/git/go/libnslcd.git/proto
deps += lukeshu.com/git/go/libnslcd.git/systemd
deps += lukeshu.com/git/go/libsystemd.git/sd_daemon
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)/test/*.o
install += $(addprefix $(DESTDIR),$(bindir)/nshd $(systemddir)/system/nshd.socket $(systemddir)/system/nshd.service)
ifeq (1,$(words $(MAKEFILE_LIST)))
include $(topdir)/common.mk
endif
$(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 > $@
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 $< $@
|