summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/CMakeLists.txt8
-rw-r--r--tools/mirb/CMakeLists.txt9
-rw-r--r--tools/mrbc/CMakeLists.txt8
-rw-r--r--tools/mrbc/Makefile (renamed from tools/mrbc/Makefile.orig)0
-rw-r--r--tools/mruby/CMakeLists.txt8
-rw-r--r--tools/mruby/Makefile (renamed from tools/mruby/Makefile.orig)0
-rw-r--r--tools/xpcat/CMakeLists.txt5
-rw-r--r--tools/xpcat/xpcat.c69
8 files changed, 101 insertions, 6 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644
index 000000000..ce348f3aa
--- /dev/null
+++ b/tools/CMakeLists.txt
@@ -0,0 +1,8 @@
+# specify the internal and external tools to be built
+
+add_subdirectory(xpcat)
+add_subdirectory(mrbc)
+add_subdirectory(mruby)
+add_subdirectory(mirb)
+
+# vim: ts=2 sts=2 sw=2 et
diff --git a/tools/mirb/CMakeLists.txt b/tools/mirb/CMakeLists.txt
new file mode 100644
index 000000000..a9f52db1f
--- /dev/null
+++ b/tools/mirb/CMakeLists.txt
@@ -0,0 +1,9 @@
+# build tools/mirb executable
+
+file(GLOB MIRBBIN_SRC_C "*.c")
+add_executable(mirb ${MIRBBIN_SRC_C})
+target_link_libraries(mirb libmruby_static ${MRUBY_LIBS})
+
+install(TARGETS mirb RUNTIME DESTINATION bin)
+
+# vim: ts=2 sts=2 sw=2 et
diff --git a/tools/mrbc/CMakeLists.txt b/tools/mrbc/CMakeLists.txt
index 073ac1743..71a3a937d 100644
--- a/tools/mrbc/CMakeLists.txt
+++ b/tools/mrbc/CMakeLists.txt
@@ -1,7 +1,9 @@
-# builds tools/mrbc
+# build tools/mrbc executable
+
file(GLOB MRBC_SRC_C "*.c")
add_executable(mrbc ${MRBC_SRC_C})
-target_link_libraries(mrbc ritevm_static ${MRUBY_LIBS})
-install(TARGETS mrbc RUNTIME DESTINATION bin)
+target_link_libraries(mrbc mruby_static ${MRUBY_LIBS})
+install(TARGETS mrbc RUNTIME DESTINATION bin)
+# vim: ts=2 sts=2 sw=2 et
diff --git a/tools/mrbc/Makefile.orig b/tools/mrbc/Makefile
index 9ecda4a59..9ecda4a59 100644
--- a/tools/mrbc/Makefile.orig
+++ b/tools/mrbc/Makefile
diff --git a/tools/mruby/CMakeLists.txt b/tools/mruby/CMakeLists.txt
index ab0e3acc1..beff6280d 100644
--- a/tools/mruby/CMakeLists.txt
+++ b/tools/mruby/CMakeLists.txt
@@ -1,7 +1,9 @@
-# builds tools/mrbc
+# build tools/mruby executable
+
file(GLOB MRUBYBIN_SRC_C "*.c")
add_executable(mruby ${MRUBYBIN_SRC_C})
-target_link_libraries(mruby mrubylib_static ${MRUBY_LIBS})
-install(TARGETS mruby RUNTIME DESTINATION bin)
+target_link_libraries(mruby libmruby_static ${MRUBY_LIBS})
+install(TARGETS mruby RUNTIME DESTINATION bin)
+# vim: ts=2 sts=2 sw=2 et
diff --git a/tools/mruby/Makefile.orig b/tools/mruby/Makefile
index 052aa93d6..052aa93d6 100644
--- a/tools/mruby/Makefile.orig
+++ b/tools/mruby/Makefile
diff --git a/tools/xpcat/CMakeLists.txt b/tools/xpcat/CMakeLists.txt
new file mode 100644
index 000000000..bb4d326f5
--- /dev/null
+++ b/tools/xpcat/CMakeLists.txt
@@ -0,0 +1,5 @@
+# build tools/xpcat internal executable
+
+add_executable(xpcat xpcat.c)
+
+# vim: ts=2 sts=2 sw=2 et
diff --git a/tools/xpcat/xpcat.c b/tools/xpcat/xpcat.c
new file mode 100644
index 000000000..c9d1abe73
--- /dev/null
+++ b/tools/xpcat/xpcat.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void
+usage(const char *program)
+{
+ printf("Usage: %s -o outputfile FILE...\n", program);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int i, ch;
+ const char *output = NULL;
+ FILE *infile = NULL;
+ FILE *outfile = NULL;
+
+ if (argc < 4) {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-o") == 0) {
+ i++;
+ if (i < argc)
+ output = argv[i];
+ else
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (output) {
+ outfile = fopen(output, "wb");
+ if (!outfile) {
+ fprintf(stderr, "[ERROR] unable to open output file: %s\n", output);
+ return EXIT_FAILURE;
+ }
+ setbuf(outfile, NULL);
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-o") == 0) { i++; continue; }
+
+ infile = fopen(argv[i], "rb");
+ if (!infile) {
+ fprintf(stderr, "[ERROR] unable to open input file: %s\n", argv[i]);
+ return EXIT_FAILURE;
+ }
+ setbuf(infile, NULL);
+
+ while ((ch = getc(infile)) != EOF) {
+ if (putc(ch, outfile) == EOF) {
+ fprintf(stderr, "[ERROR] error writing output file: %s\n", output);
+ return EXIT_FAILURE;
+ }
+ }
+
+ fclose(infile);
+ }
+ }
+
+done:
+ fclose(outfile);
+
+ return EXIT_SUCCESS;
+}
+
+/* vim: set ts=2 sts=2 sw=2 et: */