Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,19 @@ all_objects =

$(foreach program,$(programs),$(eval $(call program_template,$(program))))

# hhss.c requires a special care since it needs INSTPATH
inst_prefix := /usr/local
datadir := $(inst_prefix)/share/hhss
$(hhss_path)/hhss.o: $(hhss_path)/hhss.c
$(CC) $(CFLAGS) -DINSTPATH='"$(datadir)"' -o $@ -c $<

## Auxiliary Tasks
.PHONY: install
INSTALL := install
INSTALL_PROGRAM := $(INSTALL)
INSTALL_DATA := $(INSTALL) -m 644
install_path := ./bin
bindir := $(install_path)
datadir := $(install_path)/data

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)
Expand All @@ -88,7 +93,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))

Expand All @@ -107,7 +113,8 @@ $(test_path)/test_maker: $(test_path)/test_maker.o

.PHONY: uninstall
uninstall:
rm -rf $(install_path)
rm -rf $(foreach program,$(programs),$(bindir)/$(program))
rm -rf $(datadir)

.PHONY: clean
clean:
Expand All @@ -129,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)
Expand Down
14 changes: 9 additions & 5 deletions hhss/c/hhss.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
#define MIN_USER_NUM 1
#
#define COMMENT '#'

char *arg_num_sentence_to_print = "argv[1]";
char *sentence_file = "hsr.dat";
char *user_file = "usr.dat";
char *user_template = "${user}";
#
#ifndef INSTPATH
#define INSTPATH "../" /* install path; given when built */
#endif

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);
Expand Down
Loading