aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2015-03-09 13:02:08 +0000
committerTomasz Kramkowski <tk@the-tk.com>2015-03-09 13:02:08 +0000
commitd52c2a2c319ff866906f5072cc5730bf05e4bf35 (patch)
tree1e41754a1829a8e579abb2da7c5319a277162de4 /Makefile
parentc3ab178996b6ee87b8358d5cfe48807789b0483d (diff)
downloadc-stuff-d52c2a2c319ff866906f5072cc5730bf05e4bf35.tar.gz
c-stuff-d52c2a2c319ff866906f5072cc5730bf05e4bf35.tar.xz
c-stuff-d52c2a2c319ff866906f5072cc5730bf05e4bf35.zip
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.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 33 insertions, 0 deletions
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 <filename>.c `make <filename>`'
+ @echo ' To install <filename> `make target=<filename> install`'
+ @echo ' To uninstall <filename> `make target=<filename> 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