From 0fb7ec405a0a8c21319fd3cf9a58ffe69b7f5054 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 4 May 2024 14:42:24 +0000 Subject: [PATCH] better way git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@102 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- GNUmakefile | 7 ++++--- Makefile | 6 +++--- Serenade/main.c | 4 ++-- Tool/Makefile | 5 ++++- Tool/config.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Tool/configgen.c | 5 +---- 6 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 Tool/config.c diff --git a/GNUmakefile b/GNUmakefile index e6fbb52..43f373a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -9,10 +9,10 @@ GREP = ggrep CC = gcc endif -CFLAGS = -std=c99 -fPIC -g `$(CPP) -DCFLAGS cmdline | $(GREP) -vE "^\#" | tr '\\n' ' '` +CFLAGS = -std=c99 -fPIC -g `./Tool/config cflags` LDFLAGS = -LIBS = `$(CPP) -DLIBS cmdline | $(GREP) -vE "^\#" | tr '\\n' ' '` -EXTRA_OBJS = `$(CPP) -DOBJS cmdline | $(GREP) -vE "^\#" | tr '\\n' ' '` +LIBS = `./Tool/config libs` +EXTRA_OBJS = `./Tool/config objs` SUFFIX = SUFFIX_SO = .so PREFIX_SO = lib @@ -31,6 +31,7 @@ all: ./Tool ./config.h ./Serenade ./config.h: if [ ! -e ./Tool/configgen ]; then $(MAKE) ./Tool ; fi ./Tool/configgen $@ + $(MAKE) -C ./Tool CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" SUFFIX="$(SUFFIX)" config ./Serenade:: $(MAKE) -C ./Serenade CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" SUFFIX="$(SUFFIX)" EXTRA_OBJS="$(EXTRA_OBJS)" SUFFIX_SO="$(SUFFIX_SO)" PREFIX_SO="$(PREFIX_SO)" diff --git a/Makefile b/Makefile index 27757cb..0ac12b3 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ CPP = cpp CC = cc -CFLAGS = -std=c99 -fPIC -g `$(CPP) -DCFLAGS cmdline | $(GREP) -vE "^\#" | tr '\\n' ' '` +CFLAGS = -std=c99 -fPIC -g `./Tool/config cflags` LDFLAGS = -LIBS = `$(CPP) -DLIBS cmdline | $(GREP) -vE "^\#" | tr '\\n' ' '` -EXTRA_OBJS = `$(CPP) -DOBJS cmdline | $(GREP) -vE "^\#" | tr '\\n' ' '` +LIBS = `./Tool/config libs` +EXTRA_OBJS = `./Tool/config objs` SUFFIX = SUFFIX_SO = .so PREFIX_SO = lib diff --git a/Serenade/main.c b/Serenade/main.c index 872dfdb..23a9b92 100644 --- a/Serenade/main.c +++ b/Serenade/main.c @@ -106,8 +106,8 @@ int main(int argc, char** argv) { #ifdef HAS_REPL_SUPPORT if(!loaded) { is_repl = true; - printf(" ---+-------+--- oooo 8 \n"); - printf(" ---+-------+--- 8 8 8 \n"); + printf(" ---+---+---+--- oooo 8 \n"); + printf(" ---+---+---+--- 8 8 8 \n"); printf(" | | 8 oooo 8 oooo oooo 8 oooo oooo oooo8 oooo \n"); printf(" | | oooo 8 8 8o o 8 8 8o 8 8 8 8 8 8\n"); printf(" | | 8 8oooo8 8 8oooo8 8 8 oooo8 8 8 8oooo8\n"); diff --git a/Tool/Makefile b/Tool/Makefile index c4c59d8..b1b3b4a 100644 --- a/Tool/Makefile +++ b/Tool/Makefile @@ -10,8 +10,11 @@ all: ./configgen ./configgen: $(CONFIGGEN_OBJS) $(CC) -o $@ $(CONFIGGEN_OBJS) +./config: config.c + $(CC) -o $@ config.c + .c.o: $(CC) -c -o $@ $< clean: - rm -f *.o ./configgen ./configgen.exe + rm -f *.o ./configgen ./configgen.exe ./config diff --git a/Tool/config.c b/Tool/config.c new file mode 100644 index 0000000..dfe1450 --- /dev/null +++ b/Tool/config.c @@ -0,0 +1,46 @@ +/* $Id$ */ +#define COMMANDLINE +#include "../config.h" + +#include +#include + +int main(int argc, char** argv) { + if(argc == 1) { + fprintf(stderr, "insufficient arguments\n"); + return 1; + } + if(strcmp(argv[1], "cflags") == 0) { + printf( +#ifdef __NetBSD__ + "-I/usr/pkg/include " +#endif + "\n"); + } else if(strcmp(argv[1], "libs") == 0) { + printf( +#ifdef __NetBSD__ + "-Wl,-R/usr/pkg/lib -L/usr/pkg/lib " +#endif +#ifdef HAS_FFI_SUPPORT + "-lffi " +#endif +#ifdef HAS_READLINE_SUPPORT + "-lreadline " +#endif +#if defined(HAS_FFI_SUPPORT) || defined(HAS_BINMODULE_SUPPORT) +#ifdef __linux__ + "-ldl " +#endif +#endif + "\n"); + } else if(strcmp(argv[1], "objs") == 0) { + printf( +#ifdef HAS_FFI_SUPPORT + "ffi_binding.o " +#endif +#ifdef HAS_BINMODULE_SUPPORT + "binmodule.o " +#endif + "\n"); + } +} diff --git a/Tool/configgen.c b/Tool/configgen.c index 9414664..240ecec 100644 --- a/Tool/configgen.c +++ b/Tool/configgen.c @@ -35,10 +35,7 @@ char choice[256]; -char* asks[] = {"repl", "y", "HAS_REPL_SUPPORT", "Do you want the REPL support?", - "ffi", "y", "HAS_FFI_SUPPORT", "Do you want the FFI support?", - "readline", "n", "HAS_READLINE_SUPPORT", "Do you want the readline support for the REPL?", - "binmodule", "y", "HAS_BINMODULE_SUPPORT", "Do you want the binary module (e.g. so or dll) support?", NULL}; +char* asks[] = {"repl", "y", "HAS_REPL_SUPPORT", "Do you want the REPL support?", "ffi", "y", "HAS_FFI_SUPPORT", "Do you want the FFI support?", "readline", "n", "HAS_READLINE_SUPPORT", "Do you want the readline support for the REPL?", "binmodule", "y", "HAS_BINMODULE_SUPPORT", "Do you want the binary module (e.g. so or dll) support?", NULL}; void show_dialog(int n) { fprintf(stderr, "[default is %c] %s ", asks[n * 4 + 1][0], asks[n * 4 + 3]); -- 2.43.0