From 575e0adf7d897d3956a00c90d0fe70abd296ef6d Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 17:17:56 +0900 Subject: [PATCH 01/13] feat: pass an installation path when `hhss` is built --- Makefile | 10 ++++++++-- hhss/c/hhss.c | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 13dc2f7..57086bf 100644 --- a/Makefile +++ b/Makefile @@ -65,14 +65,20 @@ all_objects = $(foreach program,$(programs),$(eval $(call program_template,$(program)))) +### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### +install_path := $(CURDIR)/bin +datadir := $(install_path)/data +hhss/c/hhss.o: hhss/c/hhss.c + gcc -DINSTPATH='"$(datadir)/"' -c hhss/c/hhss.c -o hhss/c/hhss.o +### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### + ## Auxiliary Tasks .PHONY: install INSTALL := install INSTALL_PROGRAM := $(INSTALL) INSTALL_DATA := $(INSTALL) -m 644 -install_path := ./bin + bindir := $(install_path) -datadir := $(install_path)/data hhss_data := hsr usr program_installation_cmd := $(INSTALL_PROGRAM) ./$$i/c/$$i $(bindir) data_installation_cmd := $(INSTALL_DATA) ./hhss/$$i $(datadir) diff --git a/hhss/c/hhss.c b/hhss/c/hhss.c index 8785df2..fa56e8a 100644 --- a/hhss/c/hhss.c +++ b/hhss/c/hhss.c @@ -36,10 +36,14 @@ #define MIN_USER_NUM 1 # #define COMMENT '#' +# +#ifndef INSTPATH +#define INSTPATH "../" /* install path; given when built */ +#endif char *arg_num_sentence_to_print = "argv[1]"; -char *sentence_file = "hsr.dat"; -char *user_file = "usr.dat"; +char *sentence_file = INSTPATH "hsr.dat"; +char *user_file = INSTPATH "usr.dat"; char *user_template = "${user}"; void raise_err(char *err_msg, ...); From c23b8e2b80ca263c5c548f0589d2e75429d75643 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 19:06:42 +0900 Subject: [PATCH 02/13] fix: use `$(CC)` and `$(CFLAGS)` for consistent build --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 57086bf..a00cf33 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ $(foreach program,$(programs),$(eval $(call program_template,$(program)))) install_path := $(CURDIR)/bin datadir := $(install_path)/data hhss/c/hhss.o: hhss/c/hhss.c - gcc -DINSTPATH='"$(datadir)/"' -c hhss/c/hhss.c -o hhss/c/hhss.o + $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)/"' -c hhss/c/hhss.c -o hhss/c/hhss.o ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### ## Auxiliary Tasks From 90314aeda2826b724a601f43ec9de5e8be4b579b Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 19:17:28 +0900 Subject: [PATCH 03/13] fix: use Makefile variables instead of hardcoded values --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a00cf33..5dde987 100644 --- a/Makefile +++ b/Makefile @@ -68,8 +68,8 @@ $(foreach program,$(programs),$(eval $(call program_template,$(program)))) ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### install_path := $(CURDIR)/bin datadir := $(install_path)/data -hhss/c/hhss.o: hhss/c/hhss.c - $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)/"' -c hhss/c/hhss.c -o hhss/c/hhss.o +$(hhss_path)/hhss.o: $(hhss_path)/hhss.c + $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)/"' -o $@ -c $< ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### ## Auxiliary Tasks From bdacc74dc26f9620f6985bb01497cd962c0e42fe Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 20:06:35 +0900 Subject: [PATCH 04/13] fix: use relocatable paths --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5dde987..7961daa 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,8 @@ all_objects = $(foreach program,$(programs),$(eval $(call program_template,$(program)))) ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### -install_path := $(CURDIR)/bin -datadir := $(install_path)/data +prefix := usr/local +datadir := $(prefix)/share/hhss $(hhss_path)/hhss.o: $(hhss_path)/hhss.c $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)/"' -o $@ -c $< ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### @@ -78,7 +78,7 @@ INSTALL := install INSTALL_PROGRAM := $(INSTALL) INSTALL_DATA := $(INSTALL) -m 644 -bindir := $(install_path) +bindir := $(prefix)/bin hhss_data := hsr usr program_installation_cmd := $(INSTALL_PROGRAM) ./$$i/c/$$i $(bindir) data_installation_cmd := $(INSTALL_DATA) ./hhss/$$i $(datadir) From 11b005c3ea05afb3c49c13218a6c631507ab50a2 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 20:07:06 +0900 Subject: [PATCH 05/13] fix: update `install` and `uninstall` recipes --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7961daa..2412049 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,8 @@ done endef install: - test -d $(install_path) || (mkdir $(bindir) && mkdir $(datadir)) + test -d $(bindir) || (mkdir $(bindir)) + test -d $(datadir) || (mkdir $(datadir)) $(call installation_template,$(programs),$(program_installation_cmd)) $(call installation_template,$(hhss_data:%=%.dat),$(data_installation_cmd)) @@ -113,7 +114,8 @@ $(test_path)/test_maker: $(test_path)/test_maker.o .PHONY: uninstall uninstall: - rm -rf $(install_path) + rm -rf $(bindir)/$(programs) + rm -rf $(datadir) .PHONY: clean clean: From 6e639b5fe0068dab920018d406fd0100d5efa37d Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 20:11:09 +0900 Subject: [PATCH 06/13] fix: place preceding slashes in front of the filenames --- hhss/c/hhss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hhss/c/hhss.c b/hhss/c/hhss.c index fa56e8a..13db56e 100644 --- a/hhss/c/hhss.c +++ b/hhss/c/hhss.c @@ -42,8 +42,8 @@ #endif char *arg_num_sentence_to_print = "argv[1]"; -char *sentence_file = INSTPATH "hsr.dat"; -char *user_file = INSTPATH "usr.dat"; +char *sentence_file = INSTPATH "/hsr.dat"; +char *user_file = INSTPATH "/usr.dat"; char *user_template = "${user}"; void raise_err(char *err_msg, ...); From 08a421b05146d8e4f4efea64293cc8b4b2ca9321 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 20:14:09 +0900 Subject: [PATCH 07/13] fix: use `const char *` --- hhss/c/hhss.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hhss/c/hhss.c b/hhss/c/hhss.c index 13db56e..a08c88e 100644 --- a/hhss/c/hhss.c +++ b/hhss/c/hhss.c @@ -41,10 +41,10 @@ #define INSTPATH "../" /* install path; given when built */ #endif -char *arg_num_sentence_to_print = "argv[1]"; -char *sentence_file = INSTPATH "/hsr.dat"; -char *user_file = INSTPATH "/usr.dat"; -char *user_template = "${user}"; +const char *arg_num_sentence_to_print = "argv[1]"; +const char *sentence_file = INSTPATH "/hsr.dat"; +const char *user_file = INSTPATH "/usr.dat"; +const char *user_template = "${user}"; void raise_err(char *err_msg, ...); FILE *open_file(char *name, char *mode); From f7a74cd5f39f4ea638e290869bb07355c9751c52 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 21:11:14 +0900 Subject: [PATCH 08/13] fix: `usr/local` -> `/usr/local` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2412049..f11654b 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ all_objects = $(foreach program,$(programs),$(eval $(call program_template,$(program)))) ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### -prefix := usr/local +prefix := /usr/local datadir := $(prefix)/share/hhss $(hhss_path)/hhss.o: $(hhss_path)/hhss.c $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)/"' -o $@ -c $< From 5391eb3c382dafcfa34111fcb26c0c5eed93fa08 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 21:12:41 +0900 Subject: [PATCH 09/13] fix: remove an unnecessary slash --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f11654b..162db31 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ $(foreach program,$(programs),$(eval $(call program_template,$(program)))) prefix := /usr/local datadir := $(prefix)/share/hhss $(hhss_path)/hhss.o: $(hhss_path)/hhss.c - $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)/"' -o $@ -c $< + $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)"' -o $@ -c $< ### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### ## Auxiliary Tasks From f416ac8b0080a9de06c62a7b6cb96f7e5295ad83 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 21:15:12 +0900 Subject: [PATCH 10/13] fix: provide `rm` appropriate paths --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 162db31..2c7c63f 100644 --- a/Makefile +++ b/Makefile @@ -114,7 +114,7 @@ $(test_path)/test_maker: $(test_path)/test_maker.o .PHONY: uninstall uninstall: - rm -rf $(bindir)/$(programs) + rm -rf $(foreach program,$(programs),$(bindir)/$(program)) rm -rf $(datadir) .PHONY: clean From 74542f73d843e5da2fb3fe1c69895e09980c23ea Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 21:17:13 +0900 Subject: [PATCH 11/13] fix: write a proper comment --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2c7c63f..b924d01 100644 --- a/Makefile +++ b/Makefile @@ -65,12 +65,11 @@ all_objects = $(foreach program,$(programs),$(eval $(call program_template,$(program)))) -### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### +# hhss.c requires a special care since it needs INSTPATH prefix := /usr/local datadir := $(prefix)/share/hhss $(hhss_path)/hhss.o: $(hhss_path)/hhss.c $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)"' -o $@ -c $< -### THIS IS A VERY QUICK FIX AND NEEDS A LATER CARE ### ## Auxiliary Tasks .PHONY: install From fe16d6eaa00d4772787f6d9ec422b25040b23d68 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 22:02:11 +0900 Subject: [PATCH 12/13] fix: use a more specific variable name --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b924d01..e6f8477 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,8 @@ all_objects = $(foreach program,$(programs),$(eval $(call program_template,$(program)))) # hhss.c requires a special care since it needs INSTPATH -prefix := /usr/local -datadir := $(prefix)/share/hhss +inst_prefix := /usr/local +datadir := $(inst_prefix)/share/hhss $(hhss_path)/hhss.o: $(hhss_path)/hhss.c $(CC) $(CFLAGS) -DINSTPATH='"$(datadir)"' -o $@ -c $< @@ -77,7 +77,7 @@ INSTALL := install INSTALL_PROGRAM := $(INSTALL) INSTALL_DATA := $(INSTALL) -m 644 -bindir := $(prefix)/bin +bindir := $(inst_prefix)/bin hhss_data := hsr usr program_installation_cmd := $(INSTALL_PROGRAM) ./$$i/c/$$i $(bindir) data_installation_cmd := $(INSTALL_DATA) ./hhss/$$i $(datadir) From 9e63b180d97fd2a7be027a271eff41d2f8e18b06 Mon Sep 17 00:00:00 2001 From: Doohyeon Won Date: Wed, 20 May 2026 22:04:12 +0900 Subject: [PATCH 13/13] fix: correct the `help` recipe --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e6f8477..5d8f5ca 100644 --- a/Makefile +++ b/Makefile @@ -136,11 +136,11 @@ help: @echo " make builds every program." @echo " make "$(call cmd_color,program-names...) @echo " builds mentioned program(s) only, e.g. make btn nsy" - @echo " make "$(call cmd_color,install)" copies the executables of each program into ./bin directory." + @echo " make "$(call cmd_color,install)" copies the executables of each program into $(bindir) directory." @echo @echo $(call cmd_group,2. CLEANING ACTIONS) @echo " make "$(call cmd_color,clean)" deletes all object files and all executables." - @echo " make "$(call cmd_color,uninstall)" deletes everything under ./bin directory." + @echo " make "$(call cmd_color,uninstall)" deletes everything under $(bindir) directory." @echo " make "$(call cmd_color,cleanall)" clean + uninstall + some files in ./test" @echo @echo $(call cmd_group,3. MISCELLANEOUS)