opendoas

A portable version of the OpenBSD `doas` command
git clone https://pi.duncano.de/git/opendoas.git
Log | Files | Refs | README | LICENSE

commit 968c988e3b4f89dae7b7ec62f9cdd718041d87a3
parent cb888450540a9a9efbca1badb056fc6cce9f9feb
Author: Nathan Holstein <nathan.holstein@gmail.com>
Date:   Wed,  5 Aug 2015 09:53:11 -0400

Break out make functionality into utility makefile.

This reverts the contents of Makefile back to (nearly) what it was in
the initial import--setting a few variables and invoking a helper make
script.

All complexity is now moved into bsd.prog.mk. It should be a decent base
for use in other executables as well.

Diffstat:
Makefile | 46++--------------------------------------------
bsd.prog.mk | 45+++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,6 +1,4 @@ # $OpenBSD: Makefile,v 1.9 2014/01/13 01:41:00 tedu Exp $ -# -# Copyright 2015 Nathan Holstein SRCS= parse.y doas.c @@ -11,48 +9,8 @@ BINOWN= root BINGRP= wheel BINMODE=4511 +CFLAGS+= -I${CURDIR} COPTS+= -Wall -Wextra -Werror -pedantic -std=c11 -CFLAGS+= -I${CURDIR} -I${CURDIR}/libopenbsd ${COPTS} LDFLAGS+= -lpam -BINDIR?=/usr/bin -MANDIR?=/usr/share/man - -default: ${PROG} - -OPENBSD:=reallocarray.c strtonum.c execvpe.c setresuid.c \ - auth_userokay.c setusercontext.c explicit_bzero.c -OPENBSD:=$(addprefix libopenbsd/,${OPENBSD:.c=.o}) -libopenbsd.a: ${OPENBSD} - ${AR} -r $@ $? - -OBJS:=${SRCS:.y=.c} -OBJS:=${OBJS:.c=.o} - -${PROG}: ${OBJS} libopenbsd.a - ${CC} ${CFLAGS} ${LDFLAGS} $^ -o $@ - -.%.chmod: % - cp $< $@ - chmod ${BINMODE} $@ - chown ${BINOWN}:${BINGRP} $@ - -${BINDIR}: - mkdir -pm 0755 $@ - -${BINDIR}/${PROG}: .${PROG}.chmod ${BINDIR} - mv $< $@ - -MAN:=$(join $(addprefix ${MANDIR}/man,$(patsubst .%,%/,$(suffix ${MAN}))),${MAN}) -$(foreach M,${MAN},$(eval $M: $(notdir $M); cp $$< $$@)) - -install: ${BINDIR}/${PROG} ${MAN} - -clean: - rm -f libopenbsd.a - rm -f ${OPENBSD} - rm -f ${OBJS} - rm -f ${PROG} - -.PHONY: default clean install man -.INTERMEDIATE: .${PROG}.chmod +include bsd.prog.mk diff --git a/bsd.prog.mk b/bsd.prog.mk @@ -0,0 +1,45 @@ +# Copyright 2015 Nathan Holstein + +BINDIR?=/usr/bin +MANDIR?=/usr/share/man + +default: ${PROG} + +OPENBSD:=reallocarray.c strtonum.c execvpe.c setresuid.c \ + auth_userokay.c setusercontext.c explicit_bzero.c +OPENBSD:=$(addprefix libopenbsd/,${OPENBSD:.c=.o}) +libopenbsd.a: ${OPENBSD} + ${AR} -r $@ $? + +CFLAGS:=${CFLAGS} -I${CURDIR}/libopenbsd ${COPTS} + +OBJS:=${SRCS:.y=.c} +OBJS:=${OBJS:.c=.o} + +${PROG}: ${OBJS} libopenbsd.a + ${CC} ${CFLAGS} ${LDFLAGS} $^ -o $@ + +.%.chmod: % + cp $< $@ + chmod ${BINMODE} $@ + chown ${BINOWN}:${BINGRP} $@ + +${BINDIR}: + mkdir -pm 0755 $@ + +${BINDIR}/${PROG}: .${PROG}.chmod ${BINDIR} + mv $< $@ + +MAN:=$(join $(addprefix ${MANDIR}/man,$(patsubst .%,%/,$(suffix ${MAN}))),${MAN}) +$(foreach M,${MAN},$(eval $M: $(notdir $M); cp $$< $$@)) + +install: ${BINDIR}/${PROG} ${MAN} + +clean: + rm -f libopenbsd.a + rm -f ${OPENBSD} + rm -f ${OBJS} + rm -f ${PROG} + +.PHONY: default clean install man +.INTERMEDIATE: .${PROG}.chmod