diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 125 |
1 files changed, 112 insertions, 13 deletions
@@ -1,20 +1,119 @@ -# This Makefile is a minimal stub that exists to allow the -# `at-modules` set of Make targets to print documentation for the -# present Autothing modules. +# Copyright 2015-2017 Luke Shumaker <lukeshu@sbcglobal.net>. # -# This file is part of the documentation for Autothing. +# 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. # -# Copyright (C) 2017 Luke Shumaker +# 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. # -# This documentation file is placed into the public domain. If that -# is not possible in your legal system, I grant you permission to use -# it in absolutely every way that I can legally grant to you. +# 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/>. -dist.pkgname = autothing -dist.version = 1.0 -gnuconf.pkgname = autothing +-include config.mk +PACKAGE = parabola-hackers +sysusersdir=$(prefix)/lib/sysusers.d +systemunitdir=$(prefix)/lib/systemd/system +conf_file = $(sysconfdir)/$(PACKAGE).yml +shadow_file = $(sysconfdir)/nshd/shadow +NET ?= +#NET ?= FORCE +user = nshd +CFLAGS += -Wall -Wextra -Werror -pedantic +CC = gcc -std=c99 -topoutdir ?= . -topsrcdir ?= . +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 + +programs = nshd nshd-setuid nshd-tester common.rb +scripts = $(filter-out %.c %.o $(programs) common.rb common.rb.in,$(notdir $(wildcard $(srcdir)/bin/*))) + +files.src.gen += LICENSE.lgpl-2.1.txt LICENSE.gpl-2.txt LICENSE.apache-2.0.txt +files.out.gen += $(addprefix bin/,$(programs)) nshd.service nshd.sysusers +files.out.int += bin/*.o .gopath/ .tmp* .var* +files.sys.all += $(addprefix $(bindir)/,$(programs) $(scripts)) $(systemunitdir)/nshd.socket $(systemunitdir)/nshd.service $(sysusersdir)/nshd.conf $(conf_file) $(shadow_file) + +$(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/ > $@ + +files.generate: go-generate +go-generate: + +GOPATH=$$PWD go generate ./... +.PHONY: go-generate + +$(outdir)/bin/nshd: \ +$(outdir)/bin/%: $(outdir)/.gopath/bin/cmd-% + cp -T $< $@ +$(outdir)/.gopath/src: $(golang.var) + rm -rf -- $(@D) + mkdir $(@D) + ln -sr $(topsrcdir)/go $@ + touch $@ +$(outdir)/.gopath/bin/cmd-nshd: $(patsubst $(outdir)/.gopath/src/%,go/%,$(call golang.src,$(outdir)/.gopath)) $(_gen) $(_out) + $(call golang.install,$(topoutdir)/.gopath,cmd-nshd) + +$(outdir)/%.o: $(srcdir)/%.c $(var)CC $(var)CPPFLAGS $(var)CFLAGS + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(filter-out $(var)%,$^) +$(outdir)/bin/nshd-tester $(outdir)/bin/nshd-setuid: \ +$(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)/bin/nshd-setuid: -ldl +$(outdir)/nshd.service: $(var)user $(var)bindir +$(outdir)/nshd.sysusers: $(var)user +$(outdir)/bin/common.rb: $(var)conf_file +$(outdir)/go/cmd-nshd/main.go: $(var)conf_file +$(outdir)/go/parabola_hackers/users.go: $(var)bindir +$(outdir)/go/parabola_hackers/passwords.go: $(var)shadow_file + +# Patterns +$(DESTDIR)$(bindir)/%: $(outdir)/bin/% + $(NORMAL_INSTALL) + install -TDm755 $< $@ +$(DESTDIR)$(systemunitdir)/%.socket: $(outdir)/%.socket + $(NORMAL_INSTALL) + install -TDm644 $< $@ +$(DESTDIR)$(systemunitdir)/%.service: $(outdir)/%.service + $(NORMAL_INSTALL) + install -TDm644 $< $@ +$(DESTDIR)$(sysusersdir)/%.conf: $(outdir)/%.sysusers + $(NORMAL_INSTALL) + install -TDm644 $< $@ + +# Specific files +$(DESTDIR)$(bindir)/common.rb: $(srcdir)/bin/common.rb + $(NORMAL_INSTALL) + install -TDm644 $< $@ +$(DESTDIR)$(conf_file): $(srcdir)/parabola-hackers.yml + $(NORMAL_INSTALL) + install -TDm644 $< $@ +$(DESTDIR)$(shadow_file): $(var)user $(DESTDIR)$(sysusersdir)/nshd.conf + $(NORMAL_INSTALL) + install -d $(@D) + touch $@ + $(POST_INSTALL) + -systemd-sysusers + -chown $(user):$(user) $(@D) $@ + +.PHONY: FORCE +.SECONDARY: +.DELETE_ON_ERROR: include $(topsrcdir)/build-aux/Makefile.tail.mk |