AM_CFLAGS = @MORE_CFLAGS@
AM_CPPFLAGS = \
-I$(top_srcdir)/check \
- -DYASM_MODULEDIR="\"${libdir}\"" \
+ -DYASM_MODULEDIR="\"${pkglibdir}\"" \
@INCLTDL@
bin_PROGRAMS =
include_HEADERS = libyasm.h
lib_LTLIBRARIES =
+pkglib_LTLIBRARIES =
YASM_MODULES =
typedef struct module {
SLIST_ENTRY(module) link;
+ /*@only@*/ char *type; /* module type */
/*@only@*/ char *keyword; /* module keyword */
lt_dlhandle handle; /* dlopen handle */
} module;
/*@=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);
}
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;
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
#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.
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;
}
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
# $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
# $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
# $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
# $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
# $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
# $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
# $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
# $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 \
# $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 \
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
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
# $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
# $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