Commit 9566797b authored by Peter Pentchev's avatar Peter Pentchev

Autogenerate config.h.

parent eda523ed
......@@ -8,15 +8,13 @@ Change log for hexer, the multi-view binary editor
- fix an overzealous double const
- add a Makefile rule for the compilation of C files for
make(1) implementations that do not pass CPPFLAGS.
- deprecate config.* except for config.posix and config.linux
- clarify a README comment about the unpacked subdirectory
- drop the HAVE_NCURSES configuration setting, the support for
changing the foreground and background color is autodeteted
- drop the config.bsd file altogether, it has become identical to
config.posix now
- drop the bundled termlib implementation, require termcap support
- drop the stubs for old-style termio support, the hexer code only
works with termios anyway
- drop the config.* files and autogenerate config.h
0.2.3 2015/12/10
- build with large file support on Linux
......
......@@ -62,14 +62,7 @@ CTAGS = ctags -tawf tags
OBJECTS = buffer.o tio.o edit.o main.o hexer.o readline.o regex.o port.o \
exh.o set.o map.o signal.o util.o commands.o helptext.o calc.o
all: config.check $(HEXER)
config.check:
@{ if [ ! -f config.h ]; then \
echo '***' Please read the file README on how to configure and; \
echo '***' compile hexer.\ Thank you.; \
exit 1; \
fi; }
all: $(HEXER)
$(HEXER): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)
......@@ -83,9 +76,36 @@ bin2c: bin2c.c
helptext.c: help.txt bin2c
./bin2c -n helptext -o $@ help.txt
.c.o:
.c.o: config.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
%.o: %.c config.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
config.h:
[ ! -e config.h.auto ] || rm config.h.auto
for item in \
STRCMP \
STRCASECMP \
SIGTYPE_INT \
MEMMOVE \
FLOAT_H \
ALLOCA_H \
STRERROR \
VASPRINTF \
; do \
echo "Testing for $$item"; \
if $(CC) $(CPPFLAGS) $(CFLAGS) -D"TEST_$$item" -c -o config-test.o -Werror config-test.c; then \
value=1; \
else \
value=0; \
fi; \
echo "- result: $$value"; \
printf "#define HAVE_%s\\t%d\\n" "$$item" "$$value" >> config.h.auto; \
done
[ ! -e config.h ] || rm config.h
mv config.h.auto config.h
tags: *.c *.h
-@{ \
echo Creating tags...; \
......@@ -98,7 +118,7 @@ tags: *.c *.h
dep: depend
depend: *.c *.h
depend: *.c *.h config.h
-rm -f Makefile~
sed '/\#\#\# DO NOT DELETE THIS LINE \#\#\#/q' \
< Makefile > Makefile~
......@@ -115,6 +135,8 @@ depend: *.c *.h
clean:
rm -f $(HEXER) $(MYC) gen_testfile $(OBJECTS) bin2c
rm -f config-test.o
rm -f config.h
rm -f helptext.c TESTFILE
rm -f tags core *.bak
......
......@@ -14,13 +14,6 @@ INSTALL:
- To unpack hexer (you've probably done this already), type
gunzip < hexer-1.0.0.tar.gz | tar -xvf -
Change into the newly-created hexer-1.0.0/ subdirectory.
- There are several configuration files named `config.xxx' where
xxx is the name of the operation system or build environment.
Please try the build with config.posix first (except on GNU/Linux
systems where config.linux enables some optimizations). Only try
some of the other config.* files if hexer cannot be built or does
not run properly; in that case, please let the author know!
- Skim trough `config.h' and `Makefile'.
- Type `make'.
- If you want a command line version of the builtin calculator "myc",
type `make myc'.
......
#if defined(TEST_STRCMP)
#include <string.h>
#elif defined(TEST_STRCASECMP)
#include <string.h>
#include <strings.h>
#elif defined(TEST_SIGTYPE_INT)
#include <signal.h>
#elif defined(TEST_MEMMOVE)
#include <string.h>
#elif defined(TEST_FLOAT_H)
#include <float.h>
#elif defined(TEST_ALLOCA_H)
#include <alloca.h>
#elif defined(TEST_STRERROR)
#include <stdio.h>
#include <string.h>
#elif defined(TEST_VASPRINTF)
#define _GNU_SOURCE
#include <stdarg.h>
#include <stdio.h>
#else
#error No option to test
#endif
#if defined(TEST_SIGTYPE_INT)
int handler(void)
{
return 1;
}
#endif
#if defined(TEST_VASPRINTF)
char *run_vasprintf(char * const dst, ...)
{
char *res;
va_list v;
va_start(v, dst);
vasprintf(&res, "%d", v);
va_end(v);
return (res);
}
#endif
int main(void)
{
char buf[128] = "1";
#if defined(TEST_STRCMP)
buf[0] = '0' + (strcmp("a", "b") != 0);
#elif defined(TEST_STRCASECMP)
buf[0] = '0' + (strcasecmp("a", "b") != 0);
#elif defined(TEST_SIGTYPE_INT)
buf[0] = '0' + (signal(SIGINT, handler) != SIG_ERR);
#elif defined(TEST_MEMMOVE)
buf[1] = '1';
buf[2] = '\0';
memmove(buf, buf + 1, 2);
#elif defined(TEST_FLOAT_H)
buf[0] = '1';
#elif defined(TEST_ALLOCA_H)
buf[0] = '1';
#elif defined(TEST_STRERROR)
const char *res = strerror(2);
buf[0] = res[0];
#elif defined(TEST_VASPRINTF)
const char * const res = run_vasprintf(buf, 1);
buf[0] = res[0];
#else
#error No option to test
#endif
return buf[0];
}
/* Configuration file
*/
#warning The settings in this file have not been tested for a long time and are deprecated; if config.posix does not work, please contact the author!
#define HAVE_STRCMP 0
#define HAVE_STRCASECMP 0
#define HAVE_SIGTYPE_INT 0
#define HAVE_MEMMOVE 0
#define HAVE_USLEEP 0
#define HAVE_FLOAT_H 0
#define HAVE_ALLOCA_H 0
#define HAVE_STRERROR 0
#define HAVE_VASPRINTF 0
config.posix
\ No newline at end of file
/* Configuration file for Linux
*/
#define HAVE_STRCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_SIGTYPE_INT 0
#define HAVE_MEMMOVE 1
#define HAVE_USLEEP 1
#define HAVE_FLOAT_H 1
#define HAVE_ALLOCA_H 1
#define HAVE_STRERROR 1
#define HAVE_VASPRINTF 1
/* Configuration file
*/
#define HAVE_STRCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_SIGTYPE_INT 0
#define HAVE_MEMMOVE 1
#define HAVE_USLEEP 1
#define HAVE_FLOAT_H 1
#define HAVE_ALLOCA_H 0
#define HAVE_STRERROR 1
#define HAVE_VASPRINTF 0
/* Configuration file for SunOS
*/
#warning The settings in this file have not been tested for a long time and are deprecated; if config.posix does not work, please contact the author!
#define HAVE_STRCMP 1
#define HAVE_STRCASECMP 1
#define HAVE_SIGTYPE_INT 0
#define HAVE_MEMMOVE 0
#define HAVE_USLEEP 1
#define HAVE_FLOAT_H 0
#define HAVE_ALLOCA_H 1
#define HAVE_STRERROR 1
#define HAVE_VASPRINTF 0
......@@ -35,30 +35,6 @@ strcasecmp(const char *s1, const char *s2)
/* strcasecmp */
#endif
#if !HAVE_USLEEP
int
usleep(unsigned long usecs)
/* NOTE: this implementation of `usleep()' is not completely compatible
* with the BSD 4.3 `usleep()'-function, since it can be interrupted by
* an incoming signal.
*/
{
#ifdef FD_ZERO
struct timeval tv;
tv.tv_sec = usecs / 1000000;
tv.tv_usec = usecs & 1000000;
select(0, 0, 0, 0, &tv);
#else
struct pollfd fd;
poll(&fd, 0, usecs > 1999 ? usecs / 1000 : 1);
#endif
return 0;
}
/* usleep */
#endif
/* end of port.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment