6 changed files with 83 additions and 4 deletions
@ -1,11 +1,46 @@ |
|||
CC=gcc |
|||
CFLAGS=-g |
|||
SRCDIR=src/c/ |
|||
CFLAGS=-g -Isrc/lib/lua -Iinclude |
|||
SRCDIR=src/c |
|||
CORELUA = src/lua/core |
|||
LIBS=-llua |
|||
|
|||
OBJ=$(SRCDIR)main.o |
|||
GENERATED=include/luares.h src/c/gen/luares.c |
|||
LUAPARAMS = $(CORELUA) include/luares.h src/c/gen/luares.c lua_ |
|||
LFLAGS=$(LIBS) |
|||
OBJ=\
|
|||
$(SRCDIR)/main.o \ |
|||
$(SRCDIR)/gen/luares.o |
|||
|
|||
BUILDDIRECTORIES = $(patsubst $(SOURCE)%, $(BUILD)%, $(SRCDIRECTORIES)) |
|||
#Rules
|
|||
#Build
|
|||
all: smallclean $(BUILDDIRECTORIES) luaresources lupi |
|||
|
|||
smallclean: |
|||
find . -name '*~' -type f -exec rm {} \; |
|||
|
|||
build: clean all |
|||
|
|||
lupi: $(OBJ) |
|||
$(CC) $(LFLAGS) $^ -o $@ |
|||
|
|||
$(OBJ): %.o: %.c |
|||
$(CC) -c $(CFLAGS) $< -o $@ |
|||
|
|||
#Resources
|
|||
luaresources: cleanresourcues |
|||
scripts/txt2c $(LUAPARAMS) |
|||
|
|||
$(BUILDDIRECTORIES): |
|||
mkdir $@ |
|||
|
|||
#Clean rules
|
|||
cleanresourcues: |
|||
-rm -f $(GENERATED) |
|||
|
|||
mkdir -p src/c/gen/ |
|||
touch src/c/gen/luares.c |
|||
touch include/luares.h |
|||
|
|||
clean : cleanresourcues |
|||
-rm -f $(OBJ) |
@ -0,0 +1,40 @@ |
|||
#!/bin/bash |
|||
# $1 scripts folder |
|||
# $2 file to generate OUTPUTH C |
|||
# $3 file to generate OUTPUTH H |
|||
# $4 prefix |
|||
|
|||
LUAFILES="$1/*" |
|||
OUTPUTH="$2" |
|||
OUTPUTC="$3" |
|||
PREFIX="$4" |
|||
|
|||
|
|||
|
|||
outname="$(basename "$OUTPUTH")" |
|||
outname="${outname%.*}" |
|||
guard=$(echo "$outname" | tr '[:lower:]' '[:upper:]') |
|||
guard="$guard""_H" |
|||
|
|||
printf "#ifndef %s\n" "$guard" >> "$OUTPUTH" |
|||
printf "#define %s\n" "$guard" >> "$OUTPUTH" |
|||
|
|||
for file in $LUAFILES |
|||
do |
|||
|
|||
filename="$(basename "$file")" |
|||
filename="${filename%.*}" |
|||
|
|||
echo "extern char $PREFIX$filename[];" >> "$OUTPUTH" |
|||
|
|||
|
|||
echo "char $PREFIX$filename[] = {" >> "$OUTPUTC" |
|||
echo " " $(xxd -i < "$file") ",0x00" >> "$OUTPUTC" |
|||
echo "};" >> "$OUTPUTC" |
|||
|
|||
done |
|||
|
|||
echo "#endif" >> "$OUTPUTH" |
|||
|
|||
exit 0 |
|||
|
@ -1,5 +1,8 @@ |
|||
#include <stdio.h> |
|||
#include "luares.h" |
|||
|
|||
int main (void) { |
|||
puts("LuPI 2"); |
|||
puts("LuPI 2\n"); |
|||
puts(lua_init); |
|||
return 0; |
|||
} |
|||
|
@ -0,0 +1 @@ |
|||
print("HeelloLua") |
Loading…
issues.context.reference_issue