diff options
author | Peter Johnson <peter@tortall.net> | 2014-08-10 21:38:48 -0700 |
---|---|---|
committer | Peter Johnson <peter@tortall.net> | 2014-08-10 23:18:46 -0700 |
commit | 636dc92558efd052cd0553203f67068171a3116c (patch) | |
tree | 5bb4f3aea44713caf767c4296ebeac2699cd0ccb /frontends | |
parent | 24e01c833fa94947ff815099170311355ad39949 (diff) | |
download | yasm-636dc92558efd052cd0553203f67068171a3116c.tar.gz |
Allow building of static executables with cmake.
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/tasm/CMakeLists.txt | 20 | ||||
-rw-r--r-- | frontends/tasm/tasm.c | 12 | ||||
-rw-r--r-- | frontends/vsyasm/CMakeLists.txt | 20 | ||||
-rw-r--r-- | frontends/vsyasm/vsyasm.c | 18 | ||||
-rw-r--r-- | frontends/yasm/CMakeLists.txt | 20 | ||||
-rw-r--r-- | frontends/yasm/yasm.c | 18 |
6 files changed, 78 insertions, 30 deletions
diff --git a/frontends/tasm/CMakeLists.txt b/frontends/tasm/CMakeLists.txt index 982b95d1..e275ab84 100644 --- a/frontends/tasm/CMakeLists.txt +++ b/frontends/tasm/CMakeLists.txt @@ -15,12 +15,20 @@ ADD_CUSTOM_COMMAND( SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -ADD_EXECUTABLE(ytasm - tasm.c - tasm-options.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-plugin.c - ) -TARGET_LINK_LIBRARIES(ytasm libyasm ${LIBDL}) +IF(BUILD_SHARED_LIBS) + ADD_EXECUTABLE(ytasm + tasm.c + tasm-options.c + ${yasm_SOURCE_DIR}/frontends/yasm/yasm-plugin.c + ) + TARGET_LINK_LIBRARIES(ytasm libyasm ${LIBDL}) +ELSE(BUILD_SHARED_LIBS) + ADD_EXECUTABLE(ytasm + tasm.c + tasm-options.c + ) + TARGET_LINK_LIBRARIES(ytasm yasmstd libyasm) +ENDIF(BUILD_SHARED_LIBS) SET_SOURCE_FILES_PROPERTIES(tasm.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c diff --git a/frontends/tasm/tasm.c b/frontends/tasm/tasm.c index b0b89de7..58954b64 100644 --- a/frontends/tasm/tasm.c +++ b/frontends/tasm/tasm.c @@ -38,7 +38,7 @@ #include "tasm-options.h" -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) #include "yasm-plugin.h" #endif @@ -46,6 +46,10 @@ #define DEFAULT_OBJFMT_MODULE "bin" +#if defined(CMAKE_BUILD) && !defined(BUILD_SHARED_LIBS) +void yasm_init_plugin(void); +#endif + /*@null@*/ /*@only@*/ static char *obj_filename = NULL, *in_filename = NULL; /*@null@*/ /*@only@*/ static char *list_filename = NULL, *xref_filename = NULL; /*@null@*/ /*@only@*/ static char *machine_name = NULL; @@ -457,10 +461,14 @@ main(int argc, char *argv[]) #ifdef CMAKE_BUILD /* Load standard modules */ +#ifdef BUILD_SHARED_LIBS if (!load_plugin("yasmstd")) { print_error(_("%s: could not load standard modules"), _("FATAL")); return EXIT_FAILURE; } +#else + yasm_init_plugin(); +#endif #endif /* Initialize parameter storage */ @@ -640,7 +648,7 @@ cleanup(yasm_object *object) if (errfile != stderr && errfile != stdout) fclose(errfile); -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) unload_plugins(); #endif } diff --git a/frontends/vsyasm/CMakeLists.txt b/frontends/vsyasm/CMakeLists.txt index 62c7405c..6815b18d 100644 --- a/frontends/vsyasm/CMakeLists.txt +++ b/frontends/vsyasm/CMakeLists.txt @@ -15,12 +15,20 @@ ADD_CUSTOM_COMMAND( SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -ADD_EXECUTABLE(vsyasm - vsyasm.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-options.c - ${yasm_SOURCE_DIR}/frontends/yasm/yasm-plugin.c - ) -TARGET_LINK_LIBRARIES(vsyasm libyasm ${LIBDL}) +IF(BUILD_SHARED_LIBS) + ADD_EXECUTABLE(vsyasm + vsyasm.c + ${yasm_SOURCE_DIR}/frontends/yasm/yasm-options.c + ${yasm_SOURCE_DIR}/frontends/yasm/yasm-plugin.c + ) + TARGET_LINK_LIBRARIES(vsyasm libyasm ${LIBDL}) +ELSE(BUILD_SHARED_LIBS) + ADD_EXECUTABLE(vsyasm + vsyasm.c + ${yasm_SOURCE_DIR}/frontends/yasm/yasm-options.c + ) + TARGET_LINK_LIBRARIES(vsyasm yasmstd libyasm) +ENDIF(BUILD_SHARED_LIBS) SET_SOURCE_FILES_PROPERTIES(vsyasm.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c diff --git a/frontends/vsyasm/vsyasm.c b/frontends/vsyasm/vsyasm.c index 4ab46369..905145fa 100644 --- a/frontends/vsyasm/vsyasm.c +++ b/frontends/vsyasm/vsyasm.c @@ -37,12 +37,16 @@ #include "frontends/yasm/yasm-options.h" -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) #include "frontends/yasm/yasm-plugin.h" #endif #include "license.c" +#if defined(CMAKE_BUILD) && !defined(BUILD_SHARED_LIBS) +void yasm_init_plugin(void); +#endif + /*@null@*/ /*@only@*/ static char *objdir_pathname = NULL; /*@null@*/ /*@only@*/ static char *global_prefix = NULL, *global_suffix = NULL; /*@null@*/ /*@only@*/ static char *listdir_pathname = NULL; @@ -107,7 +111,7 @@ static int opt_preproc_option(char *cmd, /*@null@*/ char *param, int extra); static int opt_ewmsg_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_prefix_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_suffix_handler(char *cmd, /*@null@*/ char *param, int extra); -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) static int opt_plugin_handler(char *cmd, /*@null@*/ char *param, int extra); #endif @@ -207,7 +211,7 @@ static opt_option options[] = N_("append argument to name of all external symbols"), N_("suffix") }, { 0, "postfix", 1, opt_suffix_handler, 0, N_("append argument to name of all external symbols"), N_("suffix") }, -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) { 'N', "plugin", 1, opt_plugin_handler, 0, N_("load plugin module"), N_("plugin") }, #endif @@ -542,10 +546,14 @@ main(int argc, char *argv[]) #ifdef CMAKE_BUILD /* Load standard modules */ +#ifdef BUILD_SHARED_LIBS if (!load_plugin("yasmstd")) { print_error(_("%s: could not load standard modules"), _("FATAL")); return EXIT_FAILURE; } +#else + yasm_init_plugin(); +#endif #endif /* Initialize parameter storage */ @@ -783,7 +791,7 @@ cleanup(void) if (errfile != stderr && errfile != stdout) fclose(errfile); -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) unload_plugins(); #endif } @@ -1201,7 +1209,7 @@ opt_suffix_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) return 0; } -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) static int opt_plugin_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) diff --git a/frontends/yasm/CMakeLists.txt b/frontends/yasm/CMakeLists.txt index 6d963eb4..b11d7f82 100644 --- a/frontends/yasm/CMakeLists.txt +++ b/frontends/yasm/CMakeLists.txt @@ -12,12 +12,20 @@ ADD_CUSTOM_COMMAND( SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -ADD_EXECUTABLE(yasm - yasm.c - yasm-options.c - yasm-plugin.c - ) -TARGET_LINK_LIBRARIES(yasm libyasm ${LIBDL}) +IF(BUILD_SHARED_LIBS) + ADD_EXECUTABLE(yasm + yasm.c + yasm-options.c + yasm-plugin.c + ) + TARGET_LINK_LIBRARIES(yasm libyasm ${LIBDL}) +ELSE(BUILD_SHARED_LIBS) + ADD_EXECUTABLE(yasm + yasm.c + yasm-options.c + ) + TARGET_LINK_LIBRARIES(yasm yasmstd libyasm) +ENDIF(BUILD_SHARED_LIBS) SET_SOURCE_FILES_PROPERTIES(yasm.c PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 44358549..ff4c59e2 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -37,7 +37,7 @@ #include "yasm-options.h" -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) #include "yasm-plugin.h" #endif @@ -108,10 +108,14 @@ static int opt_ewmsg_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_makedep_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_prefix_handler(char *cmd, /*@null@*/ char *param, int extra); static int opt_suffix_handler(char *cmd, /*@null@*/ char *param, int extra); -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) static int opt_plugin_handler(char *cmd, /*@null@*/ char *param, int extra); #endif +#if defined(CMAKE_BUILD) && !defined(BUILD_SHARED_LIBS) +void yasm_init_plugin(void); +#endif + static /*@only@*/ char *replace_extension(const char *orig, /*@null@*/ const char *ext, const char *def); static void print_error(const char *fmt, ...); @@ -204,7 +208,7 @@ static opt_option options[] = N_("append argument to name of all external symbols"), N_("suffix") }, { 0, "postfix", 1, opt_suffix_handler, 0, N_("append argument to name of all external symbols"), N_("suffix") }, -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) { 'N', "plugin", 1, opt_plugin_handler, 0, N_("load plugin module"), N_("plugin") }, #endif @@ -611,10 +615,14 @@ main(int argc, char *argv[]) #ifdef CMAKE_BUILD /* Load standard modules */ +#ifdef BUILD_SHARED_LIBS if (!load_plugin("yasmstd")) { print_error(_("%s: could not load standard modules"), _("FATAL")); return EXIT_FAILURE; } +#else + yasm_init_plugin(); +#endif #endif /* Initialize parameter storage */ @@ -811,7 +819,7 @@ cleanup(yasm_object *object) if (errfile != stderr && errfile != stdout) fclose(errfile); -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) unload_plugins(); #endif } @@ -1192,7 +1200,7 @@ opt_suffix_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) return 0; } -#ifdef CMAKE_BUILD +#if defined(CMAKE_BUILD) && defined(BUILD_SHARED_LIBS) static int opt_plugin_handler(/*@unused@*/ char *cmd, char *param, /*@unused@*/ int extra) |