Kaynağa Gözat

Remove the need for makehelp

Bryan Drewery 11 yıl önce
ebeveyn
işleme
8456fcb6c2
4 değiştirilmiş dosya ile 54 ekleme ve 23 silme
  1. 5 17
      Makefile.in
  2. 42 0
      build/makehelp.sh
  3. 0 1
      src/.gitignore
  4. 7 5
      src/Makefile.in

+ 5 - 17
Makefile.in

@@ -73,14 +73,14 @@ MAKE_UTILS_NR = $(MAKE) 'CXX=$(CXX)' 'STRIP=touch' 'INCLUDES=$(INCLUDES)' \
 
 MAKE_CONFIG = $(MAKE) 'MAKE=$(MAKE)'
 
-.PHONY: checkclean.static checkclean.dynamic checkclean.debug lib wraith dwraith lib.debug debug test general crypto utils sorthelp makehelp stringfix help sort indent tar distrib distclean clean cleanutils test all dynamic static tags
+.PHONY: checkclean.static checkclean.dynamic checkclean.debug lib wraith dwraith lib.debug debug test general crypto utils sorthelp stringfix sort indent tar distrib distclean clean cleanutils test all dynamic static tags
 
 all: dynamic
 
 test:
 
 cleanutils:
-	@rm -f $(STRINGFIX) src/sorthelp@EXEEXT@ src/makehelp@EXEEXT@
+	@rm -f $(STRINGFIX) src/sorthelp@EXEEXT@
 
 clean:  cleanutils
 	+@cd src && $(MAKE) clean
@@ -89,7 +89,7 @@ clean:  cleanutils
 	+@cd src/mod && $(MAKE) clean
 	-+@cd lib && $(MAKE) clean
 	@rm -f $(BINEXEC) build/stamp.* *~ src/*~ configure.temp .mangled stamp.*
-	@rm -f src/help.h utctime@EXEEXT@ ts@EXEEXT@
+	@rm -f utctime@EXEEXT@ ts@EXEEXT@
 
 distclean: clean
 	@rm -rf *-$(VERSION)/ autom4te.cache/ autoscan.log configure.scan
@@ -144,30 +144,18 @@ sort: sorthelp
 	@(src/sorthelp@EXEEXT@ $(HELPFILE) $(HELPFILE) || (cp -f help.txt~ $(HELPFILE); echo "Sort failed, restoring backup."))
 	@rm -f help.txt~
 
-help: makehelp
-	@src/makehelp@EXEEXT@ $(HELPFILE) src/help.h~
-	@(if [ ! -f src/help.h ]; then \
-	touch src/help.h; \
-	fi)
-	@(if test "x`$(DIFF) -qurN src/help.h~ src/help.h`" != "x"; then \
-	cp -f src/help.h~ src/help.h; \
-	fi)
-
 stringfix: src/stringfix.cc src/config.h
 	+@cd src && ${MAKE_UTILS} stringfix
 
-makehelp: src/makehelp.cc
-	+@cd src && ${MAKE_UTILS} makehelp
-
 sorthelp: src/sorthelp.cc
 	+@cd src && ${MAKE_UTILS} sorthelp
 
-utils: stringfix makehelp
+utils: stringfix
 
 crypto:
 	+@cd src/crypto && ${MAKE_UTILS} crypto
 
-general: help stringfix
+general: stringfix
 
 .NOTPARALLEL: checkclean.static checkclean.dynamic checkclean.debug
 

+ 42 - 0
build/makehelp.sh

@@ -0,0 +1,42 @@
+#! /bin/sh
+
+echo "/* Generated by $0 */"
+echo "#include \"cmds.h\""
+echo "help_t help[] = {"
+needcomma=0
+IFS="
+"
+sed -e 's,["],\\&,g' | while read -r line; do
+	if [ -z "${line%%:*}" ]; then
+		if [ ${needcomma} -eq 1 ]; then
+			printf "\""
+			[ ${garble} -eq 1 ] && printf ")"
+			printf "},\n"
+		fi
+		line="${line#:}"
+		garble=0
+		if [ "${line%:}" != "${line}" ]; then
+			garble=1
+			line="${line%:}"
+		fi
+		type="${line%:*}"
+		cmd="${line#*:}"
+		[ "${cmd}" = "end" ] && break
+		case ${type} in
+			hub)  type_int=1 ;;
+			leaf) type_int=2 ;;
+			*)    type_int=0 ;;
+		esac
+
+		if [ ${garble} -eq 0 ]; then
+			printf "  {%d, \"%s\", %d, \"" ${type_int} "${cmd}" ${garble}
+		else
+			printf "  {%d, \"%s\", %d, STR(\"" ${type_int} "${cmd}" ${garble}
+	fi
+		needcomma=0
+	else
+		printf "%s\\\n" "${line}"
+		needcomma=1
+	fi
+done
+echo "};"

+ 0 - 1
src/.gitignore

@@ -8,7 +8,6 @@
 /.deps
 /.defs
 /stringfix
-/makehelp
 /sorthelp
 /set_default.h
 *.o

+ 7 - 5
src/Makefile.in

@@ -13,6 +13,7 @@ CPPFLAGS = @CPPFLAGS@ -I. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/pa
 LDFLAGS = @LDFLAGS@
 SETTINGSFILE = $(top_srcdir)/doc/settings.txt
 RESPONSESFILE = $(top_srcdir)/doc/responses.txt
+HELPFILE = $(top_srcdir)/doc/help.txt
 
 include $(top_srcdir)/build/build.mk
 
@@ -90,10 +91,11 @@ responses.cc: $(RESPONSESFILE) $(top_srcdir)/build/makeres.sh
 	@echo -e "[CC]	\033[1m$*\033[0m"
 	@$(top_srcdir)/build/makeres.sh < $(RESPONSESFILE) > $@
 
-makehelp: makehelp.cc ../lib/bdlib/src/libbdlib.a
-	@echo -e "Compiling: \033[1mmakehelp\033[0m"
-	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/src/libbdlib.a $(LDFLAGS) -o $@
-	@$(STRIP) $@@EXEEXT@
+cmds.cc: help.h
+
+help.h: $(HELPFILE) $(top_srcdir)/build/makehelp.sh
+	@echo -e "[H]	\033[1m$*\033[0m"
+	@$(top_srcdir)/build/makehelp.sh < $(HELPFILE) > $@
 
 sorthelp: sorthelp.cc ../lib/bdlib/src/libbdlib.a
 	@echo -e "Compiling: \033[1msorthelp\033[0m"
@@ -120,7 +122,7 @@ stringfix: stringfix.cc common.h config.h eggdrop.h
 $(EGGEXEC): stringfix ../$(EGGEXEC)
 
 clean:
-	@rm -f .depend *.o *.So *~ _*.c _*.cc *.ii *.i set_default.h responses.cc
+	@rm -f .depend *.o *.So *~ _*.c _*.cc *.ii *.i set_default.h responses.cc help.h
 
 build_msg:
 	@echo "[*] Compiling core components"