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

2017-03-30 Thread Quentin Rameau
Hi Laslo,

> > > -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.

Maybe you could at least use variables for that, like INCPATH/LIBPATH
and expand them into CFLAGS/LDFLAGS, just for convenience.

> 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.

pmake is Debian Linux port of NetBSD make (as stated in your ebuild I
guess), it's not a POSIX-compliant makefiles tester.
I'd recommend first trying to write your makefiles according to the
specs, then only test with different tools (so not only gmake/pmake,
but bmake etc.) which shouldn't take long if you wrote something
sensible in the first place.

I had a quick look at your Makefile and sent a separate fix if you want.

Enjoy!



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}
>