From 83866e480eaefbda6b2ce516d85d89873a073f11 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 03:58:29 +0100 Subject: [PATCH 1/9] Makefile: allow overriding pkg-config Makes cross compilation easier. Signed-off-by: Sam James --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4526342..7e743c2 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GAMES_DIR?=/usr/games SCORES_DIR?=/var/games MAN_DIR?=/usr/share/man/man6 CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(SCORES_DIR)\" -PKG-CONFIG=pkg-config +PKG-CONFIG?=pkg-config LDFLAGS+= $(shell pkg-config --libs --cflags ncurses) -lm From a3f1a8c09c1ac913846439c0388029831d82a08e Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:00:41 +0100 Subject: [PATCH 2/9] Makefile: separate LIBS, LDFLAGS It's conventional to list CFLAGS first, then LDFLAGS, then LIBS. It's important that LIBS go last because otherwise some LDFLAGS won't take effect (e.g. --as-needed). Signed-off-by: Sam James --- Makefile | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 7e743c2..fa8a7fa 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,13 @@ SCORES_DIR?=/var/games MAN_DIR?=/usr/share/man/man6 CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(SCORES_DIR)\" PKG-CONFIG?=pkg-config -LDFLAGS+= $(shell pkg-config --libs --cflags ncurses) -lm +LIBS=$(shell pkg-config --libs --cflags ncurses) -lm ALL= nbsdgames jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare darrt snakeduel tugow SCORE_FILES= pipes_scores jewels_scores miketron_scores muncher_scores fisher_scores darrt_scores tugow_scores -all: $(ALL) +all: $(ALL) scorefiles: for sf in $(SCORE_FILES); do touch $(SCORES_DIR)/$$sf ; chmod 664 $(SCORES_DIR)/$$sf; chown :games $(SCORES_DIR)/$$sf ; done; @@ -23,43 +23,43 @@ scorefiles: manpages: cp man/* $(MAN_DIR) jewels: jewels.c config.h common.h - $(CC) jewels.c $(LDFLAGS) $(CFLAGS) -o ./jewels -sudoku: sudoku.c config.h - $(CC) sudoku.c $(LDFLAGS) $(CFLAGS) -o ./sudoku + $(CC) $(CFLAGS) jewels.c $(LDFLAGS) $(LIBS) -o ./jewels +sudoku: sudoku.c config.h + $(CC) $(CFLAGS) sudoku.c $(LDFLAGS) $(LIBS) -o ./sudoku mines: mines.c config.h - $(CC) mines.c $(LDFLAGS) $(CFLAGS) -o ./mines + $(CC) $(CFLAGS) mines.c $(LDFLAGS) $(LIBS) -o ./mines reversi: reversi.c config.h - $(CC) reversi.c $(LDFLAGS) $(CFLAGS) -o ./reversi + $(CC) $(CFLAGS) reversi.c $(LDFLAGS) $(LIBS) -o ./reversi checkers: checkers.c config.h - $(CC) checkers.c $(LDFLAGS) $(CFLAGS) -o ./checkers + $(CC) $(CFLAGS) checkers.c $(LDFLAGS) $(LIBS) -o ./checkers battleship: battleship.c config.h - $(CC) battleship.c $(LDFLAGS) $(CFLAGS) -o ./battleship + $(CC) $(CFLAGS) battleship.c $(LDFLAGS) $(LIBS) -o ./battleship rabbithole: rabbithole.c config.h - $(CC) rabbithole.c $(LDFLAGS) $(CFLAGS) -o ./rabbithole + $(CC) $(CFLAGS) rabbithole.c $(LDFLAGS) $(LIBS) -o ./rabbithole sos: sos.c config.h - $(CC) sos.c $(LDFLAGS) $(CFLAGS) -o ./sos + $(CC) $(CFLAGS) sos.c $(LDFLAGS) $(LIBS) -o ./sos pipes: pipes.c config.h common.h - $(CC) pipes.c $(LDFLAGS) $(CFLAGS) -o ./pipes + $(CC) $(CFLAGS) pipes.c $(LDFLAGS) $(LIBS) -o ./pipes fifteen: fifteen.c config.h - $(CC) fifteen.c $(LDFLAGS) $(CFLAGS) -o ./fifteen + $(CC) $(CFLAGS) fifteen.c $(LDFLAGS) $(LIBS) -o ./fifteen memoblocks: memoblocks.c - $(CC) memoblocks.c $(LDFLAGS) $(CFLAGS) -o ./memoblocks + $(CC) $(CFLAGS) memoblocks.c $(LDFLAGS) $(LIBS) -o ./memoblocks fisher: fisher.c config.h common.h - $(CC) fisher.c $(LDFLAGS) $(CFLAGS) -o ./fisher + $(CC) $(CFLAGS) fisher.c $(LDFLAGS) $(LIBS) -o ./fisher muncher: muncher.c config.h common.h - $(CC) muncher.c $(LDFLAGS) $(CFLAGS) -o ./muncher + $(CC) $(CFLAGS) muncher.c $(LDFLAGS) $(LIBS) -o ./muncher miketron: miketron.c config.h common.h - $(CC) miketron.c $(LDFLAGS) $(CFLAGS) -o ./miketron + $(CC) $(CFLAGS) miketron.c $(LDFLAGS) $(LIBS) -o ./miketron redsquare: redsquare.c config.h - $(CC) redsquare.c $(LDFLAGS) $(CFLAGS) -o ./redsquare + $(CC) $(CFLAGS) redsquare.c $(LDFLAGS) $(LIBS) -o ./redsquare darrt: darrt.c config.h common.h - $(CC) darrt.c $(LDFLAGS) $(CFLAGS) -o ./darrt + $(CC) $(CFLAGS) darrt.c $(LDFLAGS) $(LIBS) -o ./darrt nbsdgames: nbsdgames.c - $(CC) nbsdgames.c $(LDFLAGS) $(CFLAGS) -o ./nbsdgames + $(CC) $(CFLAGS) nbsdgames.c $(LDFLAGS) $(LIBS) -o ./nbsdgames snakeduel: snakeduel.c config.h - $(CC) snakeduel.c $(LDFLAGS) $(CFLAGS) -o ./snakeduel + $(CC) $(CFLAGS) snakeduel.c $(LDFLAGS) $(LIBS) -o ./snakeduel tugow: tugow.c common.h - $(CC) tugow.c $(LDFLAGS) $(CFLAGS) -o ./tugow + $(CC) $(CFLAGS) tugow.c $(LDFLAGS) $(LIBS) -o ./tugow menu: cp nbsdgames.desktop /usr/share/applications cp nbsdgames.svg /usr/share/pixmaps From 81f2fb19c9e4a52becaa7e0d821576b79fc3c378 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:09:46 +0100 Subject: [PATCH 3/9] Makefile: make more generic This should allow further simplification. Signed-off-by: Sam James --- Makefile | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index fa8a7fa..8cbdf98 100644 --- a/Makefile +++ b/Makefile @@ -23,43 +23,43 @@ scorefiles: manpages: cp man/* $(MAN_DIR) jewels: jewels.c config.h common.h - $(CC) $(CFLAGS) jewels.c $(LDFLAGS) $(LIBS) -o ./jewels + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ sudoku: sudoku.c config.h - $(CC) $(CFLAGS) sudoku.c $(LDFLAGS) $(LIBS) -o ./sudoku + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ mines: mines.c config.h - $(CC) $(CFLAGS) mines.c $(LDFLAGS) $(LIBS) -o ./mines + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ reversi: reversi.c config.h - $(CC) $(CFLAGS) reversi.c $(LDFLAGS) $(LIBS) -o ./reversi + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ checkers: checkers.c config.h - $(CC) $(CFLAGS) checkers.c $(LDFLAGS) $(LIBS) -o ./checkers + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ battleship: battleship.c config.h - $(CC) $(CFLAGS) battleship.c $(LDFLAGS) $(LIBS) -o ./battleship + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ rabbithole: rabbithole.c config.h - $(CC) $(CFLAGS) rabbithole.c $(LDFLAGS) $(LIBS) -o ./rabbithole + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ sos: sos.c config.h - $(CC) $(CFLAGS) sos.c $(LDFLAGS) $(LIBS) -o ./sos + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ pipes: pipes.c config.h common.h - $(CC) $(CFLAGS) pipes.c $(LDFLAGS) $(LIBS) -o ./pipes + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ fifteen: fifteen.c config.h - $(CC) $(CFLAGS) fifteen.c $(LDFLAGS) $(LIBS) -o ./fifteen + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ memoblocks: memoblocks.c - $(CC) $(CFLAGS) memoblocks.c $(LDFLAGS) $(LIBS) -o ./memoblocks + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ fisher: fisher.c config.h common.h - $(CC) $(CFLAGS) fisher.c $(LDFLAGS) $(LIBS) -o ./fisher + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ muncher: muncher.c config.h common.h - $(CC) $(CFLAGS) muncher.c $(LDFLAGS) $(LIBS) -o ./muncher + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ miketron: miketron.c config.h common.h - $(CC) $(CFLAGS) miketron.c $(LDFLAGS) $(LIBS) -o ./miketron + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ redsquare: redsquare.c config.h - $(CC) $(CFLAGS) redsquare.c $(LDFLAGS) $(LIBS) -o ./redsquare + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ darrt: darrt.c config.h common.h - $(CC) $(CFLAGS) darrt.c $(LDFLAGS) $(LIBS) -o ./darrt + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ nbsdgames: nbsdgames.c - $(CC) $(CFLAGS) nbsdgames.c $(LDFLAGS) $(LIBS) -o ./nbsdgames + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ snakeduel: snakeduel.c config.h - $(CC) $(CFLAGS) snakeduel.c $(LDFLAGS) $(LIBS) -o ./snakeduel + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ tugow: tugow.c common.h - $(CC) $(CFLAGS) tugow.c $(LDFLAGS) $(LIBS) -o ./tugow + $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ menu: cp nbsdgames.desktop /usr/share/applications cp nbsdgames.svg /usr/share/pixmaps From 8f4beee8f959ea6b898a4663d8be235e1035267b Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:12:05 +0100 Subject: [PATCH 4/9] Makefile: respect DESTDIR This makes it a _lot_ easier for packaging where we always pass this. It allows creating a "staging area" where everything will be installed to. Signed-off-by: Sam James --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8cbdf98..01d9d59 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,11 @@ SCORE_FILES= pipes_scores jewels_scores miketron_scores muncher_scores fisher_sc all: $(ALL) scorefiles: - for sf in $(SCORE_FILES); do touch $(SCORES_DIR)/$$sf ; chmod 664 $(SCORES_DIR)/$$sf; chown :games $(SCORES_DIR)/$$sf ; done; - for game in $(ALL); do chown :games $(GAMES_DIR)/$$game; chmod g $(GAMES_DIR)/$$game ; done; + for sf in $(SCORE_FILES); do touch $(DESTDIR)$(SCORES_DIR)/$$sf ; chmod 664 $(DESTDIR)$(SCORES_DIR)/$$sf; chown :games $(DESTDIR)$(SCORES_DIR)/$$sf ; done; + for game in $(ALL); do chown :games $(DESTDIR)$(GAMES_DIR)/$$game; chmod g $(DESTDIR)$(GAMES_DIR)/$$game ; done; manpages: - cp man/* $(MAN_DIR) + cp man/* $(DESTDIR)$(MAN_DIR) jewels: jewels.c config.h common.h $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ sudoku: sudoku.c config.h @@ -61,14 +61,14 @@ snakeduel: snakeduel.c config.h tugow: tugow.c common.h $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ menu: - cp nbsdgames.desktop /usr/share/applications - cp nbsdgames.svg /usr/share/pixmaps + cp nbsdgames.desktop $(DESTIDR)/usr/share/applications + cp nbsdgames.svg $(DESTDIR)/usr/share/pixmaps clean: for game in $(ALL); do rm $$game; done; uninstall: for game in $(ALL); do rm $(GAMES_DIR)/$$game; rm $(MAN_DIR)/$$game.6.gz ;done; install: $(ALL) - cp $(ALL) $(GAMES_DIR) + cp $(ALL) $(DESTDIR)/$(GAMES_DIR) test: for game in $(ALL); do ./$$game ;done; @@ -78,8 +78,8 @@ nb: for game in $(ALL); do cp $$game nb$$game ;done; for manpage in $(ls man); do cp man/$$manpage man/nb$$manpage ;done; nbinstall: nb - cp nb* $(GAMES_DIR) + cp nb* $(DESTDIR)/$(GAMES_DIR) nbmanpages: nb - cp man/nb* $(MAN_DIR) + cp man/nb* $(DESTDIR)/$(MAN_DIR) nbclean: for game in $(ALL); do rm nb$$game; done; From 0130773b31fd3391f8677da858a9de1a526050dd Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:13:38 +0100 Subject: [PATCH 5/9] Makefile: respect PREFIX Allows easily appending a prefix to all variables. Again, a standard used frequently by packagers. Not just for things like Gentoo Prefix but also e.g. macports where everything ends up installed in some path beginning with /usr/local, or /opt, or ... Signed-off-by: Sam James --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 01d9d59..5f2a56e 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ #-O3 --std=c99 -lcurses -DNO_MOUSE for NetBSD curses #adding --std=c99 makes warnings in GNU, and the blame is upon glibc feature test macros. my code is correct. -GAMES_DIR?=/usr/games -SCORES_DIR?=/var/games -MAN_DIR?=/usr/share/man/man6 -CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(SCORES_DIR)\" +GAMES_DIR?=$(PREFIX)/usr/games +SCORES_DIR?=$(PREFIX)/var/games +MAN_DIR?=$(PREFIX)/usr/share/man/man6 +CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(PREFIX)$(SCORES_DIR)\" PKG-CONFIG?=pkg-config LIBS=$(shell pkg-config --libs --cflags ncurses) -lm @@ -61,8 +61,8 @@ snakeduel: snakeduel.c config.h tugow: tugow.c common.h $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ menu: - cp nbsdgames.desktop $(DESTIDR)/usr/share/applications - cp nbsdgames.svg $(DESTDIR)/usr/share/pixmaps + cp nbsdgames.desktop $(DESTIDR)$(PREFIX)/usr/share/applications + cp nbsdgames.svg $(DESTDIR)$(PREFIX)/usr/share/pixmaps clean: for game in $(ALL); do rm $$game; done; uninstall: From f0f86e17f517eca142caf9954950c31627baed57 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:14:34 +0100 Subject: [PATCH 6/9] Makefile: use $(MAKE), not make Calling 'make' directly prevents parallel builds as the jobserver fds are lost (and any flags). Signed-off-by: Sam James --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5f2a56e..a34df61 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ test: #######for namespacing ####### nb: - CFLAGS="$$CFLAGS -D NB=\\\"nb\\\"" make + CFLAGS="$$CFLAGS -D NB=\\\"nb\\\"" $(MAKE) for game in $(ALL); do cp $$game nb$$game ;done; for manpage in $(ls man); do cp man/$$manpage man/nb$$manpage ;done; nbinstall: nb From 49306e592df32ff550c81cacf973f222ef88085b Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:16:37 +0100 Subject: [PATCH 7/9] Makefile: rename *_DIR -> *DIR This matches convention better. Signed-off-by: Sam James --- Makefile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index a34df61..b07782b 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,10 @@ #-O3 --std=c99 -lcurses -DNO_MOUSE for NetBSD curses #adding --std=c99 makes warnings in GNU, and the blame is upon glibc feature test macros. my code is correct. -GAMES_DIR?=$(PREFIX)/usr/games -SCORES_DIR?=$(PREFIX)/var/games -MAN_DIR?=$(PREFIX)/usr/share/man/man6 -CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(PREFIX)$(SCORES_DIR)\" -PKG-CONFIG?=pkg-config +GAMESDIR?=$(PREFIX)/usr/games +SCORESDIR?=$(PREFIX)/var/games +MANDIR?=$(PREFIX)/usr/share/man/man6 +CFLAGS=-Wno-unused-result -DSCORES_DIR=\"$(PREFIX)$(SCORESDIR)\" LIBS=$(shell pkg-config --libs --cflags ncurses) -lm @@ -17,11 +16,11 @@ SCORE_FILES= pipes_scores jewels_scores miketron_scores muncher_scores fisher_sc all: $(ALL) scorefiles: - for sf in $(SCORE_FILES); do touch $(DESTDIR)$(SCORES_DIR)/$$sf ; chmod 664 $(DESTDIR)$(SCORES_DIR)/$$sf; chown :games $(DESTDIR)$(SCORES_DIR)/$$sf ; done; - for game in $(ALL); do chown :games $(DESTDIR)$(GAMES_DIR)/$$game; chmod g $(DESTDIR)$(GAMES_DIR)/$$game ; done; + for sf in $(SCORE_FILES); do touch $(DESTDIR)$(SCORESDIR)/$$sf ; chmod 664 $(DESTDIR)$(SCORESDIR)/$$sf; chown :games $(DESTDIR)$(SCORESDIR)/$$sf ; done; + for game in $(ALL); do chown :games $(DESTDIR)$(GAMESDIR)/$$game; chmod g $(DESTDIR)$(GAMESDIR)/$$game ; done; manpages: - cp man/* $(DESTDIR)$(MAN_DIR) + cp man/* $(DESTDIR)$(MANDIR) jewels: jewels.c config.h common.h $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ sudoku: sudoku.c config.h @@ -66,9 +65,9 @@ menu: clean: for game in $(ALL); do rm $$game; done; uninstall: - for game in $(ALL); do rm $(GAMES_DIR)/$$game; rm $(MAN_DIR)/$$game.6.gz ;done; + for game in $(ALL); do rm $(GAMESDIR)/$$game; rm $(MANDIR)/$$game.6.gz ;done; install: $(ALL) - cp $(ALL) $(DESTDIR)/$(GAMES_DIR) + cp $(ALL) $(DESTDIR)/$(GAMESDIR) test: for game in $(ALL); do ./$$game ;done; @@ -78,8 +77,8 @@ nb: for game in $(ALL); do cp $$game nb$$game ;done; for manpage in $(ls man); do cp man/$$manpage man/nb$$manpage ;done; nbinstall: nb - cp nb* $(DESTDIR)/$(GAMES_DIR) + cp nb* $(DESTDIR)/$(GAMESDIR) nbmanpages: nb - cp man/nb* $(DESTDIR)/$(MAN_DIR) + cp man/nb* $(DESTDIR)/$(MANDIR) nbclean: for game in $(ALL); do rm nb$$game; done; From beffffa61487002e5ad108005d01c6348db6319b Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:45:14 +0100 Subject: [PATCH 8/9] Makefile: factor out rules as much as possible Signed-off-by: Sam James --- Makefile | 57 ++++++++++++++++++-------------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index b07782b..bee66d6 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ GAMESDIR?=$(PREFIX)/usr/games SCORESDIR?=$(PREFIX)/var/games MANDIR?=$(PREFIX)/usr/share/man/man6 -CFLAGS=-Wno-unused-result -DSCORES_DIR=\"$(PREFIX)$(SCORESDIR)\" +CFLAGS+= -Wno-unused-result -DSCORES_DIR=\"$(PREFIX)$(SCORESDIR)\" LIBS=$(shell pkg-config --libs --cflags ncurses) -lm @@ -21,44 +21,23 @@ scorefiles: manpages: cp man/* $(DESTDIR)$(MANDIR) -jewels: jewels.c config.h common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -sudoku: sudoku.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -mines: mines.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -reversi: reversi.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -checkers: checkers.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -battleship: battleship.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -rabbithole: rabbithole.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -sos: sos.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -pipes: pipes.c config.h common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -fifteen: fifteen.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -memoblocks: memoblocks.c - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -fisher: fisher.c config.h common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -muncher: muncher.c config.h common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -miketron: miketron.c config.h common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -redsquare: redsquare.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -darrt: darrt.c config.h common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -nbsdgames: nbsdgames.c - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -snakeduel: snakeduel.c config.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ -tugow: tugow.c common.h - $(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@ + +# Games which only need config.h +sudoku mines reversi checkers battleship rabbithole sos fifteen redsquare snakeduel: config.h + $(CC) $(CFLAGS) $@.c $< $(LDFLAGS) $(LIBS) -o $@ + +# Games which need config.h and common.h +jewels pipes fisher muncher miketron darrt: config.h common.h + $(CC) $(CFLAGS) $@.c $< $(LDFLAGS) $(LIBS) -o $@ + +# Games which only need common.h +tugow: common.h + $(CC) $(CFLAGS) $@.c $< $(LDFLAGS) $(LIBS) -o $@ + +# Games which only need themselves +memoblocks nbsdgames: + $(CC) $(CFLAGS) $@.c $< $(LDFLAGS) $(LIBS) -o $@ + menu: cp nbsdgames.desktop $(DESTIDR)$(PREFIX)/usr/share/applications cp nbsdgames.svg $(DESTDIR)$(PREFIX)/usr/share/pixmaps From 06f6b735052e4c775377209cda9d0bb5e5b0bba0 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 31 Mar 2022 04:48:05 +0100 Subject: [PATCH 9/9] Makefile: fix GNUism in Makefile (fix bmake) Apparently even $(shell isn't supported by bmake? Signed-off-by: Sam James --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bee66d6..8a74b7d 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,8 @@ GAMESDIR?=$(PREFIX)/usr/games SCORESDIR?=$(PREFIX)/var/games MANDIR?=$(PREFIX)/usr/share/man/man6 CFLAGS+= -Wno-unused-result -DSCORES_DIR=\"$(PREFIX)$(SCORESDIR)\" -LIBS=$(shell pkg-config --libs --cflags ncurses) -lm +LIBS_PKG_CONFIG!=pkg-config --libs --cflags ncurses +LIBS=$(LIBS_PKG_CONFIG) -lm ALL= nbsdgames jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare darrt snakeduel tugow