]> granicus.if.org Git - yasm/commitdiff
Install modules into pkglibdir rather than libdir, and rename to type_keyword
authorPeter Johnson <peter@tortall.net>
Sat, 3 May 2003 06:26:15 +0000 (06:26 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 3 May 2003 06:26:15 +0000 (06:26 -0000)
from yasm_keyword (separating same-keyword modules of different types).  Update
yasm frontend module loader to handle this.

svn path=/trunk/yasm/; revision=921

16 files changed:
Makefile.am
frontends/yasm/yasm-module.c
frontends/yasm/yasm-module.h
frontends/yasm/yasm.c
modules/Makefile.inc
modules/arch/x86/Makefile.inc
modules/dbgfmts/null/Makefile.inc
modules/objfmts/bin/Makefile.inc
modules/objfmts/coff/Makefile.inc
modules/objfmts/dbg/Makefile.inc
modules/objfmts/win32/Makefile.inc
modules/optimizers/basic/Makefile.inc
modules/parsers/nasm/Makefile.inc
modules/preprocs/nasm/Makefile.inc
modules/preprocs/raw/Makefile.inc
modules/preprocs/yapp/Makefile.inc

index b552a45bfcabe8e43ac171819c1d130f648a7f31..ae11a4240ea00ccaa5bc6248fb590c14631c1086 100644 (file)
@@ -6,7 +6,7 @@ AM_YFLAGS = -d
 AM_CFLAGS = @MORE_CFLAGS@
 AM_CPPFLAGS = \
        -I$(top_srcdir)/check \
-       -DYASM_MODULEDIR="\"${libdir}\"" \
+       -DYASM_MODULEDIR="\"${pkglibdir}\"" \
        @INCLTDL@
 
 bin_PROGRAMS =
@@ -16,6 +16,7 @@ noinst_PROGRAMS =
 include_HEADERS = libyasm.h
 
 lib_LTLIBRARIES =
+pkglib_LTLIBRARIES =
 
 YASM_MODULES = 
 
index 68130204e4e0d4e588518c3b5946dec38227063c..352f864b4682234337f5fd8aea1c6b3a847d88ac 100644 (file)
@@ -35,6 +35,7 @@
 
 typedef struct module {
     SLIST_ENTRY(module) link;
+    /*@only@*/ char *type;         /* module type */
     /*@only@*/ char *keyword;      /* module keyword */
     lt_dlhandle handle;                    /* dlopen handle */
 } module;
@@ -85,21 +86,25 @@ const char *preprocs[] = {
 /*@=nullassign@*/
 
 static /*@dependent@*/ /*@null@*/ module *
-load_module(const char *keyword)
+load_module(const char *type, const char *keyword)
 {
     module *m;
     char *name;
     lt_dlhandle handle;
+    size_t typelen;
 
     /* See if the module has already been loaded. */
     SLIST_FOREACH(m, &modules, link) {
-       if (yasm__strcasecmp(m->keyword, keyword) == 0)
+       if (yasm__strcasecmp(m->type, type) == 0 &&
+           yasm__strcasecmp(m->keyword, keyword) == 0)
            return m;
     }
 
     /* Look for dynamic module.  First build full module name from keyword. */
-    name = yasm_xmalloc(5+strlen(keyword)+1);
-    strcpy(name, "yasm_");
+    typelen = strlen(type);
+    name = yasm_xmalloc(typelen+strlen(keyword)+2);
+    strcpy(name, type);
+    strcat(name, "_");
     strcat(name, keyword);
     handle = lt_dlopenext(name);
 
@@ -109,8 +114,9 @@ load_module(const char *keyword)
     }
 
     m = yasm_xmalloc(sizeof(module));
-    m->keyword = name;
-    strcpy(m->keyword, keyword);
+    m->type = name;
+    name[typelen] = '\0';
+    m->keyword = &name[typelen+1];
     m->handle = handle;
     SLIST_INSERT_HEAD(&modules, m, link);
     return m;
@@ -124,24 +130,36 @@ unload_modules(void)
     while (!SLIST_EMPTY(&modules)) {
        m = SLIST_FIRST(&modules);
        SLIST_REMOVE_HEAD(&modules, link);
-       yasm_xfree(m->keyword);
+       yasm_xfree(m->type);
        lt_dlclose(m->handle);
        yasm_xfree(m);
     }
 }
 
 void *
-get_module_data(const char *keyword, const char *symbol)
+get_module_data(const char *type, const char *keyword, const char *symbol)
 {
+    char *name;
     /*@dependent@*/ module *m;
+    void *data;
 
     /* Load module */
-    m = load_module(keyword);
+    m = load_module(type, keyword);
     if (!m)
        return NULL;
 
+    name = yasm_xmalloc(strlen(keyword)+strlen(symbol)+11);
+
+    strcpy(name, "yasm_");
+    strcat(name, keyword);
+    strcat(name, "_LTX_");
+    strcat(name, symbol);
+
     /* Find and return data pointer: NULL if it doesn't exist */
-    return lt_dlsym(m->handle, symbol);
+    data = lt_dlsym(m->handle, name);
+
+    yasm_xfree(name);
+    return data;
 }
 
 void
index b7c6489695752ea3285b6131b29ec49188c41779..ae5e000424a0fe3f1e200662f2599aa21bf0f00d 100644 (file)
 #define YASM_MODULE_H
 
 void unload_modules(void);
-/*@dependent@*/ /*@null@*/ void *get_module_data(const char *keyword,
-                                                const char *symbol);
+/*@dependent@*/ /*@null@*/ void *get_module_data
+    (const char *type, const char *keyword, const char *symbol);
 
-#define load_arch(keyword)     get_module_data(keyword, "arch")
-#define load_dbgfmt(keyword)   get_module_data(keyword, "dbgfmt")
-#define load_objfmt(keyword)   get_module_data(keyword, "objfmt")
-#define load_optimizer(keyword)        get_module_data(keyword, "optimizer")
-#define load_parser(keyword)   get_module_data(keyword, "parser")
-#define load_preproc(keyword)  get_module_data(keyword, "preproc")
+#define load_arch(keyword)     get_module_data("arch", keyword, "arch")
+#define load_dbgfmt(keyword)   get_module_data("dbgfmt", keyword, "dbgfmt")
+#define load_objfmt(keyword)   get_module_data("objfmt", keyword, "objfmt")
+#define load_optimizer(keyword)        get_module_data("optimizer", keyword, "optimizer")
+#define load_parser(keyword)   get_module_data("parser", keyword, "parser")
+#define load_preproc(keyword)  get_module_data("preproc", keyword, "preproc")
 
 /* Lists all available object formats.  Calls printfunc with the name and
  * keyword of each available format.
index bda5dbc604ad35e39b08d086783e71c0511ca703..7ef749638731710abe24d57ff38190a6982928bf 100644 (file)
@@ -436,12 +436,20 @@ main(int argc, char *argv[])
            return EXIT_FAILURE;
        }
     }
+
+    if (!cur_preproc) {
+       print_error(_("Could not load default preprocessor"));
+       cleanup(NULL);
+       return EXIT_FAILURE;
+    }
+
     apply_preproc_saved_options();
 
     /* Get initial x86 BITS setting from object format */
     if (strcmp(cur_arch->keyword, "x86") == 0) {
        unsigned char *x86_mode_bits;
-       x86_mode_bits = (unsigned char *)get_module_data("x86", "mode_bits");
+       x86_mode_bits = (unsigned char *)get_module_data("arch", "x86",
+                                                        "mode_bits");
        if (x86_mode_bits)
            *x86_mode_bits = cur_objfmt->default_x86_mode_bits;
     }
index 3b1e5eb1b6458130e32f5289b7ec0313cb61dff9..ccb635f9eb8bb0392bf2538d443e3a3a55d28f21 100644 (file)
@@ -7,14 +7,6 @@ EXTRA_DIST += \
        modules/optimizers/Makefile.inc \
        modules/objfmts/Makefile.inc
 
-# Modules with more than one type of interface
-
-lib_LTLIBRARIES += yasm_nasm.la
-yasm_nasm_la_SOURCES =
-yasm_nasm_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_nasm_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_nasm.la
-
 include modules/arch/Makefile.inc
 include modules/parsers/Makefile.inc
 include modules/preprocs/Makefile.inc
index f6a4662151c2122160b65f0d3be2ab3ce0dbb74b..25d53cdfaa20dc21bfa6b175ceaddc87c83d3651 100644 (file)
@@ -1,19 +1,19 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_x86.la
+pkglib_LTLIBRARIES += arch_x86.la
 
-yasm_x86_la_SOURCES = \
+arch_x86_la_SOURCES = \
        modules/arch/x86/x86arch.c      \
        modules/arch/x86/x86arch.h      \
        modules/arch/x86/x86bc.c        \
        modules/arch/x86/x86expr.c      \
        x86id.c
-yasm_x86_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_x86_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_x86.la
+arch_x86_la_LDFLAGS = -module -avoid-version -no-undefined
+arch_x86_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen arch_x86.la
 
-x86id.c: $(srcdir)/modules/arch/x86/x86id.re re2c$(EXEEXT) $(srcdir)/tools/re2c/cleanup.pl
-       $(top_builddir)/re2c$(EXEEXT) -s $(srcdir)/modules/arch/x86/x86id.re | $(PERL) $(srcdir)/tools/re2c/cleanup.pl | sed "/^#l/ s,re2c-out\.c,$@," > $@
+x86id.c: $(srcdir)/modules/arch/x86/x86id.re $(top_builddir)/re2c$(EXEEXT) $(srcdir)/tools/re2c/cleanup.pl
+       $(top_builddir)/re2c$(EXEEXT) -s $(srcdir)/modules/arch/x86/x86id.re | $(PERL) $(top_srcdir)/tools/re2c/cleanup.pl | sed "/^#l/ s,re2c-out\.c,$@," > $@
 
 BUILT_SOURCES += \
        x86id.c
index acab29653acc396cf49feb21ff0d05f608567018..ab73f15369cdecbe68c71dd494cdebdc96829669 100644 (file)
@@ -1,9 +1,9 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_null.la
+pkglib_LTLIBRARIES += dbgfmt_null.la
 
-yasm_null_la_SOURCES = \
+dbgfmt_null_la_SOURCES = \
        modules/dbgfmts/null/null-dbgfmt.c
-yasm_null_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_null_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_null.la
+dbgfmt_null_la_LDFLAGS = -module -avoid-version -no-undefined
+dbgfmt_null_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen dbgfmt_null.la
index ad1a72091d7eab08c6b205edfe6af777c7574f49..eda7ce150537b387d99cf9dc355e44af43f01d35 100644 (file)
@@ -1,12 +1,12 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_bin.la
+pkglib_LTLIBRARIES += objfmt_bin.la
 
-yasm_bin_la_SOURCES = \
+objfmt_bin_la_SOURCES = \
        modules/objfmts/bin/bin-objfmt.c
-yasm_bin_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_bin_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_bin.la
+objfmt_bin_la_LDFLAGS = -module -avoid-version -no-undefined
+objfmt_bin_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen objfmt_bin.la
 
 EXTRA_DIST += \
        modules/objfmts/bin/tests/Makefile.inc
index 8257b28cb81c6b5b4da945dbab694a921800c128..eee58782da730306b6f78f3b329486e9372fdbe0 100644 (file)
@@ -1,12 +1,12 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_coff.la
+pkglib_LTLIBRARIES += objfmt_coff.la
 
-yasm_coff_la_SOURCES = \
+objfmt_coff_la_SOURCES = \
        modules/objfmts/coff/coff-objfmt.c
-yasm_coff_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_coff_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_coff.la
+objfmt_coff_la_LDFLAGS = -module -avoid-version -no-undefined
+objfmt_coff_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen objfmt_coff.la
 
 EXTRA_DIST += \
        modules/objfmts/coff/tests/Makefile.inc
index aa78484fe9666520529f5bf4df5b31a1ec43df0d..d05a65a63780890f8ac7df3ebf4f3d3e04c4573e 100644 (file)
@@ -1,9 +1,9 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_dbg.la
+pkglib_LTLIBRARIES += objfmt_dbg.la
 
-yasm_dbg_la_SOURCES = \
+objfmt_dbg_la_SOURCES = \
        modules/objfmts/dbg/dbg-objfmt.c
-yasm_dbg_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_dbg_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_dbg.la
+objfmt_dbg_la_LDFLAGS = -module -avoid-version -no-undefined
+objfmt_dbg_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen objfmt_dbg.la
index 17fb8797de482e4473db710dd2216ff996e8c363..4562bda42ec7afced60dba48190897eee331a96a 100644 (file)
@@ -1,12 +1,12 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_win32.la
+pkglib_LTLIBRARIES += objfmt_win32.la
 
-yasm_win32_la_SOURCES = \
+objfmt_win32_la_SOURCES = \
        modules/objfmts/coff/coff-objfmt.c
-yasm_win32_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_win32_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_win32.la
+objfmt_win32_la_LDFLAGS = -module -avoid-version -no-undefined
+objfmt_win32_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen objfmt_win32.la
 
 EXTRA_DIST += \
        modules/objfmts/win32/tests/Makefile.inc
index c1296a62101e52de31e0704f08a62633387e6222..ce02408c93c02a60cb5f64197ba461cdf294c086 100644 (file)
@@ -1,9 +1,9 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_basic.la
+pkglib_LTLIBRARIES += optimizer_basic.la
 
-yasm_basic_la_SOURCES = \
+optimizer_basic_la_SOURCES = \
        modules/optimizers/basic/basic-optimizer.c
-yasm_basic_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_basic_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_basic.la
+optimizer_basic_la_LDFLAGS = -module -avoid-version -no-undefined
+optimizer_basic_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen optimizer_basic.la
index 5b06bb69529fb2c93889d771e060599aafcc96a2..cb9485952062b04cfcd103b85dfe919440f68211 100644 (file)
@@ -1,20 +1,20 @@
 # $IdPath$
 
-#lib_LTLIBRARIES += yasm_nasm.la
+pkglib_LTLIBRARIES += parser_nasm.la
 
-yasm_nasm_la_SOURCES += \
+parser_nasm_la_SOURCES = \
        modules/parsers/nasm/nasm-parser.h      \
        modules/parsers/nasm/nasm-parser.c      \
        modules/parsers/nasm/nasm-defs.h        \
        modules/parsers/nasm/nasm-bison.y       \
        nasm-bison.h                            \
        nasm-token.c
-#yasm_nasm_la_LDFLAGS = -module -avoid-version -no-undefined
-#yasm_nasm_la_LIBADD = libyasm.la
-#YASM_MODULES += -dlopen yasm_nasm.la
+parser_nasm_la_LDFLAGS = -module -avoid-version -no-undefined
+parser_nasm_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen parser_nasm.la
 
-nasm-token.c: $(srcdir)/modules/parsers/nasm/nasm-token.re re2c$(EXEEXT) $(srcdir)/tools/re2c/cleanup.pl
-       $(top_builddir)/re2c$(EXEEXT) -b $(srcdir)/modules/parsers/nasm/nasm-token.re | $(PERL) $(srcdir)/tools/re2c/cleanup.pl | sed "/^#l/ s,re2c-out\.c,$@," > $@
+nasm-token.c: $(srcdir)/modules/parsers/nasm/nasm-token.re $(top_builddir)/re2c$(EXEEXT) $(srcdir)/tools/re2c/cleanup.pl
+       $(top_builddir)/re2c$(EXEEXT) -b $(srcdir)/modules/parsers/nasm/nasm-token.re | $(PERL) $(top_srcdir)/tools/re2c/cleanup.pl | sed "/^#l/ s,re2c-out\.c,$@," > $@
 
 BUILT_SOURCES += \
        nasm-bison.c                            \
index 9b1119c04b42a53181009c747c0acc3552fef18f..bfa0425496a9457e65af3c52fd6a0117a7c7460b 100644 (file)
@@ -1,8 +1,8 @@
 # $IdPath$
 
-#lib_LTLIBRARIES += yasm_nasm.la
+pkglib_LTLIBRARIES += preproc_nasm.la
 
-yasm_nasm_la_SOURCES += \
+preproc_nasm_la_SOURCES = \
        modules/preprocs/nasm/nasm-preproc.c \
        modules/preprocs/nasm/nasm-pp.h \
        modules/preprocs/nasm/nasm-pp.c \
@@ -11,6 +11,9 @@ yasm_nasm_la_SOURCES += \
        modules/preprocs/nasm/nasmlib.c \
        modules/preprocs/nasm/nasm-eval.h \
        modules/preprocs/nasm/nasm-eval.c
+preproc_nasm_la_LDFLAGS = -module -avoid-version -no-undefined
+preproc_nasm_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen preproc_nasm.la
 
 $(top_modulesdir)/src/preprocs/nasm/nasm-pp.c: nasm-macros.c
 
@@ -24,8 +27,4 @@ EXTRA_DIST += modules/preprocs/nasm/macros.pl \
        modules/preprocs/nasm/standard.mac \
        modules/preprocs/nasm/tests/Makefile.inc
 
-#yasm_nasm_la_LDFLAGS = -module -avoid-version -no-undefined
-#yasm_nasm_la_LIBADD = libyasm.la
-#YASM_MODULES += -dlopen yasm_nasm.la
-
 include modules/preprocs/nasm/tests/Makefile.inc
index 86bcde275d10e4e78175f0b1609a91d2feb2c80c..b5bae7c3be63f6b98322ba034eaa787025b7428d 100644 (file)
@@ -1,9 +1,9 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_raw.la
+pkglib_LTLIBRARIES += preproc_raw.la
 
-yasm_raw_la_SOURCES = \
+preproc_raw_la_SOURCES = \
        modules/preprocs/raw/raw-preproc.c
-yasm_raw_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_raw_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_raw.la
+preproc_raw_la_LDFLAGS = -module -avoid-version -no-undefined
+preproc_raw_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen preproc_raw.la
index a6e48c57cb11dfea914abcb798a09bd0eec1e28c..9707dbfd1050dd225ea82d46bd0c0db829edd672 100644 (file)
@@ -1,15 +1,15 @@
 # $IdPath$
 
-lib_LTLIBRARIES += yasm_yapp.la
+pkglib_LTLIBRARIES += preproc_yapp.la
 
-yasm_yapp_la_SOURCES = \
+preproc_yapp_la_SOURCES = \
        modules/preprocs/yapp/yapp-preproc.h    \
        modules/preprocs/yapp/yapp-preproc.c    \
        modules/preprocs/yapp/yapp-token.h      \
        modules/preprocs/yapp/yapp-token.l
-yasm_yapp_la_LDFLAGS = -module -avoid-version -no-undefined
-yasm_yapp_la_LIBADD = libyasm.la
-YASM_MODULES += -dlopen yasm_yapp.la
+preproc_yapp_la_LDFLAGS = -module -avoid-version -no-undefined
+preproc_yapp_la_LIBADD = libyasm.la
+YASM_MODULES += -dlopen preproc_yapp.la
 
 BUILT_SOURCES += \
        yapp-token.c