TIC-80-guile/Makefile

442 lines
10 KiB
Makefile
Raw Normal View History

2017-09-26 08:59:34 +02:00
CC=gcc
OPT=-O3 -Wall -std=gnu99
2017-11-11 20:52:12 +01:00
OPT_PRO=-DTIC80_PRO
2017-11-21 18:34:01 +01:00
BIN_NAME= bin/tic80
2017-09-26 08:59:34 +02:00
3RD_PARTY = 3rd-party
DUKTAPE_LIB = $(3RD_PARTY)/duktape-2.2.0/src
2018-01-10 15:11:22 +01:00
BLIPBUF_LIB = $(3RD_PARTY)/blip-buf
2018-01-10 15:36:49 +01:00
SDL_NET_LIB = $(3RD_PARTY)/SDL2_net-2.0.1
PRE_BUILT = $(3RD_PARTY)/pre-built
2017-09-26 08:59:34 +02:00
RM= rm -f
INCLUDES= \
-I$(3RD_PARTY)/lua-5.3.1/src \
-I$(3RD_PARTY)/zlib-1.2.8 \
-I$(3RD_PARTY)/giflib-5.1.4/lib \
-I$(3RD_PARTY)/SDL2-2.0.7/include \
2018-02-19 11:13:44 +01:00
-I$(3RD_PARTY)/sdl-gpu/include \
2018-02-05 14:52:55 +01:00
-I$(3RD_PARTY)/wren-0.1.0/src/include \
2018-01-11 05:57:14 +01:00
-I$(3RD_PARTY)/moonscript \
2018-01-10 15:11:22 +01:00
-I$(BLIPBUF_LIB) \
-I$(DUKTAPE_LIB) \
2018-01-10 15:36:49 +01:00
-I$(SDL_NET_LIB) \
-Iinclude
2017-09-26 08:59:34 +02:00
MINGW_LINKER_FLAGS= \
-L$(PRE_BUILT)/mingw \
2017-09-26 08:59:34 +02:00
-lmingw32 \
-lcomdlg32 \
-lws2_32 \
2018-02-22 13:32:06 +01:00
-lsdlgpu \
2018-02-19 11:13:44 +01:00
-lSDL2main \
-lSDL2 \
-lopengl32 \
2017-09-26 08:59:34 +02:00
-mwindows
2017-11-20 07:46:46 +01:00
GTK_INCLUDES= `pkg-config --cflags gtk+-3.0`
GTK_LIBS= `pkg-config --libs gtk+-3.0`
2017-09-26 08:59:34 +02:00
LINUX_INCLUDES= \
2017-11-20 07:46:46 +01:00
$(GTK_INCLUDES) \
2017-11-12 12:33:06 +01:00
`sdl2-config --cflags`
2017-09-26 08:59:34 +02:00
2017-11-08 15:08:12 +01:00
LINUX_LIBS= \
2017-11-20 07:46:46 +01:00
$(GTK_LIBS) \
2018-02-06 15:39:51 +01:00
`sdl2-config --static-libs` \
2018-02-26 12:36:28 +01:00
-L$(3RD_PARTY)/wren-0.1.0/lib \
-L$(3RD_PARTY)/sdl-gpu/build/linux
2017-11-08 15:08:12 +01:00
2017-09-26 08:59:34 +02:00
LINUX64_LIBS= \
2018-02-06 12:44:33 +01:00
$(GTK_LIBS) \
-L$(PRE_BUILT)/linux64
2017-09-26 08:59:34 +02:00
LINUX32_LIBS= \
2018-02-06 12:44:33 +01:00
$(GTK_LIBS) \
-L$(PRE_BUILT)/linux32
2017-09-26 08:59:34 +02:00
LINUX_ARM_LIBS= \
-L$(PRE_BUILT)/arm
2017-09-26 08:59:34 +02:00
2017-11-11 20:52:12 +01:00
LINUX_LINKER_LTO_FLAGS= \
-lSDL2 \
2018-02-22 18:10:19 +01:00
-lsdlgpu \
2017-11-11 20:52:12 +01:00
-llua \
2018-02-05 14:52:55 +01:00
-lwren \
2017-11-11 20:52:12 +01:00
-lgif \
-ldl \
-lm \
-lpthread \
-lrt \
2018-02-22 18:10:19 +01:00
-lz \
-lGL
2017-11-11 20:52:12 +01:00
2017-09-26 08:59:34 +02:00
LINUX_LINKER_FLAGS= \
2017-11-08 15:08:12 +01:00
-llua5.3 \
2018-02-05 14:52:55 +01:00
-lwren \
2017-09-26 08:59:34 +02:00
-ldl \
-lm \
-lpthread \
-lrt \
2018-02-26 12:36:28 +01:00
-lz \
-lsdlgpu \
-lGL
2017-09-26 08:59:34 +02:00
2017-11-21 18:34:01 +01:00
MINGW_OUTPUT=$(BIN_NAME).exe
2017-09-26 08:59:34 +02:00
EMS_CC=emcc
EMS_OPT= \
-Wno-typedef-redefinition \
-s USE_SDL=2 \
-s TOTAL_MEMORY=67108864 \
--llvm-lto 1 \
--memory-init-file 0 \
--pre-js build/html/prejs.js \
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=["writeArrayToMemory"]'
2017-09-26 08:59:34 +02:00
EMS_LINKER_FLAGS= \
-L$(PRE_BUILT)/emscripten \
2017-09-26 08:59:34 +02:00
-llua \
2018-02-05 14:52:55 +01:00
-lwren \
2017-09-26 08:59:34 +02:00
-lgif \
2018-02-22 13:32:06 +01:00
-lz \
-lsdlgpu
2017-09-26 08:59:34 +02:00
MACOSX_OPT= \
-mmacosx-version-min=10.6 \
-Wno-typedef-redefinition \
-D_THREAD_SAFE
2017-09-26 08:59:34 +02:00
MACOSX_LIBS= \
-L$(PRE_BUILT)/macos \
2017-09-26 08:59:34 +02:00
-L/usr/local/lib \
2018-02-05 14:52:55 +01:00
-lSDL2 -lm -liconv -lobjc -llua -lwren -lz -lgif \
2018-02-22 18:50:05 +01:00
-lsdlgpu \
2017-09-26 08:59:34 +02:00
-Wl,-framework,CoreAudio \
-Wl,-framework,AudioToolbox \
-Wl,-framework,ForceFeedback \
-Wl,-framework,CoreVideo \
-Wl,-framework,Cocoa \
-Wl,-framework,Carbon \
2018-02-22 18:50:05 +01:00
-Wl,-framework,IOKit \
-Wl,-framework,OpenGL
2017-09-26 08:59:34 +02:00
SOURCES=\
src/studio.c \
src/console.c \
src/run.c \
src/ext/file_dialog.c \
src/ext/md5.c \
src/ext/gif.c \
2018-01-10 15:36:49 +01:00
$(SDL_NET_LIB)/SDLnet.c \
$(SDL_NET_LIB)/SDLnetTCP.c \
$(SDL_NET_LIB)/SDLnetselect.c \
2017-09-26 08:59:34 +02:00
src/fs.c \
src/tools.c \
src/start.c \
src/sprite.c \
src/map.c \
src/sfx.c \
src/music.c \
src/history.c \
src/world.c \
src/config.c \
src/code.c \
src/dialog.c \
src/menu.c \
src/net.c \
2018-02-26 07:43:59 +01:00
src/surf.c
SYSTEM=\
2018-02-14 14:53:32 +01:00
src/system.c
2017-09-26 08:59:34 +02:00
SOURCES_EXT= \
src/html.c
LPEG_SRC= $(3RD_PARTY)/lpeg-1.0.1/*.c
GIF_SRC= $(3RD_PARTY)/giflib-5.1.4/lib/*.c
2018-01-10 15:11:22 +01:00
BLIP_SRC= $(BLIPBUF_LIB)/blip_buf.c
2017-11-08 15:08:12 +01:00
2017-09-26 08:59:34 +02:00
DEMO_ASSETS= \
bin/assets/fire.tic.dat \
bin/assets/p3d.tic.dat \
bin/assets/palette.tic.dat \
bin/assets/quest.tic.dat \
bin/assets/sfx.tic.dat \
bin/assets/music.tic.dat \
bin/assets/font.tic.dat \
bin/assets/tetris.tic.dat \
bin/assets/jsdemo.tic.dat \
bin/assets/luademo.tic.dat \
bin/assets/moondemo.tic.dat \
2018-02-05 14:52:55 +01:00
bin/assets/wrendemo.tic.dat \
bin/assets/benchmark.tic.dat \
2017-09-26 08:59:34 +02:00
bin/assets/config.tic.dat
all: run
TIC80_H = include/tic80_types.h include/tic80.h include/tic80_config.h src/tic.h src/ticapi.h src/machine.h
2017-09-26 08:59:34 +02:00
TIC_H= src/*.h \
src/ext/*.h
bin/studio.o: src/studio.c src/keycodes.c $(TIC80_H) $(TIC_H)
2017-09-26 08:59:34 +02:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/console.o: src/console.c $(TIC80_H) $(TIC_H) $(DEMO_ASSETS)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/run.o: src/run.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/file_dialog.o: src/ext/file_dialog.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/md5.o: src/ext/md5.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/gif.o: src/ext/gif.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-01-10 15:36:49 +01:00
bin/SDLnet.o: $(SDL_NET_LIB)/SDLnet.c $(TIC80_H) $(TIC_H)
2017-09-26 08:59:34 +02:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-01-10 15:36:49 +01:00
bin/SDLnetTCP.o: $(SDL_NET_LIB)/SDLnetTCP.c $(TIC80_H) $(TIC_H)
2017-09-26 08:59:34 +02:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-01-10 15:36:49 +01:00
bin/SDLnetselect.o: $(SDL_NET_LIB)/SDLnetselect.c $(TIC80_H) $(TIC_H)
2017-09-26 08:59:34 +02:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/fs.o: src/fs.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/tools.o: src/tools.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/start.o: src/start.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/sprite.o: src/sprite.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/map.o: src/map.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/sfx.o: src/sfx.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/music.o: src/music.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/history.o: src/history.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/world.o: src/world.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/config.o: src/config.c $(TIC80_H) $(TIC_H) $(DEMO_ASSETS)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/code.o: src/code.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/net.o: src/net.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/dialog.o: src/dialog.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/menu.o: src/menu.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/surf.o: src/surf.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-02-26 11:56:54 +01:00
bin/system.o: src/system.c src/keycodes.c $(TIC80_H) $(TIC_H)
2018-01-24 10:20:05 +01:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-02-26 07:43:59 +01:00
bin/chip.o: src/system/chip.c src/keycodes.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-02-07 16:21:24 +01:00
SDL_NET = \
bin/SDLnet.o \
bin/SDLnetTCP.o \
bin/SDLnetselect.o \
bin/net.o
2018-02-08 12:26:17 +01:00
FILE_DIALOG = \
bin/file_dialog.o
2017-09-26 08:59:34 +02:00
TIC_O=\
bin/studio.o \
bin/console.o \
bin/run.o \
bin/md5.o \
bin/gif.o \
bin/fs.o \
bin/tools.o \
bin/start.o \
bin/sprite.o \
bin/map.o \
bin/sfx.o \
bin/music.o \
bin/history.o \
bin/world.o \
bin/config.o \
bin/code.o \
bin/dialog.o \
bin/menu.o \
2018-02-07 16:21:24 +01:00
bin/surf.o
2017-09-26 08:59:34 +02:00
bin/tic80.o: src/tic80.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -DTIC80_SHARED -c -o $@
bin/tic.o: src/tic.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-01-10 15:11:22 +01:00
bin/blip_buf.o: $(BLIP_SRC)
2017-09-26 08:59:34 +02:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/jsapi.o: src/jsapi.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/luaapi.o: src/luaapi.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-02-05 14:52:55 +01:00
bin/wrenapi.o: src/wrenapi.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/duktape.o: $(DUKTAPE_LIB)/duktape.c $(TIC80_H)
2017-09-26 08:59:34 +02:00
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
2018-02-05 14:52:55 +01:00
TIC80_SRC = src/tic80.c src/tic.c $(BLIP_SRC) src/jsapi.c src/luaapi.c src/wrenapi.c $(DUKTAPE_LIB)/duktape.c
TIC80_O = bin/tic80.o bin/tic.o bin/tools.o bin/blip_buf.o bin/jsapi.o bin/luaapi.o bin/wrenapi.o bin/duktape.o bin/gif.o
2017-09-26 08:59:34 +02:00
TIC80_A = bin/libtic80.a
TIC80_DLL = bin/tic80.dll
2018-02-07 16:21:24 +01:00
STUDIO_A = bin/libstudio.a
STUDIO_DLL = bin/studio.dll
2017-09-26 08:59:34 +02:00
$(TIC80_DLL): $(TIC80_O)
2018-02-05 14:52:55 +01:00
$(CC) $(OPT) -shared $(TIC80_O) -L$(PRE_BUILT)/mingw -llua -lwren -lgif -Wl,--out-implib,$(TIC80_A) -o $@
2017-09-26 08:59:34 +02:00
2018-02-07 16:21:24 +01:00
$(STUDIO_DLL): $(DEMO_ASSETS) $(TIC80_DLL) $(TIC_O) bin/html.o
$(CC) $(TIC_O) bin/html.o $(TIC80_A) $(OPT) -shared $(INCLUDES) -L$(PRE_BUILT)/mingw -llua -lz -lgif -Wl,--out-implib,$(STUDIO_A) -o $@
2017-09-26 08:59:34 +02:00
emscripten:
2018-02-26 07:43:59 +01:00
$(EMS_CC) $(SOURCES) $(SYSTEM) $(TIC80_SRC) $(OPT) $(INCLUDES) $(EMS_OPT) $(EMS_LINKER_FLAGS) -o build/html/tic.js
2017-09-26 08:59:34 +02:00
2018-01-22 14:35:19 +01:00
wasm:
2018-02-26 07:43:59 +01:00
$(EMS_CC) $(SOURCES) $(SYSTEM) $(TIC80_SRC) $(OPT) $(INCLUDES) $(EMS_OPT) -s WASM=1 $(EMS_LINKER_FLAGS) -o build/html/tic.js
2018-01-22 14:35:19 +01:00
2018-02-14 13:16:33 +01:00
mingw: $(STUDIO_DLL) $(SDL_NET) $(FILE_DIALOG) bin/system.o bin/res.o
$(CC) bin/system.o bin/res.o $(STUDIO_A) $(SDL_NET) $(FILE_DIALOG) $(OPT) $(INCLUDES) $(MINGW_LINKER_FLAGS) -o $(MINGW_OUTPUT)
2017-09-26 08:59:34 +02:00
2017-11-09 18:34:03 +01:00
mingw-pro:
2017-11-11 20:52:12 +01:00
$(eval OPT += $(OPT_PRO))
2017-11-09 18:34:03 +01:00
make mingw OPT="$(OPT)"
run: mingw-pro
2017-09-26 08:59:34 +02:00
$(MINGW_OUTPUT)
2017-11-09 18:34:03 +01:00
linux64-lto:
2018-02-26 07:43:59 +01:00
$(CC) $(GTK_INCLUDES) $(SOURCES) $(SYSTEM) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX64_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o $(BIN_NAME)
2017-11-11 20:52:12 +01:00
linux64-lto-pro:
$(eval OPT += $(OPT_PRO))
make linux64-lto OPT="$(OPT)"
2017-09-26 08:59:34 +02:00
2017-11-09 18:34:03 +01:00
linux32-lto:
2018-02-26 07:43:59 +01:00
$(CC) $(GTK_INCLUDES) $(SOURCES) $(SYSTEM) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX32_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o $(BIN_NAME)
2017-11-11 20:52:12 +01:00
linux32-lto-pro:
$(eval OPT += $(OPT_PRO))
make linux32-lto OPT="$(OPT)"
2017-09-26 08:59:34 +02:00
2017-11-20 07:14:37 +01:00
chip-lto:
2018-02-26 07:43:59 +01:00
$(CC) $(LINUX_INCLUDES) $(GTK_INCLUDES) $(SOURCES) src/system/chip.c $(TIC80_SRC) $(SOURCES_EXT) $(OPT) -D__CHIP__ $(INCLUDES) $(LINUX_ARM_LIBS) $(GTK_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o $(BIN_NAME)
2017-11-11 20:52:12 +01:00
2017-11-20 07:14:37 +01:00
chip-lto-pro:
2017-11-11 20:52:12 +01:00
$(eval OPT += $(OPT_PRO))
2017-11-20 07:14:37 +01:00
make chip-lto OPT="$(OPT)"
2017-09-26 08:59:34 +02:00
2018-02-27 08:14:17 +01:00
WREN_A=$(3RD_PARTY)/wren-0.1.0/lib/libwren.a
SDLGPU_A=$(3RD_PARTY)/sdl-gpu/build/linux/libsdlgpu.a
$(WREN_A):
make static -C $(3RD_PARTY)/wren-0.1.0/
$(SDLGPU_A):
make -C $(3RD_PARTY)/sdl-gpu/build/linux/
linux: $(WREN_A) $(SDLGPU_A)
2018-02-26 07:43:59 +01:00
$(CC) $(LINUX_INCLUDES) $(SOURCES) $(SYSTEM) $(LPEG_SRC) $(GIF_SRC) $(SOURCES_EXT) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_LIBS) $(LINUX_LINKER_FLAGS) -o $(BIN_NAME)
2017-11-08 15:08:12 +01:00
2017-11-11 20:52:12 +01:00
linux-pro:
$(eval OPT += $(OPT_PRO))
make linux OPT="$(OPT)"
2017-09-26 08:59:34 +02:00
macosx:
2018-02-26 07:43:59 +01:00
$(CC) $(SOURCES) $(SYSTEM) $(TIC80_SRC) $(SOURCES_EXT) src/ext/file_dialog.m $(OPT) $(MACOSX_OPT) $(INCLUDES) $(MACOSX_LIBS) -o $(BIN_NAME)
2017-09-26 08:59:34 +02:00
2017-11-11 20:52:12 +01:00
macosx-pro:
$(eval OPT += $(OPT_PRO))
make macosx OPT="$(OPT)"
bin/res.o: build/mingw/res.rc build/mingw/icon.ico
2017-09-26 08:59:34 +02:00
windres $< $@
BIN2TXT= tools/bin2txt/bin2txt
bin/html.o: src/html.c build/html/index.html build/html/tic.js
$(BIN2TXT) build/html/index.html bin/assets/index.html.dat -z
$(BIN2TXT) build/html/tic.js bin/assets/tic.js.dat -z
$(CC) -c src/html.c $(OPT) $(INCLUDES) -o $@
bin/assets/config.tic.dat: config.tic
$(BIN2TXT) $< $@ -z
bin/assets/fire.tic.dat: demos/fire.tic
$(BIN2TXT) $< $@ -z
bin/assets/p3d.tic.dat: demos/p3d.tic
$(BIN2TXT) $< $@ -z
bin/assets/palette.tic.dat: demos/palette.tic
$(BIN2TXT) $< $@ -z
bin/assets/quest.tic.dat: demos/quest.tic
$(BIN2TXT) $< $@ -z
bin/assets/sfx.tic.dat: demos/sfx.tic
$(BIN2TXT) $< $@ -z
bin/assets/font.tic.dat: demos/font.tic
$(BIN2TXT) $< $@ -z
bin/assets/music.tic.dat: demos/music.tic
$(BIN2TXT) $< $@ -z
bin/assets/tetris.tic.dat: demos/tetris.tic
$(BIN2TXT) $< $@ -z
bin/assets/jsdemo.tic.dat: demos/jsdemo.tic
$(BIN2TXT) $< $@ -z
bin/assets/luademo.tic.dat: demos/luademo.tic
$(BIN2TXT) $< $@ -z
2018-02-05 14:52:55 +01:00
bin/assets/wrendemo.tic.dat: demos/wrendemo.tic
$(BIN2TXT) $< $@ -z
2017-09-26 08:59:34 +02:00
bin/assets/moondemo.tic.dat: demos/moondemo.tic
$(BIN2TXT) $< $@ -z
bin/assets/benchmark.tic.dat: demos/benchmark.tic
$(BIN2TXT) $< $@ -z
2017-09-26 08:59:34 +02:00
clean: $(TIC_O) $(TIC80_O)
2017-11-09 18:34:03 +01:00
del bin\*.o