Skip to content

Commit e16b94b

Browse files
committed
Update build process and instructions
1 parent 81ec5fe commit e16b94b

File tree

6 files changed

+42
-37
lines changed

6 files changed

+42
-37
lines changed

INSTALL

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
If you are a windows user and want to build this you will need mingw.
2-
First of all in the Retro Graphics Toolkit directory create a folder called lua
3-
Then extract all files from the src folder into the folder you just created.
4-
Then rename all *.c files to *.cpp
5-
HINT: Don't do this manually on *unix you can just run:
6-
rename .c .cpp *.c
7-
The reason lua is built even though many distributions already provide lua is so that the latest version is used and so that this version which may be built with a different configuration does not overwrite your system's instillation of lua.
8-
(Windows only on other systems your distribution of choice should already have provided fltk) you will now need to build fltk to do this download fltk-1.3.2 and extract it into the Retro Graphics Toolkit project folder and build it using
2+
3+
First of all in the Retro Graphics Toolkit directory create a folder called lua or luawin on windows.
4+
Note the only reason for creating a separate folder is to accommodate for the fact that I do all my development on GNU/Linux and have a separate instillation of GCC as a cross compiler. This allows me to quickly test the windows build and *unix build simultaneously.
5+
Extract the latest version of Lua in the newly created folder.
6+
Now edit the makefile in src
7+
edit CC=gcc to say CC=g++
8+
If you are using a cross compiler make sure to take into account it's prefix also you will need to modify the AR and RANLIB variables if such is the case.
9+
Also if you are building on windows you must replace this line in the Makefile
10+
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
11+
with
12+
"AR=$(CC) -shared -static-libgcc -static-libstdc++ -o" "RANLIB=strip --strip-all" \
13+
Lua can be build using c++ which is what we are doing this is to take advantage of GCC's support for zero cost exception handling using throw.
14+
The reason Lua is built even though many distributions already provide Lua is so that the latest version is used and so that this version which may be built with a different configuration does not overwrite your system's instillation of Lua.
15+
Now run make linux or make mingw depending on your system platform.
16+
DO NOT RUN MAKE INSTALL.
17+
18+
(Windows only. On other systems your distribution of choice should already have provided fltk) you will now need to build fltk to do this download fltk-1.3.2 and extract it into the Retro Graphics Toolkit project folder and build it using
919
either ./configure if you are on windows or if you are cross compiling you need to something like this ./configure --host=i686-pc-mingw32 --build=x86_64-unknown-linux-gnu
1020
Regardless of how ./configure is ran you will just need to run make and you are done building fltk.
1121

callback_gui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "color_convert.h"
2020
#include "system.h"
2121
#include "callback_project.h"
22-
#include "lua/lua.h"
22+
#include "lua.h"
2323
static const char* GPLv3="This program is free software: you can redistribute it and/or modify\n"
2424
"it under the terms of the GNU General Public License as published by\n"
2525
"the Free Software Foundation, either version 3 of the License, or\n"

make_debug

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
CPPFLAGS=-MD -MP -DLUA_USE_LINUX -DLUA_COMPAT_ALL
1+
CPPFLAGS=-MD -MP
22
CC=gcc
33
CXX=g++
44
#gentoo fix needs include directory set to /usr/include/fltk-1 if you are using a different distro then this may not apply to you
5-
CFLAGS=-I/usr/include/fltk-1/ -Ikens/ -c -Wall -O0 -ggdb
5+
CFLAGS=-I/usr/include/fltk-1/ -Ilua/src -Ikens/ -c -Wall -O0 -ggdb
66
CXXFLAGS= $(CFLAGS) -std=gnu++11
7-
LDFLAGS=-L/usr/lib/fltk-1/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -ldl -lreadline
8-
LUAOBJECTS=lua/lapi.o lua/lcode.o lua/lctype.o lua/ldebug.o lua/ldo.o lua/ldump.o lua/lfunc.o lua/lgc.o lua/llex.o lua/lmem.o lua/lobject.o lua/lopcodes.o lua/lparser.o lua/lstate.o lua/lstring.o lua/ltable.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o lua/lauxlib.o lua/lbaselib.o lua/lbitlib.o lua/lcorolib.o lua/ldblib.o lua/liolib.o lua/lmathlib.o lua/loslib.o lua/lstrlib.o lua/ltablib.o lua/loadlib.o lua/linit.o
9-
OBJECTS=$(LUAOBJECTS) project.o main.o callbacks_palette.o callback_tiles.o class_global.o global.o quant.o tilemap.o color_convert.o \
7+
OBJECTS=project.o main.o callbacks_palette.o callback_tiles.o class_global.o global.o quant.o tilemap.o color_convert.o \
108
errorMsg.o class_palette.o dither.o \
119
class_tiles.o kens/nemesis.o kens/enigma.o kens/kosinski.o spatial_color_quant.o NEUQUANT.o \
1210
classtilemap.o palette.o zlibwrapper.o color_compare.o windowinit.o tiles_io.o savepng.o \
1311
callback_project.o callback_tilemap.o callback_gui.o classChunks.o compressionWrapper.o callback_chunk.o gui.o \
1412
wu.o system.o filemisc.o classSprite.o classSprites.o callbacksprites.o undo.o undocallback.o image.o \
1513
classlevel.o runlua.o
1614
EXECUTABLE=RetroGraphicsToolkit
15+
LINKER=-L/usr/lib/fltk-1/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -Llua/src -llua -ldl
1716
all: $(EXECUTABLE)
1817

1918
$(EXECUTABLE): $(OBJECTS)
20-
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
19+
$(CXX) $(OBJECTS) $(LINKER) -o $@
2120
.c.o:
2221
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
2322
.cc.o:

make_win

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
CPPFLAGS=-DLUA_COMPAT_ALL
1+
CPPFLAGS=
22
CC=i686-pc-mingw32-gcc
33
CXX=i686-pc-mingw32-g++
44
STRIP=i686-pc-mingw32-strip
55
#to compile on windows you must compile fltk
66
#I compiled fltk in a folder named fltk-1.3.2 which is in the Retro Graphics tookit directory
77
#if that is not the case for you edit the makefile changing paths
8-
CFLAGS=-Ifltk-1.3.2/ -Ikens/ -Ifltk-1.3.2/zlib -I fltk-1.3.2/png -c -Wall -O2 -s -ffunction-sections -fdata-sections -mwindows -fomit-frame-pointer -pipe -Wl,--gc-sections
8+
CFLAGS=-Ifltk-1.3.2/ -Ikens/ -Ifltk-1.3.2/zlib -I fltk-1.3.2/png -Iluawin/src -c -Wall -O2 -s -ffunction-sections -fdata-sections -mwindows -fomit-frame-pointer -pipe -Wl,--gc-sections
99
CXXFLAGS=$(CFLAGS) -std=gnu++11 -fno-rtti -std=gnu++11
1010
LDFLAGS= -O2 -s -fomit-frame-pointer -Wl,--as-needed -Wl,--gc-sections
11-
LUAOBJECTS=lua/lapi.o lua/lcode.o lua/lctype.o lua/ldebug.o lua/ldo.o lua/ldump.o lua/lfunc.o lua/lgc.o lua/llex.o lua/lmem.o lua/lobject.o lua/lopcodes.o lua/lparser.o lua/lstate.o lua/lstring.o lua/ltable.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o lua/lauxlib.o lua/lbaselib.o lua/lbitlib.o lua/lcorolib.o lua/ldblib.o lua/liolib.o lua/lmathlib.o lua/loslib.o lua/lstrlib.o lua/ltablib.o lua/loadlib.o lua/linit.o
12-
OBJECTS=$(LUAOBJECTS) project.o main.o callbacks_palette.o callback_tiles.o class_global.o global.o quant.o tilemap.o color_convert.o \
11+
OBJECTS= project.o main.o callbacks_palette.o callback_tiles.o class_global.o global.o quant.o tilemap.o color_convert.o \
1312
errorMsg.o class_palette.o dither.o \
1413
class_tiles.o kens/nemesis.o kens/enigma.o kens/kosinski.o spatial_color_quant.o NEUQUANT.o \
1514
classtilemap.o palette.o zlibwrapper.o color_compare.o windowinit.o tiles_io.o savepng.o \
1615
callback_project.o callback_tilemap.o callback_gui.o classChunks.o compressionWrapper.o callback_chunk.o gui.o \
1716
wu.o system.o filemisc.o classSprite.o classSprites.o callbacksprites.o undo.o undocallback.o image.o \
1817
classlevel.o runlua.o
19-
LINKER=-Lfltk-1.3.2/lib -s -static-libgcc -static-libstdc++ -lfltk_images -lfltk -lfltk_jpeg -lfltk_png -lfltk_z -mwindows -lole32 -luuid -lcomctl32
18+
LINKER=-Lfltk-1.3.2/lib -s -static-libgcc -static-libstdc++ -lfltk_images -lfltk -lfltk_jpeg -lfltk_png -lfltk_z -mwindows -lole32 -luuid -lcomctl32 -Lluawin/src -llua52
2019
EXECUTABLE=RetroGraphicsToolkit.exe
2120

2221
all: $(EXECUTABLE)

makefile

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
CPPFLAGS=-DLUA_USE_LINUX -DLUA_COMPAT_ALL
1+
CPPFLAGS=
22
CC=gcc
33
CPP=g++
44
#gentoo fix needs include directory set to /usr/include/fltk-1 if you are using a different distro then this may not apply to you
5-
CFLAGS=-march=native -flto -fuse-linker-plugin -I/usr/include/fltk-1/ -s -Ikens/ -c -Wall -Wextra -Wdouble-promotion -O3 -pipe -march=native -fomit-frame-pointer
5+
CFLAGS=-march=native -flto -fuse-linker-plugin -I/usr/include/fltk-1/ -Ilua/src -s -Ikens/ -c -Wall -Wextra -Wdouble-promotion -O3 -pipe -march=native -fomit-frame-pointer
66
CXXFLAGS= $(CFLAGS) -fno-rtti -std=gnu++11
77
LDFLAGS=-flto -O3 -march=native -fuse-linker-plugin -s -fno-rtti -std=gnu++11 -L/usr/lib/fltk-1/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -s
8-
LUAOBJECTS=lua/lapi.o lua/lcode.o lua/lctype.o lua/ldebug.o lua/ldo.o lua/ldump.o lua/lfunc.o lua/lgc.o lua/llex.o lua/lmem.o lua/lobject.o lua/lopcodes.o lua/lparser.o lua/lstate.o lua/lstring.o lua/ltable.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o lua/lauxlib.o lua/lbaselib.o lua/lbitlib.o lua/lcorolib.o lua/ldblib.o lua/liolib.o lua/lmathlib.o lua/loslib.o lua/lstrlib.o lua/ltablib.o lua/loadlib.o lua/linit.o
9-
OBJECTS=$(LUAOBJECTS) project.o main.o callbacks_palette.o callback_tiles.o class_global.o global.o quant.o tilemap.o color_convert.o \
8+
OBJECTS= project.o main.o callbacks_palette.o callback_tiles.o class_global.o global.o quant.o tilemap.o color_convert.o \
109
errorMsg.o class_palette.o dither.o \
1110
class_tiles.o kens/nemesis.o kens/enigma.o kens/kosinski.o spatial_color_quant.o NEUQUANT.o \
1211
classtilemap.o palette.o zlibwrapper.o color_compare.o windowinit.o tiles_io.o savepng.o \
1312
callback_project.o callback_tilemap.o callback_gui.o classChunks.o compressionWrapper.o callback_chunk.o gui.o \
1413
wu.o system.o filemisc.o classSprite.o classSprites.o callbacksprites.o undo.o undocallback.o image.o \
1514
classlevel.o runlua.o
15+
LINKER=-L/usr/lib/fltk-1/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -Llua/src -llua -ldl
16+
1617
EXECUTABLE=RetroGraphicsToolkit
1718

1819
all: $(SOURCES) $(EXECUTABLE)
1920

2021
$(EXECUTABLE): $(OBJECTS)
21-
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
22+
$(CXX) $(OBJECTS) $(LINKER) -o $@
2223
.c.o:
2324
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
2425
.cc.o:

runlua.cpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#include <string>
1818
#include "includes.h"
1919
#include "gui.h"
20-
#include "lua/lua.h"
21-
#include "lua/lualib.h"
22-
#include "lua/lauxlib.h"
20+
#include "lua.h"
21+
#include "lualib.h"
22+
#include "lauxlib.h"
2323
static int panic(lua_State *L){
2424
fl_alert("PANIC: unprotected error in call to Lua API (%s)\n",lua_tostring(L, -1));
2525
throw 0;//Otherwise abort() would be called when not needed
@@ -38,18 +38,14 @@ void runLua(Fl_Widget*,void*){
3838
lua_State *L = lua_newstate(l_alloc, NULL);
3939
if(L){
4040
lua_atpanic(L, &panic);
41-
luaL_openlibs(L);
4241
try{
42+
luaL_openlibs(L);
4343
int s = luaL_loadfile(L, scriptname.c_str());
44-
if(s){
45-
if (s != LUA_OK && !lua_isnil(L, -1)) {
46-
const char *msg = lua_tostring(L, -1);
47-
if (msg == NULL) msg = "(error object is not a string)";
48-
fl_alert(msg);
49-
lua_pop(L, 1);
50-
/* force a complete garbage collection in case of errors */
51-
lua_gc(L, LUA_GCCOLLECT, 0);
52-
}
44+
if(s != LUA_OK && !lua_isnil(L, -1)){
45+
const char *msg = lua_tostring(L, -1);
46+
if (msg == NULL) msg = "(error object is not a string)";
47+
fl_alert(msg);
48+
lua_pop(L, 1);
5349
}else{
5450
// execute Lua program
5551
s = lua_pcall(L, 0, LUA_MULTRET, 0);

0 commit comments

Comments
 (0)