commit bbe28227eb80da62fec59aa79ba7a97f5c3937b4
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Thu Mar 30 08:41:17 2017 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Thu Mar 30 08:43:42 2017 +0200
Make Makefile strictly POSIX compliant
Thanks Hiltjo for the feedback! GNUisms need to be avoided like a
plague, even if it means having to be a little more creative.
Strict POSIX compliance means that I just worked within the bounds of
the POSIX specification, hopefully without using any GNU or BSD
extensions. If I did, please let me know.
Tip to all Linux users: Test your Makefiles with pmake(1) instead of
make(1) (= GNU make) and refer to the newest POSIX 2016 make
specification[0].
[0]:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
diff --git a/Makefile b/Makefile
index dcbbeed..5d9c213 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -1,31 +1,32 @@
-# farbfeld - suckless image format with conversion tools
# See LICENSE file for copyright and license details
+# farbfeld - suckless image format with conversion tools
+.POSIX:
+
include config.mk
-REQ =
HDR = arg.h
BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm
-SCRIPTS = 2ff
+SCR = 2ff
MAN1 = 2ff.1 $(BIN:=.1)
MAN5 = farbfeld.5
all: $(BIN)
-$(BIN): % : %.o $(REQ:=.o)
- $(CC) $^ $(LDFLAGS) -o $_AT_
+.o: $(REQ:=.o)
+ $(CC) $(CFLAGS) $($*-LDFLAGS) -o $_AT_ $< $(REQ:=.o)
-$(BIN:=.o): $(HDR) $(REQ:=.h)
-
-%.o: %.c config.mk
+.c.o:
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
+$(BIN:=.o): config.mk $(HDR) $(REQ:=.h)
+
clean:
rm -f $(BIN) $(BIN:=.o) $(REQ:=.o)
dist:
rm -rf "farbfeld-$(VERSION)"
mkdir -p "farbfeld-$(VERSION)"
- cp -R FORMAT LICENSE Makefile README TODO config.mk $(SCRIPTS) \
+ cp -R FORMAT LICENSE Makefile README TODO config.mk $(SCR) \
$(HDR) $(BIN:=.c) $(REQ:=.c) $(REQ:=.h) \
$(MAN1) $(MAN5) "farbfeld-$(VERSION)"
tar -cf - "farbfeld-$(VERSION)" | gzip -c > "farbfeld-$(VERSION).tar.gz"
_AT_@ -33,8 +34,8 @@ dist:
install: all
mkdir -p "$(DESTDIR)$(PREFIX)/bin"
- cp -f $(SCRIPTS) $(BIN) "$(DESTDIR)$(PREFIX)/bin"
- for f in $(BIN) $(SCRIPTS); do chmod 755 "$(DESTDIR)$(PREFIX)/bin/$$f"; done
+ cp -f $(SCR) $(BIN) "$(DESTDIR)$(PREFIX)/bin"
+ for f in $(BIN) $(SCR); do chmod 755 "$(DESTDIR)$(PREFIX)/bin/$$f"; done
mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
cp -f $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
for m in $(MAN1); do chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/$$m"; done
_AT_@ -43,8 +44,6 @@ install: all
for m in $(MAN5); do chmod 644 "$(DESTDIR)$(MANPREFIX)/man5/$$m"; done
uninstall:
- for f in $(BIN) $(SCRIPTS); do rm -f "$(DESTDIR)$(PREFIX)/bin/$$f"; done
+ for f in $(BIN) $(SCR); do rm -f "$(DESTDIR)$(PREFIX)/bin/$$f"; done
for m in $(MAN1); do rm -f "$(DESTDIR)$(MANPREFIX)/man1/$$m"; done
for m in $(MAN5); do rm -f "$(DESTDIR)$(MANPREFIX)/man5/$$m"; done
-
-.PHONY: all clean dist install uninstall
diff --git a/config.mk b/config.mk
index 93988c4..d5bc6c7 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -12,8 +12,10 @@ CPPFLAGS = -D_DEFAULT_SOURCE
CFLAGS = -std=c89 -pedantic -Wall -Os
LDFLAGS = -s
-png2ff ff2png: LDFLAGS += -lpng
-jpg2ff ff2jpg: LDFLAGS += -ljpeg
+png2ff-LDFLAGS = -lpng
+ff2png-LDFLAGS = -lpng
+jpg2ff-LDFLAGS = -ljpeg
+ff2jpg-LDFLAGS = -ljpeg
# compiler and linker
CC = cc
Received on Thu Mar 30 2017 - 08:44:34 CEST