1
0
mirror of https://github.com/slicer69/doas synced 2024-07-09 12:05:49 +00:00
doas/Makefile
Jesse Smith f595b9a35e Updated Makefile with uninstall instructions for doas. Removes
doas, vidoas, the doas manual page, and doas.conf manual page.
The doas.conf file is left on the system, if it exists.
2020-08-18 12:34:39 -03:00

85 lines
2.5 KiB
Makefile

AWK?=awk
CC?=clang
YACC?=yacc
BIN=doas
PREFIX?=/usr/local
MANDIR?=$(DESTDIR)$(PREFIX)/man
SYSCONFDIR?=$(DESTDIR)$(PREFIX)/etc
OBJECTS=doas.o env.o compat/execvpe.o compat/reallocarray.o y.tab.o
OPT?=-O2
# Can set GLOBAL_PATH here to set PATH for target user.
# TARGETPATH=-DGLOBAL_PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:\"
CFLAGS+=-Wall $(OPT) -DUSE_PAM -DDOAS_CONF=\"${SYSCONFDIR}/doas.conf\" $(TARGETPATH)
CPPFLAGS+=-include compat/compat.h
LDFLAGS+=-lpam
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS+=-lpam_misc
CPPFLAGS+=-Icompat
CFLAGS+=-D_GNU_SOURCE
COMPAT+=closefrom.o errc.o getprogname.o setprogname.o strlcat.o strlcpy.o strtonum.o verrc.o
OBJECTS+=$(COMPAT:%.o=compat/%.o)
endif
ifeq ($(UNAME_S),FreeBSD)
CFLAGS+=-DHAVE_LOGIN_CAP_H
LDFLAGS+=-lutil
endif
ifeq ($(UNAME_S),SunOS)
SAFE_PATH?=/bin:/sbin:/usr/bin:/usr/sbin:$(PREFIX)/bin:$(PREFIX)/sbin
GLOBAL_PATH?=/bin:/sbin:/usr/bin:/usr/sbin:$(PREFIX)/bin:$(PREFIX)/sbin
CPPFLAGS+=-Icompat
CFLAGS+=-DSOLARIS_PAM -DSAFE_PATH=\"$(SAFE_PATH)\" -DGLOBAL_PATH=\"$(GLOBAL_PATH)\"
COMPAT=errc.o pm_pam_conv.o setresuid.o verrc.o
OBJECTS+=$(COMPAT:%.o=compat/%.o)
endif
ifeq ($(UNAME_S),Darwin)
CPPFLAGS+=-Icompat
COMPAT+=bsd-closefrom.o
OBJECTS+=$(COMPAT:%.o=compat/%.o)
# On MacOS the default man page path is /usr/local/share/man
MANDIR=$(DESTDIR)$(PREFIX)/share/man
endif
all: $(OBJECTS) doas.1.final doas.conf.5.final
$(CC) -o $(BIN) $(OBJECTS) $(LDFLAGS)
env.o: doas.h env.c
execvpe.o: doas.h execvpe.c
doas.o: doas.h doas.c parse.y
reallocarray.o: doas.h reallocarray.c
y.tab.o: parse.y
$(YACC) parse.y
$(CC) $(CPPFLAGS) $(CFLAGS) -c y.tab.c
install: $(BIN)
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $(BIN) $(DESTDIR)$(PREFIX)/bin/
cp vidoas $(DESTDIR)$(PREFIX)/bin/
chmod 4755 $(DESTDIR)$(PREFIX)/bin/$(BIN)
mkdir -p $(MANDIR)/man1
cp doas.1.final $(MANDIR)/man1/doas.1
mkdir -p $(MANDIR)/man5
cp doas.conf.5.final $(MANDIR)/man5/doas.conf.5
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/doas
rm -f $(DESTDIR)$(PREFIX)/bin/vidoas
rm -f $(MANDIR)/man1/doas.1
rm -f $(MANDIR)/man5/doas.conf.5
clean:
rm -f $(BIN) $(OBJECTS) y.tab.c
rm -f *.final parse.o
# Doing it this way allows to change the original files
# only partially instead of renaming them.
doas.1.final:
$(AWK) -v pfx="$(SYSCONFDIR)" '{gsub("@SUBSTSYSCONFDIR@",pfx); print $$0}' < doas.1 > doas.1.final
doas.conf.5.final:
$(AWK) -v pfx="$(SYSCONFDIR)" '{gsub("@SUBSTSYSCONFDIR@",pfx); print $$0}' < doas.conf.5 > doas.conf.5.final