From: Sebastien Peterson-Boudreau <sebastien.peterson.boudr...@gmail.com>
Rather than manually managing lists of files, use shell substitution (portable; specified in POSIX) to find files. This makes the Makefile easier to manage and shorter. Simpler is subjective, but I would not make this patch if I thought it added complexity. It can also be said that this avoids any errors of files not being added to the Makefile when they are created, but that doesn't seem to have been an issue before now. The build has been tested and runs correctly and equally as fast as the previous version (due to the use of the immediate-expansion-assignment overator, `::=`, which is also specified in POSIX. If the lazily-expanding assingment, `=`, is used it is much slower). Additionally, the expansion of the macros changed in this patch have been checked and are identical to the manual values from the previous version, so nothing in the build _should_ change. The change to the BIN macro is potentially objectionable, because it assumes that every binary has a .c file with the same name, but this is typically the suckless style. If this is an issue, BIN could continue to be manually specified. --- Makefile | 184 +++---------------------------------------------------- 1 file changed, 9 insertions(+), 175 deletions(-) diff --git a/Makefile b/Makefile index e3b6936..ea8ec56 100644 --- a/Makefile +++ b/Makefile @@ -11,184 +11,18 @@ CPPFLAGS =\ -D_XOPEN_SOURCE=700 \ -D_FILE_OFFSET_BITS=64 -HDR =\ - arg.h\ - compat.h\ - crypt.h\ - fs.h\ - md5.h\ - queue.h\ - sha1.h\ - sha224.h\ - sha256.h\ - sha384.h\ - sha512.h\ - sha512-224.h\ - sha512-256.h\ - text.h\ - utf.h\ - util.h - -LIBUTFOBJ =\ - libutf/fgetrune.o\ - libutf/fputrune.o\ - libutf/isalnumrune.o\ - libutf/isalpharune.o\ - libutf/isblankrune.o\ - libutf/iscntrlrune.o\ - libutf/isdigitrune.o\ - libutf/isgraphrune.o\ - libutf/isprintrune.o\ - libutf/ispunctrune.o\ - libutf/isspacerune.o\ - libutf/istitlerune.o\ - libutf/isxdigitrune.o\ - libutf/lowerrune.o\ - libutf/rune.o\ - libutf/runetype.o\ - libutf/upperrune.o\ - libutf/utf.o\ - libutf/utftorunestr.o - -LIBUTILOBJ =\ - libutil/concat.o\ - libutil/cp.o\ - libutil/crypt.o\ - libutil/ealloc.o\ - libutil/enmasse.o\ - libutil/eprintf.o\ - libutil/eregcomp.o\ - libutil/estrtod.o\ - libutil/fnck.o\ - libutil/fshut.o\ - libutil/getlines.o\ - libutil/human.o\ - libutil/linecmp.o\ - libutil/md5.o\ - libutil/memmem.o\ - libutil/mkdirp.o\ - libutil/mode.o\ - libutil/parseoffset.o\ - libutil/putword.o\ - libutil/reallocarray.o\ - libutil/recurse.o\ - libutil/rm.o\ - libutil/sha1.o\ - libutil/sha224.o\ - libutil/sha256.o\ - libutil/sha384.o\ - libutil/sha512.o\ - libutil/sha512-224.o\ - libutil/sha512-256.o\ - libutil/strcasestr.o\ - libutil/strlcat.o\ - libutil/strlcpy.o\ - libutil/strsep.o\ - libutil/strnsubst.o\ - libutil/strtonum.o\ - libutil/unescape.o\ - libutil/writeall.o +HDR != echo *.h + +LIBUTF != echo libutf/*.c +LIBUTFOBJ ::= $(LIBUTF:%.c=%.o) + +LIBUTIL != echo libutil/*.c +LIBUTILOBJ ::= $(LIBUTIL:%.c=%.o) LIB = libutf.a libutil.a -BIN =\ - basename\ - cal\ - cat\ - chgrp\ - chmod\ - chown\ - chroot\ - cksum\ - cmp\ - cols\ - comm\ - cp\ - cron\ - cut\ - date\ - dd\ - dirname\ - du\ - echo\ - ed\ - env\ - expand\ - expr\ - false\ - find\ - flock\ - fold\ - getconf\ - grep\ - head\ - hostname\ - join\ - kill\ - link\ - ln\ - logger\ - logname\ - ls\ - md5sum\ - mkdir\ - mkfifo\ - mknod\ - mktemp\ - mv\ - nice\ - nl\ - nohup\ - od\ - paste\ - pathchk\ - printenv\ - printf\ - pwd\ - readlink\ - renice\ - rev\ - rm\ - rmdir\ - sed\ - seq\ - setsid\ - sha1sum\ - sha224sum\ - sha256sum\ - sha384sum\ - sha512sum\ - sha512-224sum\ - sha512-256sum\ - sleep\ - sort\ - split\ - sponge\ - strings\ - sync\ - tail\ - tar\ - tee\ - test\ - tftp\ - time\ - touch\ - tr\ - true\ - tsort\ - tty\ - uname\ - unexpand\ - uniq\ - unlink\ - uudecode\ - uuencode\ - wc\ - which\ - whoami\ - xargs\ - xinstall\ - yes +SRC != echo *.c +BIN ::= $(SRC:%.c=%) OBJ = $(LIBUTFOBJ) $(LIBUTILOBJ) -- 2.48.1