]> git.armaanb.net Git - opendoas.git/commitdiff
Makefile for gmake on MacOSX.
authorNathan Holstein <nathan.holstein@gmail.com>
Sun, 2 Aug 2015 16:11:40 +0000 (12:11 -0400)
committerNathan Holstein <nathan.holstein@gmail.com>
Wed, 5 Aug 2015 12:49:07 +0000 (08:49 -0400)
Makefile
libopenbsd/openbsd.h [new file with mode: 0644]

index 191d00faedbe4910211c71ec01af44ad916c63ff..7bb667e9a8927aa4be886f245bc56fd0acdec04e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,32 @@ PROG=  doas
 MAN=   doas.1 doas.conf.5
 
 BINOWN= root
+BINGRP= wheel
 BINMODE=4555
 
-CFLAGS+= -I${.CURDIR}
-COPTS+=        -Wall
+COPTS+= -Wall -Wextra -Werror -pedantic -std=c11
+CFLAGS+= -I${CURDIR} -I${CURDIR}/libopenbsd ${COPTS}
 
-.include <bsd.prog.mk>
+BINDIR?=/usr/bin
+MANDIR?=/usr/share/man
+
+default: ${PROG}
+
+OBJS:=${SRCS:.y=.c}
+OBJS:=${OBJS:.c=.o}
+
+${PROG}: ${OBJS}
+       ${CC} ${COPTS} ${LDOPTS} $^ -o $@
+
+${BINDIR}/${PROG}: ${PROG}
+       cp $< $@
+       chown ${BINOWN}:${BINGRP} $@
+       chmod ${BINMODE} $@
+
+install: ${BINDIR}/${PROG}
+
+clean:
+       rm -f ${OBJS}
+       rm -f ${PROG}
+
+.PHONY: default clean install
diff --git a/libopenbsd/openbsd.h b/libopenbsd/openbsd.h
new file mode 100644 (file)
index 0000000..bcf0e3b
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef _LIB_OPENBSD_H_
+#define _LIB_OPENBSD_H_
+
+/* API definitions lifted from OpenBSD src/include */
+
+/* bsd_auth.h */
+int auth_userokay(char *, char *, char *, char *);
+
+/* login_cap.h */
+#define        LOGIN_SETGROUP          0x0001  /* Set group */
+#define        LOGIN_SETLOGIN          0x0002  /* Set login */
+#define        LOGIN_SETPATH           0x0004  /* Set path */
+#define        LOGIN_SETPRIORITY       0x0008  /* Set priority */
+#define        LOGIN_SETRESOURCES      0x0010  /* Set resource limits */
+#define        LOGIN_SETUMASK          0x0020  /* Set umask */
+#define        LOGIN_SETUSER           0x0040  /* Set user */
+#define        LOGIN_SETENV            0x0080  /* Set environment */
+#define        LOGIN_SETALL            0x00ff  /* Set all. */
+
+typedef struct login_cap login_cap_t;
+struct passwd;
+int setusercontext(login_cap_t *, struct passwd *, uid_t, unsigned int);
+
+/* pwd.h */
+#define _PW_NAME_LEN 63
+
+/* stdlib.h */
+void * reallocarray(void *optr, size_t nmemb, size_t size);
+long long strtonum(const char *numstr, long long minval,
+               long long maxval, const char **errstrp);
+
+/* unistd.h */
+int execvpe(const char *, char *const *, char *const *);
+int setresuid(uid_t, uid_t, uid_t);
+
+#endif