commit 0188d2f8b73aa4a77aa2fdda313b1192d81aa0a6
Author: Quentin Rameau <[email protected]>
AuthorDate: Sat Apr 11 14:29:53 2020 +0200
Commit: Jochen Sprickerhof <[email protected]>
CommitDate: Sat Apr 11 18:24:37 2020 +0200
Rework the Makefile a bit
diff --git a/Makefile b/Makefile
index 4677e7a..c3e1c50 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,21 @@
-include config.mk
+.POSIX:
-.PHONY: all clean install test
+include config.mk
all: scroll
+
clean:
rm -f scroll ptty
config.h:
cp config.def.h config.h
-scroll: scroll.c config.h
- $(CC) $(CFLAGS) $(CPPFLAGS) scroll.c $(LDLIBS) -o $@
+scroll: config.h
install: scroll
- cp scroll ${BINDIR}
- cp scroll.1 ${MAN1DIR}
+ mkdir -p $(BINDIR) $(MANDIR)/man1
+ cp -f scroll $(BINDIR)
+ cp -f scroll.1 $(MANDIR)/man1
test: scroll ptty
# check usage
@@ -22,3 +23,8 @@ test: scroll ptty
# check exit passthrough of child
if ! ./ptty ./scroll true; then exit 1; fi
if ./ptty ./scroll false; then exit 1; fi
+
+.c:
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< -lutil
+
+.PHONY: all clean install test
diff --git a/config.mk b/config.mk
index 20fa68c..247bb01 100644
--- a/config.mk
+++ b/config.mk
@@ -1,10 +1,9 @@
# paths
PREFIX = /usr/local
-BINDIR = ${PREFIX}/bin
-MANDIR = ${PREFIX}/share/man
-MAN1DIR = ${MANDIR}/man1
+BINDIR = $(PREFIX)/bin
+MANDIR = $(PREFIX)/share/man
-CC ?= cc
-CFLAGS = -std=c99 -pedantic -Wall -Wextra -g
-LDLIBS += -lutil
-CPPFLAGS += -D_DEFAULT_SOURCE
+CPPFLAGS = -D_DEFAULT_SOURCE
+# if your system is not POSIX, add -std=c99 to CFLAGS
+CFLAGS = -Os
+LDFLAGS = -s