From 367697a24f8d078b1567a2aabe7bcc2e9f8bebba Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 24 Oct 2017 22:44:29 +0100 Subject: [PATCH 1/2] Makefile: rename CCFLAGS to CFLAGS the latter is the standard way of naming it. it was pretty surprising when doing make CFLAGS="-O0 -g" ended up running `gcc -O0 -g -O3 ...` --- src/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4e8195f..b8957e3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ -CCFLAGS ?= -std=c99 -O3 +CFLAGS ?= -std=c99 -O3 TARGET = pixiewps CRYPTO = mbedtls/sha256.c mbedtls/md.c mbedtls/md_wrap.c @@ -9,10 +9,10 @@ PREFIX ?= $(DESTDIR)/usr BINDIR = $(PREFIX)/bin all: - $(CC) $(CFLAGS) $(CCFLAGS) $(CPPFLAGS) -o $(TARGET) $(SOURCE) $(LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TARGET) $(SOURCE) $(LIBS) $(LDFLAGS) debug: - $(CC) $(CLFAGS) $(CCFLAGS) $(CPPFLAGS) -DDEBUG -o $(TARGET) $(SOURCE) $(LIBS) $(LDFLAGS) + $(CC) $(CLFAGS) $(CPPFLAGS) -DDEBUG -o $(TARGET) $(SOURCE) $(LIBS) $(LDFLAGS) install: rm -f $(BINDIR)/$(TARGET) From c56e689f589cda28553aa6866a97fb8e2e803874 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 24 Oct 2017 22:50:10 +0100 Subject: [PATCH 2/2] 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. --- src/Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index b8957e3..4c2646c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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)