From d52c2a2c319ff866906f5072cc5730bf05e4bf35 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 9 Mar 2015 13:02:08 +0000 Subject: Update makefile to better standards and practices. Makefile now installs to /usr/local/bin by default. Makefile now uses lower-case bindir and prefix. Makefile name changed from makefile to Makefile. Added DEBUG mode with alternate CFLAGS to makefile. LDLIBS can now be used to specify link libraries. Removed redundant target which now uses implicit target. --- Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1d6edc4 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +CFLAGS = -std=gnu11 -Wall -Wextra +LDFLAGS = -Wl,--as-needed + +ifeq ($(DEBUG), 1) + CFLAGS += -Og -g +else + CFLAGS += -O2 +endif + +INSTALL = install -m755 + +prefix = /usr/local +bindir = $(prefix)/bin + +all: + @echo 'Error, target not specified.' + @echo ' To compile .c `make `' + @echo ' To install `make target= install`' + @echo ' To uninstall `make target= uninstall`' + + +$(DESTDIR)$(bindir)/%: % + $(INSTALL) $^ $(DESTDIR)$(bindir) + +install: $(DESTDIR)$(bindir)/$(target) + +uninstall: + $(RM) "$(DESTDIR)$(bindir)/$(target)" + +clean: + find . -mindepth 1 -maxdepth 1 -executable -type f ! -name "prefix_header" -delete + +.PHONY : all install uninstall clean -- cgit v1.2.3-54-g00ecf From 792ef281df229d5748ef7049f4ffcf678588cfe7 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 24 May 2015 20:26:13 +0100 Subject: Makefile now has a help target as well as the all target --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1d6edc4..4f29283 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,14 @@ bindir = $(prefix)/bin all: @echo 'Error, target not specified.' + @make --no-print-directory help + +help: + @echo 'Usage:' @echo ' To compile .c `make `' @echo ' To install `make target= install`' @echo ' To uninstall `make target= uninstall`' + @echo ' To clean up `make clean`' $(DESTDIR)$(bindir)/%: % -- cgit v1.2.3-54-g00ecf From b0409caee2e2e13355a883ac0cf1e6addd8adcbe Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 24 May 2015 20:30:05 +0100 Subject: Added -D flag to install --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4f29283..0cb6fcc 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ else CFLAGS += -O2 endif -INSTALL = install -m755 +INSTALL = install -Dm755 prefix = /usr/local bindir = $(prefix)/bin -- cgit v1.2.3-54-g00ecf From 0f981889b3a4d62104383c5a5c0efa3a1e9f5261 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 24 May 2015 20:38:00 +0100 Subject: Makefile no longer installs bin executable --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0cb6fcc..f5da2e9 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ help: $(DESTDIR)$(bindir)/%: % - $(INSTALL) $^ $(DESTDIR)$(bindir) + $(INSTALL) $^ $(DESTDIR)$(bindir)/$(target) install: $(DESTDIR)$(bindir)/$(target) -- cgit v1.2.3-54-g00ecf