mirror of https://git.kore.io/kore.git
Kill the skeleton folder, needs documentation updates
This commit is contained in:
parent
2a1aecbaa0
commit
ad4ee88e9a
|
@ -1,79 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2013 Joris Vink <joris@coders.se>
|
||||
#
|
||||
# Kore module build script, use this as a base for building
|
||||
# your own modules for kore or just roll your own.
|
||||
|
||||
# The name of the module you will be building
|
||||
MODULE=site.module
|
||||
|
||||
# The directory containing all your media files (HTML, CSS, ...).
|
||||
# These files will be compiled into the module and symbols will
|
||||
# be exported for you to use in your code.
|
||||
MEDIA_DIR=media
|
||||
|
||||
# The directory containing your module source.
|
||||
SOURCE_DIR=src
|
||||
|
||||
# Compiler settings.
|
||||
CC=gcc
|
||||
CFLAGS="-I. -I/usr/local/include -Wall -Wstrict-prototypes \
|
||||
-Wmissing-prototypes -Wmissing-declarations -Wshadow \
|
||||
-Wpointer-arith -Wcast-qual -Wsign-compare -g"
|
||||
|
||||
OSNAME=$(uname -s | sed -e 's/[-_].*//g' | tr A-Z a-z)
|
||||
if [ "${OSNAME}" = "darwin" ]; then
|
||||
LDFLAGS="-dynamiclib -undefined suppress -flat_namespace"
|
||||
else
|
||||
LDFLAGS="-shared"
|
||||
fi
|
||||
|
||||
MODULE_BUILD_DATE=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
|
||||
### Begin building ####
|
||||
echo "Building module ${MODULE}..."
|
||||
rm -f ${MODULE}
|
||||
|
||||
${CC} ${CFLAGS} tools/inject.c -o tools/inject
|
||||
|
||||
if [ ! -d ${SOURCE_DIR}/${MEDIA_DIR} ]; then
|
||||
mkdir ${SOURCE_DIR}/${MEDIA_DIR};
|
||||
fi
|
||||
rm -f ${SOURCE_DIR}/${MEDIA_DIR}/*
|
||||
|
||||
if [ ! -d .objs ]; then
|
||||
mkdir .objs;
|
||||
fi
|
||||
rm -f .objs/*
|
||||
|
||||
rm -f static.h
|
||||
|
||||
for file in `find ${MEDIA_DIR} -type f \( ! -name \*.swp \)`; do
|
||||
echo "Injecting $file";
|
||||
base=`basename $file`;
|
||||
./tools/inject $file $base > ${SOURCE_DIR}/${MEDIA_DIR}/${base}.c;
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Injection error, check above messages for clues.";
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
|
||||
echo "#define MODULE_BUILD_DATE \"${MODULE_BUILD_DATE}\"" >> static.h
|
||||
|
||||
for src in `find ${SOURCE_DIR} -type f -name \*.c`; do
|
||||
base=`basename $src`;
|
||||
${CC} ${CFLAGS} -fPIC -c $src -o .objs/${base}.o
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Build error, check above messages for clues.";
|
||||
exit 1;
|
||||
fi
|
||||
done
|
||||
|
||||
${CC} ${LDFLAGS} `find .objs -name \*.o -type f` -o ${MODULE}
|
||||
echo "Building completed!"
|
||||
|
||||
rm -rf ${SOURCE_DIR}/${MEDIA_DIR}
|
||||
rm -rf .objs
|
||||
rm -f tools/inject
|
||||
rm -f static.h
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Joris Vink <joris@coders.se>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(OpenBSD)
|
||||
#define PRI_TIME_T "d"
|
||||
#endif
|
||||
|
||||
#if defined(linux)
|
||||
#if defined(__x86_64__)
|
||||
#define PRI_TIME_T PRIu64
|
||||
#else
|
||||
#define PRI_TIME_T "ld"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__MACH__)
|
||||
#define PRI_TIME_T "ld"
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct stat st;
|
||||
ssize_t len;
|
||||
FILE *hdr;
|
||||
char *ext;
|
||||
unsigned char c[1];
|
||||
int fd, newline, count;
|
||||
|
||||
if (argc != 3)
|
||||
exit(1);
|
||||
|
||||
if ((fd = open(argv[1], O_RDONLY)) == -1)
|
||||
err(1, "open() %d", errno);
|
||||
if ((hdr = fopen("static.h", "a+")) == NULL)
|
||||
err(1, "fopen() %d", errno);
|
||||
if ((ext = strchr(argv[2], '.')) != NULL)
|
||||
*(ext)++ = '\0';
|
||||
else
|
||||
ext = "";
|
||||
|
||||
if (stat(argv[1], &st) == -1) {
|
||||
printf("stat(%s) failed: %d\n", argv[1], errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("/**** AUTO GENERATED BY MAKEFILE - DO NOT TOUCH ****/\n");
|
||||
printf("#include <sys/param.h>\n\n");
|
||||
printf("u_int8_t static_%s_%s[] = {", ext, argv[2]);
|
||||
|
||||
len = 0;
|
||||
count = 0;
|
||||
newline = 1;
|
||||
for (;;) {
|
||||
if (newline) {
|
||||
printf("\n\t");
|
||||
count = 0;
|
||||
newline = 0;
|
||||
}
|
||||
|
||||
len = read(fd, c, 1);
|
||||
if (len == 0)
|
||||
break;
|
||||
|
||||
if (len == -1) {
|
||||
printf("read(): %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (len != 1)
|
||||
exit(1);
|
||||
|
||||
printf("0x%02x, ", c[0]);
|
||||
if (count++ == 10)
|
||||
newline = 1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
printf("};\n\n");
|
||||
printf("u_int32_t static_len_%s_%s = %" PRIu32 ";\n",
|
||||
ext, argv[2], (u_int32_t)st.st_size);
|
||||
|
||||
printf("time_t static_mtime_%s_%s = %" PRI_TIME_T ";\n",
|
||||
ext, argv[2], st.st_mtime);
|
||||
|
||||
fprintf(hdr, "extern u_int8_t static_%s_%s[];\n", ext, argv[2]);
|
||||
fprintf(hdr, "extern u_int32_t static_len_%s_%s;\n", ext, argv[2]);
|
||||
fprintf(hdr, "extern time_t static_mtime_%s_%s;\n", ext, argv[2]);
|
||||
fclose(hdr);
|
||||
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue