aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-02-23 15:23:30 +0100
committerMattias Andrée <maandree@kth.se>2021-02-23 15:23:30 +0100
commit6ef03dcaee546215c8e5fc15fdeac43689b63f7b (patch)
treefa1dfdf2d1122446745f60f72c9b04da7acb487a /Makefile
parentremove dist (diff)
downloadsetpgrp-12c6f1553863aa99c0b9f1c93341886f9ac2e7f9.tar.gz
setpgrp-12c6f1553863aa99c0b9f1c93341886f9ac2e7f9.tar.bz2
setpgrp-12c6f1553863aa99c0b9f1c93341886f9ac2e7f9.tar.xz
Change license, add man pages, misc2
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile122
1 files changed, 27 insertions, 95 deletions
diff --git a/Makefile b/Makefile
index 4127c6d..80adf03 100644
--- a/Makefile
+++ b/Makefile
@@ -1,108 +1,40 @@
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
+.POSIX:
+CONFIGFILE = config.mk
+include $(CONFIGFILE)
-# The package path prefix, if you want to install to another root, set DESTDIR to that root.
-PREFIX ?= /usr
-# The command path excluding prefix.
-BIN ?= /bin
-# The library path excluding prefix.
-LIB ?= /lib
-# The executable library path excluding prefix.
-LIBEXEC ?= /libexec
-# The resource path excluding prefix.
-DATA ?= /share
-# The command path including prefix.
-BINDIR ?= $(PREFIX)$(BIN)
-# The library path including prefix.
-LIBDIR ?= $(PREFIX)$(LIB)
-# The executable library path including prefix.
-LIBEXECDIR ?= $(PREFIX)$(LIBEXEC)
-# The resource path including prefix.
-DATADIR ?= $(PREFIX)$(DATA)
-# The generic documentation path including prefix.
-DOCDIR ?= $(DATADIR)/doc
-# The info manual documentation path including prefix.
-INFODIR ?= $(DATADIR)/info
-# The license base path including prefix.
-LICENSEDIR ?= $(DATADIR)/licenses
+BIN = getpgrp setpgrp
+OBJ = $(@:=.o)
+MAN = $(@:=.1)
+HDR = arg.h
-# The name of the package as it should be installed.
-PKGNAME ?= setpgrp
+all: $(BIN)
+$(OBJ): $(@:.o=.c) $(HDR)
-# Optimisation level (and debug flags.)
-OPTIMISE = -Og -g
+getpgrp: getpgrp.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
-# Enabled Warnings.
-WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self \
- -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow \
- -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
- -Wnested-externs -Winline -Wno-variadic-macros -Wsign-conversion \
- -Wswitch-default -Wconversion -Wsync-nand -Wunsafe-loop-optimizations \
- -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef \
- -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op \
- -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked \
- -Wvector-operation-performance -Wunsuffixed-float-constants \
- -Wsuggest-attribute=const -Wsuggest-attribute=noreturn \
- -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc
+setpgrp: setpgrp.o
+ $(CC) -o $@ $@.o $(LDFLAGS)
-# The C standard used in the code.
-STD = gnu99
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-# Options for the C compiler.
-C_FLAGS = $(OPTIMISE) $(WARN) -std=$(STD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
- -ftree-vrp -fstrict-aliasing -fipa-pure-const -fstack-usage \
- -fstrict-overflow -funsafe-loop-optimizations -fno-builtin
+install: $(BIN)
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
+ cp -- $(BIN) "$(DESTDIR)$(PREFIX)/bin/"
+ cp -- $(MAN) "$(DESTDIR)$(MANPREFIX)/man1/"
-
-
-.PHONY: all
-all: getpgrp setpgrp
-
-.PHONY: getpgrp setpgrp
-getpgrp: bin/getpgrp
-setpgrp: bin/setpgrp
-
-bin/%: src/%.c
- @mkdir -p bin
- $(CC) $(C_FLAGS) -o $@ $^
-
-
-.PHONY: install
-install: install-commands install-license
-
-.PHONY: install-commands
-install-commands: install-getpgrp install-setpgrp
-
-.PHONY: install-getpgrp
-install-getpgrp: bin/getpgrp
- install -dm755 -- "$(DESTDIR)$(BINDIR)"
- install -m755 $< -- "$(DESTDIR)$(BINDIR)/getpgrp"
-
-.PHONY: install-setpgrp
-install-setpgrp: bin/setpgrp
- install -dm755 -- "$(DESTDIR)$(BINDIR)"
- install -m755 $< -- "$(DESTDIR)$(BINDIR)/setpgrp"
-
-.PHONY: install-license
-install-license:
- install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- install -m644 COPYING LICENSE -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-
-
-.PHONY: uninstall
uninstall:
- -rm -- "$(DESTDIR)$(BINDIR)/getpgrp"
- -rm -- "$(DESTDIR)$(BINDIR)/setpgrp"
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
- -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-
+ -cd -- "$(DESTDIR)$(PREFIX)/bin/" && rm -f -- $(BIN)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man1/" && rm -f -- $(MAN)
-.PHONY: clean
clean:
- -rm -r -- bin *.su
+ -rm -rf -- $(BIN) *.o *.su
+
+.SUFFIXES:
+.SUFFIXES: .o .c
+.PHONY: all install uninstall clean