aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Holstein <nathan.holstein@gmail.com>2015-08-05 09:53:11 -0400
committerNathan Holstein <nathan.holstein@gmail.com>2015-08-05 10:53:26 -0400
commit968c988e3b4f89dae7b7ec62f9cdd718041d87a3 (patch)
treea82ccc54f677ab17acf14fc871d4a4a3de841c0e
parentcb888450540a9a9efbca1badb056fc6cce9f9feb (diff)
downloadopendoas-968c988e3b4f89dae7b7ec62f9cdd718041d87a3.tar.gz
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.
-rw-r--r--Makefile46
-rw-r--r--bsd.prog.mk45
2 files changed, 47 insertions, 44 deletions
diff --git a/Makefile b/Makefile
index 4399611..f2277ab 100644
--- 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
new file mode 100644
index 0000000..197455a
--- /dev/null
+++ 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