[hackers] [farbfeld] Make Makefile strictly POSIX compliant || Laslo Hunhold

2017-03-29 Thread git
commit bbe28227eb80da62fec59aa79ba7a97f5c3937b4
Author: Laslo Hunhold 
AuthorDate: Thu Mar 30 08:41:17 2017 +0200
Commit: Laslo Hunhold 
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
@@ -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 $@
+.o: $(REQ:=.o)
+   $(CC) $(CFLAGS) $($*-LDFLAGS) -o $@ $< $(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"
@@ -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
@@ -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
@@ -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



Re: [hackers] [farbfeld] Overhaul Build-system || Laslo Hunhold

2017-03-29 Thread Roberto E . Vargas Caballero
>> +png2ff ff2png: LDFLAGS += -lpng
>> +jpg2ff ff2jpg: LDFLAGS += -ljpeg
>>  
> 
> This is invalid and breaks on OpenBSD (and other non-GNU make probably).

It is not POSIX, so it is a syntax error for me.




Re: [hackers] [farbfeld] Overhaul Build-system || Laslo Hunhold

2017-03-29 Thread Laslo Hunhold
On Wed, 29 Mar 2017 23:24:33 +0200
Hiltjo Posthuma  wrote:

Hey Hiltjo,

> > -PNGLIB = /usr/local/lib
> > -PNGINC = /usr/local/include
> > -
> > -JPGLIB = /usr/local/lib
> > -JPGINC = /usr/local/include
> 
> Personally I think it's useful to have these separated. It is also
> useful to specify PNGINC, JPGINC etc separately for building in
> different environments.

what moved me to put it all into one parameter was the thought that
even if the png and jpg library are in different places (same with the
includes) you can easily add two or more include/library search paths to
the compiler with the I- and L-flags. In this sense, it was logical to
me that having separate variables was overkill. Please tell me if I'm
missing something.

> > +png2ff ff2png: LDFLAGS += -lpng
> > +jpg2ff ff2jpg: LDFLAGS += -ljpeg
> 
> This is invalid and breaks on OpenBSD (and other non-GNU make
> probably).

What a shame I hit this mine. It's even easier to hit GNUisms in make
than bashisms in Bash, and I really didn't give it enough thought and
just used target-specific variables. I'll do some further testing with
pmake (that's how the BSD-make is called on Gentoo) and fix my makefiles
to be portable.
Thanks for pointing out the issue and taking your time to write this
E-mail.

> I didn't see an issue with the previous Makefile and don't share the
> criticism. Just my 0.69 cents.

The old Makefile was okay, but it made it a bit hard to work with
requisites, which I plan on doing here. I really respect your opinion on
this matter. It was also admittedly a personal interest to write
something from scratch and just explore things a little. Seems like my
exploration continues; I learnt a lot today. :)

With best regards

Laslo

-- 
Laslo Hunhold 



Re: [hackers] [farbfeld] Overhaul Build-system || Laslo Hunhold

2017-03-29 Thread Hiltjo Posthuma
On Wed, Mar 29, 2017 at 05:52:57PM +0200, g...@suckless.org wrote:
> commit 416f39e3d68a6b12a05751930a609cfbbde483ff
> Author: Laslo Hunhold 
> AuthorDate: Wed Mar 29 17:51:41 2017 +0200
> Commit: Laslo Hunhold 
> CommitDate: Wed Mar 29 17:51:41 2017 +0200
> 
> Overhaul Build-system
> 
> I didn't like the current Makefiles. They were too crufted and not
> elegant. Additionally, given I'm planning to put some utility functions
> into a util.{c|h}-prerequisite, I wrote this new Makefile with PREREQs
> in mind.
> 
> diff --git a/Makefile b/Makefile
> index 72a5e3c..a764133 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,51 +2,49 @@
>  # See LICENSE file for copyright and license details
>  include config.mk
>  
> +PREREQ =
> +HDR = arg.h
>  BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm
>  SCRIPTS = 2ff
> -SRC = ${BIN:=.c}
> -HDR = arg.h
> -MAN1 = 2ff.1 ${BIN:=.1}
> +MAN1 = 2ff.1 $(BIN:=.1)
>  MAN5 = farbfeld.5
>  
> -all: ${BIN}
> -
> -${BIN}: ${@:=.o}
> -
> -OBJ = ${SRC:.c=.o}
> +all: $(BIN)
>  
> -${OBJ}: config.mk ${HDR}
> +$(BIN): % : %.o $(PREREQ:=.o)
> + $(CC) $^ $(LDFLAGS) -o $@
>  
> -.o:
> - ${CC} ${CFLAGS} ${$*-LDFLAGS} -o $@ $<
> +$(BIN:=.o): $(HDR) $(PREREQ:=.h)
>  
> -.c.o:
> - ${CC} ${CFLAGS} ${$*-CFLAGS} ${CPPFLAGS} -c $<
> +%.o: %.c config.mk
> + $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
>  
>  clean:
> - rm -f ${BIN} ${OBJ}
> + rm -f $(BIN) $(BIN:=.o) $(PREREQ:=.o)
>  
>  dist:
> - rm -rf "farbfeld-${VERSION}"
> - mkdir -p "farbfeld-${VERSION}"
> - cp -R FORMAT LICENSE Makefile README TODO config.mk ${SCRIPTS} ${HDR} 
> ${SRC} ${MAN1} ${MAN5} "farbfeld-${VERSION}"
> - tar -cf - "farbfeld-${VERSION}" | gzip -c > "farbfeld-${VERSION}.tar.gz"
> - rm -rf "farbfeld-${VERSION}"
> + rm -rf "farbfeld-$(VERSION)"
> + mkdir -p "farbfeld-$(VERSION)"
> + cp -R FORMAT LICENSE Makefile README TODO config.mk $(SCRIPTS) \
> +   $(HDR) $(BIN:=.c) $(PREREQ:=.c) $(PREREQ:=.h) \
> +   $(MAN1) $(MAN5) "farbfeld-$(VERSION)"
> + tar -cf - "farbfeld-$(VERSION)" | gzip -c > "farbfeld-$(VERSION).tar.gz"
> + rm -rf "farbfeld-$(VERSION)"
>  
>  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
> - mkdir -p "${DESTDIR}${MANPREFIX}/man1"
> - cp -f ${MAN1} "${DESTDIR}${MANPREFIX}/man1"
> - for m in $(MAN1); do chmod 644 "${DESTDIR}${MANPREFIX}/man1/$$m"; done
> - mkdir -p "${DESTDIR}${MANPREFIX}/man5"
> - cp -f ${MAN5} "${DESTDIR}${MANPREFIX}/man5"
> - for m in $(MAN5); do chmod 644 "${DESTDIR}${MANPREFIX}/man5/$$m"; done
> + 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
> + mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
> + cp -f $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
> + for m in $(MAN1); do chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/$$m"; done
> + mkdir -p "$(DESTDIR)$(MANPREFIX)/man5"
> + cp -f $(MAN5) "$(DESTDIR)$(MANPREFIX)/man5"
> + 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 m in $(MAN1); do rm -f "${DESTDIR}${MANPREFIX}/man1/$$m"; done
> - for m in $(MAN5); do rm -f "${DESTDIR}${MANPREFIX}/man5/$$m"; done
> + for f in $(BIN) $(SCRIPTS); 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 5fde97e..93988c4 100644
> --- a/config.mk
> +++ b/config.mk
> @@ -7,33 +7,13 @@ VERSION = 2
>  PREFIX = /usr/local
>  MANPREFIX = ${PREFIX}/man
>  
> -PNGLIB = /usr/local/lib
> -PNGINC = /usr/local/include
> -
> -JPGLIB = /usr/local/lib
> -JPGINC = /usr/local/include
> -

Personally I think it's useful to have these separated. It is also useful
to specify PNGINC, JPGINC etc separately for building in different
environments.

> -INCS =
> -LIBS =
> -
>  # flags
>  CPPFLAGS = -D_DEFAULT_SOURCE
> -CFLAGS   = -std=c99 -pedantic -Wall -Os ${INCS}
> -LDFLAGS  = -s ${LIBS}
> +CFLAGS   = -std=c89 -pedantic -Wall -Os
> +LDFLAGS  = -s
> +
> +png2ff ff2png: LDFLAGS += -lpng
> +jpg2ff ff2jpg: LDFLAGS += -ljpeg
>  

This is invalid and breaks on OpenBSD (and other non-GNU make probably).

>  # compiler and linker
>  CC = cc
> -
> -# flags per tool.
> -
> -png2ff-CFLAGS := -I${PNGINC}
> -png2ff-LDFLAGS := -L${PNGLIB} -lpng
> -
> -ff2png-CFLAGS := -I${PNGINC}
> -ff2png-LDFLAGS := -L${PNGLIB} -lpng
> -
> -jpg2ff-CFLAGS := -I${JPGINC}
> -jpg2ff-LDFLAGS := -L${JPGLIB} -ljpeg
> -
> -ff2jpg-CFLAGS := -I${JPGINC}
> -ff2jpg-LDFLAGS := -L${JPGLIB} -ljpeg

[hackers] [st] Fix commented out code || Alexander Krotov

2017-03-29 Thread git
commit 149c0d3aedffe69b625ef95868daae200941d5f5
Author: Alexander Krotov 
AuthorDate: Sat Mar 25 23:02:42 2017 +0300
Commit: Roberto E. Vargas Caballero 
CommitDate: Wed Mar 29 18:46:20 2017 +0200

Fix commented out code

diff --git a/st.c b/st.c
index d7bd32a..ae93ade 100644
--- a/st.c
+++ b/st.c
@@ -2537,7 +2537,7 @@ tresize(int col, int row)
}
 
/* allocate any new rows */
-   for (/* i == minrow */; i < row; i++) {
+   for (/* i = minrow */; i < row; i++) {
term.line[i] = xmalloc(col * sizeof(Glyph));
term.alt[i] = xmalloc(col * sizeof(Glyph));
}



[hackers] [st] keep some glyph modes for the cursor || Nils Reuße

2017-03-29 Thread git
commit f2bfd513b14a2aa27796670235557a550b4189db
Author: Nils Reuße 
AuthorDate: Wed Mar 29 18:34:12 2017 +0200
Commit: Roberto E. Vargas Caballero 
CommitDate: Wed Mar 29 18:39:21 2017 +0200

keep some glyph modes for the cursor

st currently does not keep any mode for the cursor that was active
in the underlying glyph (e.g. italic text), the mode is always
ATTR_NULL [1].  At [2] you can find a screenshot that shows the
implications.  Other terminals (at least vte-based, such as
XFCE-terminal) keep some modes for the cursor.  I find the current
behaviour very disruptive, so here is a patch that keeps a few
(arbitrarily chosen) modes for the cursor.

[1] http://git.suckless.org/st/tree/st.c#n3963
[2] http://i.imgur.com/R2yCEaC.png

diff --git a/x.c b/x.c
index 743b084..b7339e9 100644
--- a/x.c
+++ b/x.c
@@ -1266,6 +1266,7 @@ xdrawcursor(void)
Glyph g = {' ', ATTR_NULL, defaultbg, defaultcs}, og;
int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN);
Color drawcol;
+   unsigned attr;
 
LIMIT(oldx, 0, term.col-1);
LIMIT(oldy, 0, term.row-1);
@@ -1285,6 +1286,8 @@ xdrawcursor(void)
xdrawglyph(og, oldx, oldy);
 
g.u = term.line[term.c.y][term.c.x].u;
+   attr = ATTR_BOLD | ATTR_ITALIC | ATTR_UNDERLINE | ATTR_STRUCK;
+   g.mode |= term.line[term.c.y][term.c.x].mode & attr;
 
/*
 * Select the right color for the right mode.



[hackers] [farbfeld] Rename PREREQ to REQ || Laslo Hunhold

2017-03-29 Thread git
commit 65829635d9f5f9f4a23c2f890c60c315bcbafee2
Author: Laslo Hunhold 
AuthorDate: Wed Mar 29 18:07:29 2017 +0200
Commit: Laslo Hunhold 
CommitDate: Wed Mar 29 18:07:29 2017 +0200

Rename PREREQ to REQ

diff --git a/Makefile b/Makefile
index a764133..dcbbeed 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 # See LICENSE file for copyright and license details
 include config.mk
 
-PREREQ =
+REQ =
 HDR = arg.h
 BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm
 SCRIPTS = 2ff
@@ -11,22 +11,22 @@ MAN5 = farbfeld.5
 
 all: $(BIN)
 
-$(BIN): % : %.o $(PREREQ:=.o)
+$(BIN): % : %.o $(REQ:=.o)
$(CC) $^ $(LDFLAGS) -o $@
 
-$(BIN:=.o): $(HDR) $(PREREQ:=.h)
+$(BIN:=.o): $(HDR) $(REQ:=.h)
 
 %.o: %.c config.mk
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
 
 clean:
-   rm -f $(BIN) $(BIN:=.o) $(PREREQ:=.o)
+   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) \
- $(HDR) $(BIN:=.c) $(PREREQ:=.c) $(PREREQ:=.h) \
+ $(HDR) $(BIN:=.c) $(REQ:=.c) $(REQ:=.h) \
  $(MAN1) $(MAN5) "farbfeld-$(VERSION)"
tar -cf - "farbfeld-$(VERSION)" | gzip -c > "farbfeld-$(VERSION).tar.gz"
rm -rf "farbfeld-$(VERSION)"



[hackers] [farbfeld] Overhaul Build-system || Laslo Hunhold

2017-03-29 Thread git
commit 416f39e3d68a6b12a05751930a609cfbbde483ff
Author: Laslo Hunhold 
AuthorDate: Wed Mar 29 17:51:41 2017 +0200
Commit: Laslo Hunhold 
CommitDate: Wed Mar 29 17:51:41 2017 +0200

Overhaul Build-system

I didn't like the current Makefiles. They were too crufted and not
elegant. Additionally, given I'm planning to put some utility functions
into a util.{c|h}-prerequisite, I wrote this new Makefile with PREREQs
in mind.

diff --git a/Makefile b/Makefile
index 72a5e3c..a764133 100644
--- a/Makefile
+++ b/Makefile
@@ -2,51 +2,49 @@
 # See LICENSE file for copyright and license details
 include config.mk
 
+PREREQ =
+HDR = arg.h
 BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm
 SCRIPTS = 2ff
-SRC = ${BIN:=.c}
-HDR = arg.h
-MAN1 = 2ff.1 ${BIN:=.1}
+MAN1 = 2ff.1 $(BIN:=.1)
 MAN5 = farbfeld.5
 
-all: ${BIN}
-
-${BIN}: ${@:=.o}
-
-OBJ = ${SRC:.c=.o}
+all: $(BIN)
 
-${OBJ}: config.mk ${HDR}
+$(BIN): % : %.o $(PREREQ:=.o)
+   $(CC) $^ $(LDFLAGS) -o $@
 
-.o:
-   ${CC} ${CFLAGS} ${$*-LDFLAGS} -o $@ $<
+$(BIN:=.o): $(HDR) $(PREREQ:=.h)
 
-.c.o:
-   ${CC} ${CFLAGS} ${$*-CFLAGS} ${CPPFLAGS} -c $<
+%.o: %.c config.mk
+   $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
 
 clean:
-   rm -f ${BIN} ${OBJ}
+   rm -f $(BIN) $(BIN:=.o) $(PREREQ:=.o)
 
 dist:
-   rm -rf "farbfeld-${VERSION}"
-   mkdir -p "farbfeld-${VERSION}"
-   cp -R FORMAT LICENSE Makefile README TODO config.mk ${SCRIPTS} ${HDR} 
${SRC} ${MAN1} ${MAN5} "farbfeld-${VERSION}"
-   tar -cf - "farbfeld-${VERSION}" | gzip -c > "farbfeld-${VERSION}.tar.gz"
-   rm -rf "farbfeld-${VERSION}"
+   rm -rf "farbfeld-$(VERSION)"
+   mkdir -p "farbfeld-$(VERSION)"
+   cp -R FORMAT LICENSE Makefile README TODO config.mk $(SCRIPTS) \
+ $(HDR) $(BIN:=.c) $(PREREQ:=.c) $(PREREQ:=.h) \
+ $(MAN1) $(MAN5) "farbfeld-$(VERSION)"
+   tar -cf - "farbfeld-$(VERSION)" | gzip -c > "farbfeld-$(VERSION).tar.gz"
+   rm -rf "farbfeld-$(VERSION)"
 
 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
-   mkdir -p "${DESTDIR}${MANPREFIX}/man1"
-   cp -f ${MAN1} "${DESTDIR}${MANPREFIX}/man1"
-   for m in $(MAN1); do chmod 644 "${DESTDIR}${MANPREFIX}/man1/$$m"; done
-   mkdir -p "${DESTDIR}${MANPREFIX}/man5"
-   cp -f ${MAN5} "${DESTDIR}${MANPREFIX}/man5"
-   for m in $(MAN5); do chmod 644 "${DESTDIR}${MANPREFIX}/man5/$$m"; done
+   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
+   mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
+   cp -f $(MAN1) "$(DESTDIR)$(MANPREFIX)/man1"
+   for m in $(MAN1); do chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/$$m"; done
+   mkdir -p "$(DESTDIR)$(MANPREFIX)/man5"
+   cp -f $(MAN5) "$(DESTDIR)$(MANPREFIX)/man5"
+   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 m in $(MAN1); do rm -f "${DESTDIR}${MANPREFIX}/man1/$$m"; done
-   for m in $(MAN5); do rm -f "${DESTDIR}${MANPREFIX}/man5/$$m"; done
+   for f in $(BIN) $(SCRIPTS); 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 5fde97e..93988c4 100644
--- a/config.mk
+++ b/config.mk
@@ -7,33 +7,13 @@ VERSION = 2
 PREFIX = /usr/local
 MANPREFIX = ${PREFIX}/man
 
-PNGLIB = /usr/local/lib
-PNGINC = /usr/local/include
-
-JPGLIB = /usr/local/lib
-JPGINC = /usr/local/include
-
-INCS =
-LIBS =
-
 # flags
 CPPFLAGS = -D_DEFAULT_SOURCE
-CFLAGS   = -std=c99 -pedantic -Wall -Os ${INCS}
-LDFLAGS  = -s ${LIBS}
+CFLAGS   = -std=c89 -pedantic -Wall -Os
+LDFLAGS  = -s
+
+png2ff ff2png: LDFLAGS += -lpng
+jpg2ff ff2jpg: LDFLAGS += -ljpeg
 
 # compiler and linker
 CC = cc
-
-# flags per tool.
-
-png2ff-CFLAGS := -I${PNGINC}
-png2ff-LDFLAGS := -L${PNGLIB} -lpng
-
-ff2png-CFLAGS := -I${PNGINC}
-ff2png-LDFLAGS := -L${PNGLIB} -lpng
-
-jpg2ff-CFLAGS := -I${JPGINC}
-jpg2ff-LDFLAGS := -L${JPGLIB} -ljpeg
-
-ff2jpg-CFLAGS := -I${JPGINC}
-ff2jpg-LDFLAGS := -L${JPGLIB} -ljpeg