COMMON_DIR = $(SRCDIR)/common
COMMON_LIB = $(COMMON_DIR)/frotz_common.a
-COMMON_DEFINES = $(COMMON_DIR)/version.c
+COMMON_STRINGS = $(COMMON_DIR)/version.c
+COMMON_DEFINES = $(COMMON_DIR)/defines.h
HASH = $(COMMON_DIR)/git_hash.h
CURSES_DIR = $(SRCDIR)/curses
blorb_lib: $(BLORB_LIB)
-# Defines
+# Compile-time generated defines and strings
-common_defines: $(COMMON_DEFINES)
-$(COMMON_DEFINES):
+common_strings: $(COMMON_STRINGS)
+$(COMMON_STRINGS):
@echo "Generating $@"
@echo "#include \"frotz.h\"" > $@
@echo "const char frotz_version[] = \"$(VERSION)\";" >> $@
@echo "const char frotz_v_minor[] = \"$(MINOR)\";" >> $@
@echo "const char frotz_v_build[] = \"$(BUILD_DATE_TIME)\";" >> $@
+common_defines: $(COMMON_DEFINES)
+$(COMMON_DEFINES):
+ @echo "Generating $@"
+ @echo "#ifndef COMMON_DEFINES_H" > $@
+ @echo "#define COMMON_DEFINES_H" >> $@
+ifdef NO_MEMMOVE
+ @echo "#define NO_MEMMOVE" >> $@
+endif
+ @echo "#endif /* COMMON_DEFINES_H */" >> $@
+
curses_defines: $(CURSES_DEFINES)
$(CURSES_DEFINES):
@echo "Generating $@"
@echo "#define COLOR_SUPPORT" >> $@
endif
-ifdef NO_MEMMOVE
- @echo "#define NO_MEMMOVE" >> $@
-endif
-
@echo "#endif /* CURSES_DEFINES_H */" >> $@
blorb_lib common_lib curses_lib dumb_lib \
install install_dfrotz install_dumb \
uninstall uninstall_dfrotz uninstall_dumb $(SUBDIRS) $(SUB_CLEAN) \
- $(COMMON_DIR)/version.c $(CURSES_DIR)/defines.h
+ $(COMMON_DIR)/defines.h $(COMMON_DIR)/version.c $(CURSES_DIR)/defines.h
# For GNU Make.
SOURCES = buffer.c err.c fastmem.c files.c getopt.c hotkey.c input.c \
- main.c math.c object.c process.c quetzal.c random.c redirect.c \
- screen.c sound.c stream.c table.c text.c variable.c version.c
+ main.c math.c missing.c object.c process.c quetzal.c random.c \
+ redirect.c screen.c sound.c stream.c table.c text.c variable.c \
+ version.c
HEADERS = frotz.h setup.h unused.h
#include "setup.h"
+#include "defines.h"
+#include "missing.h"
#include "unused.h"
/*** Constants that may be set at compile time ***/
--- /dev/null
+/*
+ * missing.c - Assorted standard functions that may be missing on older systems
+ * Written by David Griffith <dave@661.org>
+ *
+ * This file is part of Frotz.
+ *
+ * Frotz is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Frotz is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "frotz.h"
+
+#ifdef NO_MEMMOVE
+/*
+ * Unix-ish operating systems based on 4.2BSD or older or SYSVR3 or older
+ * lack the memmove(3) system call.
+ *
+ */
+void *my_memmove(void *dest, const void *src, size_t n)
+{
+ char *d =(char *)dest;
+ char *s =(char *)src;
+
+ if(s == d) return dest;
+
+ if(s < d) { // copy from back
+ s=s+n-1;
+ d=d+n-1;
+ while(n--) *d-- = *s--;
+ } else // copy from front
+ while(n--) *d++=*s++;
+
+ return dest;
+}
+#endif /* NO_MEMMOVE */
--- /dev/null
+/*
+ * missing.h
+ *
+ * Declarations and definitions for standard things that may be missing
+ * on older systems.
+ *
+ */
+
+#ifndef MISSING_H
+#define MISSING_H
+
+#ifdef NO_MEMMOVE
+void *my_memmove(void *, const void *, size_t);
+#define memmove my_memmove
+#endif
+
+
+#endif /* MISSING_H */
*
*/
+#ifndef UX_FROTZ_H
+#define UX_FROTZ_H
+
#include <signal.h>
#include "defines.h"
char *strrchr(const char *, int);
#endif
-#ifdef NO_MEMMOVE
-void *memmove(void *, void *);
-#endif
+#endif /* UX_FROTZ_H */
*/
-#ifdef NO_MEMMOVE
-/*
- * This is for operating systems based on 4.2BSD or older or SYSVR3 or
- * older. Since they lack the memmove(3) system call, it is provided
- * here. Because I don't have a machine like this to play with, this code
- * is untested. If you happen to have a spare SunOS 4.1.x install CD
- * lying around, please consider sending it my way. Dave.
- *
- */
-void *memmove(void *s, void *t, size_t n)
-{
- char *p = s; char *q = t;
-
- if (p < q) {
- while (n--) *p++ = *q++;
- } else {
- p += n; q += n;
- while (n--) *--p = *--q;
- }
- return;
-}
-
-#endif /* NO_MEMMOVE */
-
-
/*
* Search for start of preceding word
* param currpos marker position