Makefile: use DESTDIR in the conventional way

DESTDIR gets only used in the install target, so prefix doesn't get
cluttered and can be used internally to reference file dependencies.
e.g. if for example a DB would be used, the filename to the DB could
be passed in CPPFLAGS like "-DDBPATH=$(PREFIX)/share/pixiewps.db".
this doesn't happen at the moment, but it's good practice to follow
the conventions.

additionally, remove the "rm" command in the install target - running
`make install` should never ever delete files from user's prefix.
This commit is contained in:
rofl0r 2017-10-24 22:50:10 +01:00
parent 367697a24f
commit c56e689f58

View File

@ -5,7 +5,7 @@ CRYPTO = mbedtls/sha256.c mbedtls/md.c mbedtls/md_wrap.c
SOURCE = $(TARGET).c random_r.c $(CRYPTO)
LIBS = -lpthread
PREFIX ?= $(DESTDIR)/usr
PREFIX ?= /usr
BINDIR = $(PREFIX)/bin
all:
@ -15,12 +15,11 @@ debug:
$(CC) $(CLFAGS) $(CPPFLAGS) -DDEBUG -o $(TARGET) $(SOURCE) $(LIBS) $(LDFLAGS)
install:
rm -f $(BINDIR)/$(TARGET)
install -d $(BINDIR)
install -m 755 $(TARGET) $(BINDIR)
install -m 755 $(TARGET) $(DESTDIR)$(BINDIR)
uninstall:
rm -f $(BINDIR)/$(TARGET)
rm -f $(DESTDIR)$(BINDIR)/$(TARGET)
clean:
rm -f $(TARGET)