Makefile fix to easily make linux, windows, web; DBG flag set correctly
This commit is contained in:
parent
3e0dc30645
commit
467f7b29ea
108
Makefile
108
Makefile
|
@ -5,51 +5,73 @@ UNAME != uname
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
# DBG --- build with debugging symbols and logging
|
# DBG --- build with debugging symbols and logging
|
||||||
# ED --- build with or without editor
|
|
||||||
# OPT --- Optimize
|
# Temp to strip long emcc paths to just emcc
|
||||||
|
CC := $(notdir $(CC))
|
||||||
|
|
||||||
|
DBG ?= 1
|
||||||
|
|
||||||
QFLAGS :=
|
QFLAGS :=
|
||||||
|
|
||||||
ifdef DBG
|
INFO :=
|
||||||
QFLAGS += -O0 -g -DDBG
|
|
||||||
|
ifeq ($(DBG),1)
|
||||||
|
QFLAGS += -g
|
||||||
INFO = dbg
|
INFO = dbg
|
||||||
|
|
||||||
ifeq ($(CC),tcc)
|
ifeq ($(CC),tcc)
|
||||||
QFLAGS +=
|
QFLAGS +=
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
QFLAGS += -O2
|
QFLAGS += -DNDEBUG -s
|
||||||
INFO = rel
|
INFO = rel
|
||||||
CC = clang
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef OPT
|
|
||||||
QFLAGS += -flto
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef ED
|
|
||||||
QFLAGS += -DED
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
QFLAGS += -DHAVE_CEIL -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF
|
QFLAGS += -DHAVE_CEIL -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF
|
||||||
|
|
||||||
|
# Uncomment for smallest binary
|
||||||
|
# QFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -fno-stack-protector -fomit-frame-pointer -fno-math-errno -fno-unroll-loops -fmerge-all-constants -fno-ident -mfpmath=387 -fsingle-precision-constant -ffast-math
|
||||||
|
|
||||||
PTYPE != uname -m
|
PTYPE != uname -m
|
||||||
|
|
||||||
LINKER_FLAGS = $(QFLAGS)
|
LINKER_FLAGS = $(QFLAGS)
|
||||||
|
|
||||||
|
ELIBS = engine quickjs
|
||||||
|
|
||||||
|
PKGCMD = tar --directory $(BIN) --exclude="./*.a" --exclude="./obj" --exclude="./include" -czf $(DISTDIR)/$(DIST) .
|
||||||
|
ZIP = .tar.gz
|
||||||
|
|
||||||
|
ARCH = x64
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
QFLAGS += -mwin32
|
LINKER_FLAGS += -mwin32 -static
|
||||||
LINKER_FLAGS +=
|
ELIBS += kernel32 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
|
||||||
ELIBS = engine kernel32 user32 shell32 dxgi quickjs gdi32 ws2_32 ole32 winmm setupapi m
|
|
||||||
EXT = .exe
|
EXT = .exe
|
||||||
else ifeq ($(OS), WEB)
|
PLAT = w64
|
||||||
|
PKGCMD = zip -r $(DISTDIR)/$(DIST) $(BIN) --exclude "./*.a" --exclude="./obj" --exclude="./include"
|
||||||
|
ZIP = .zip
|
||||||
|
else ifeq ($(CC), emcc)
|
||||||
LINKER_FLAGS += -sFULL_ES3
|
LINKER_FLAGS += -sFULL_ES3
|
||||||
ELIBS = engine pthread quickjs GL c m dl
|
ELIBS += pthread quickjs GL c m dl
|
||||||
CC = emcc
|
CC = emcc
|
||||||
EXT = .html
|
EXT = .html
|
||||||
|
PLAT = html5
|
||||||
else
|
else
|
||||||
LINKER_FLAGS += -L/usr/local/lib -pthread -rdynamic
|
UNAME != uname -s
|
||||||
ELIBS = engine pthread quickjs GL c m dl X11 Xi Xcursor EGL asound
|
ifeq ($(UNAME), Linux)
|
||||||
|
LINKER_FLAGS += -pthread -rdynamic
|
||||||
|
ELIBS += GL pthread c m dl X11 Xi Xcursor EGL asound
|
||||||
|
PLAT = linux-$(ARCH)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UNAME), Darwin)
|
||||||
|
ifeq ($(PLATFORM), macosx)
|
||||||
|
ELIBS = Coca QuartzCore OpenGL
|
||||||
|
PLAT = mac-$(ARCH)
|
||||||
|
else ifeq ($(PLATFORM), iphoneos)
|
||||||
|
ELIBS = Foundation UIKit OpenGLES GLKit
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BIN = bin/$(CC)/$(INFO)/
|
BIN = bin/$(CC)/$(INFO)/
|
||||||
|
@ -103,7 +125,6 @@ DEPENDS = $(objects:.o=.d)
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
ENGINE = $(BIN)libengine.a
|
ENGINE = $(BIN)libengine.a
|
||||||
INCLUDE = $(BIN)include
|
|
||||||
|
|
||||||
SCRIPTS = $(shell ls source/scripts/*.js)
|
SCRIPTS = $(shell ls source/scripts/*.js)
|
||||||
|
|
||||||
|
@ -111,53 +132,48 @@ LINK = $(LIBPATH) $(LINKER_FLAGS) $(ELIBS)
|
||||||
|
|
||||||
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
||||||
|
|
||||||
DIST = $(NAME)-$(MYTAG).tar.gz
|
DIST = yugine-$(PLAT)-$(COM)$(ZIP)
|
||||||
|
DISTDIR = ./dist
|
||||||
|
|
||||||
yugine: $(BIN)yugine
|
.DEFAULT_GOAL := all
|
||||||
|
all: $(DISTDIR)/$(DIST)
|
||||||
|
|
||||||
$(NAME): $(BIN)$(NAME)
|
DESTDIR ?= ~/.bin
|
||||||
|
|
||||||
|
install: $(DISTDIR)/$(DIST)
|
||||||
|
@echo Unpacking $(DIST) in $(DESTDIR)
|
||||||
|
# @unzip $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
||||||
|
@cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
||||||
|
|
||||||
$(BIN)$(NAME): $(objprefix)/source/engine/yugine.o $(ENGINE) $(BIN)libquickjs.a
|
$(BIN)$(NAME): $(objprefix)/source/engine/yugine.o $(ENGINE) $(BIN)libquickjs.a
|
||||||
@echo Linking $(NAME)
|
@echo Linking $(NAME)
|
||||||
$(CC) $< $(LINK) -o $(BIN)$(NAME)
|
$(CC) $< $(LINK) -o $(BIN)$(NAME)
|
||||||
@echo Finished build
|
@echo Finished build
|
||||||
|
|
||||||
$(BIN)$(DIST): $(BIN)$(NAME) source/shaders/* $(SCRIPTS) assets/*
|
$(DISTDIR)/$(DIST): $(BIN)$(NAME) source/shaders/* $(SCRIPTS) assets/*
|
||||||
@echo Creating distribution $(DIST)
|
@echo Creating distribution $(DIST)
|
||||||
@mkdir -p $(BIN)dist
|
@mkdir -p $(DISTDIR)
|
||||||
@cp $(BIN)$(NAME) $(BIN)dist
|
@cp -rf assets/* $(BIN)
|
||||||
@cp -rf assets/* $(BIN)dist
|
@cp -rf source/shaders $(BIN)
|
||||||
@cp -rf source/shaders $(BIN)dist
|
@cp -r source/scripts $(BIN)
|
||||||
@cp -r source/scripts $(BIN)dist
|
@$(PKGCMD)
|
||||||
@tar czf $(DIST) --directory $(BIN)dist .
|
|
||||||
@mv $(DIST) $(BIN)
|
|
||||||
|
|
||||||
$(BIN)libquickjs.a:
|
$(BIN)libquickjs.a:
|
||||||
make -C quickjs clean
|
make -C quickjs clean
|
||||||
make -C quickjs libquickjs.a libquickjs.lto.a CC=$(CC)
|
make -C quickjs libquickjs.a libquickjs.lto.a CC=$(CC)
|
||||||
cp quickjs/libquickjs.* $(BIN)
|
cp quickjs/libquickjs.* $(BIN)
|
||||||
|
|
||||||
dist: $(BIN)$(DIST)
|
|
||||||
|
|
||||||
install: $(BIN)$(DIST)
|
|
||||||
@echo Unpacking $(DIST) in $(DESTDIR)
|
|
||||||
@cp $(BIN)$(DIST) $(DESTDIR)
|
|
||||||
@tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR)
|
|
||||||
@rm $(DESTDIR)/$(DIST)
|
|
||||||
|
|
||||||
$(ENGINE): $(eobjects)
|
$(ENGINE): $(eobjects)
|
||||||
@echo Making library engine.a
|
@echo Making library engine.a
|
||||||
@ar r $(ENGINE) $(eobjects)
|
@llvm-ar r $(ENGINE) $(eobjects)
|
||||||
@mkdir -p $(INCLUDE)
|
|
||||||
@cp -u -r $(ehead) $(INCLUDE)
|
|
||||||
|
|
||||||
$(objprefix)/%.o:%.c
|
$(objprefix)/%.o:%.c
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@echo Making C object $@
|
@echo Making C object $@ OS $(OS)
|
||||||
@$(CC) $(COMPILER_FLAGS)
|
@$(CC) $(COMPILER_FLAGS)
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
clean:
|
||||||
@echo Cleaning project
|
@echo Cleaning project
|
||||||
@rm -rf bin/*
|
@rm -rf bin/*
|
||||||
@rm -f *.gz
|
@rm -f *.gz
|
||||||
|
@rm -rf dist/*
|
||||||
|
|
|
@ -31,7 +31,7 @@ char consolelog[CONSOLE_BUF+1] = {'\0'};
|
||||||
|
|
||||||
void mYughLog(int category, int priority, int line, const char *file, const char *message, ...)
|
void mYughLog(int category, int priority, int line, const char *file, const char *message, ...)
|
||||||
{
|
{
|
||||||
#ifdef DBG
|
#ifndef NDEBUG
|
||||||
if (priority >= logLevel) {
|
if (priority >= logLevel) {
|
||||||
time_t now = time(0);
|
time_t now = time(0);
|
||||||
struct tm *tinfo = localtime(&now);
|
struct tm *tinfo = localtime(&now);
|
||||||
|
@ -51,9 +51,6 @@ void mYughLog(int category, int priority, int line, const char *file, const char
|
||||||
snprintf(buffer, ERROR_BUFFER, "%s:%d: %s, %s: %s\n", file, line, logstr[priority], catstr[category], msgbuffer);
|
snprintf(buffer, ERROR_BUFFER, "%s:%d: %s, %s: %s\n", file, line, logstr[priority], catstr[category], msgbuffer);
|
||||||
|
|
||||||
log_print(buffer);
|
log_print(buffer);
|
||||||
|
|
||||||
// if (category != LOG_SCRIPT && priority >= 2)
|
|
||||||
// js_stacktrace();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ extern char lastlog[];
|
||||||
extern char consolelog[];
|
extern char consolelog[];
|
||||||
extern int logLevel;
|
extern int logLevel;
|
||||||
|
|
||||||
#ifdef DBG
|
#ifndef NDEBUG
|
||||||
#define YughLog(cat, pri, msg, ...) mYughLog(cat, pri, __LINE__, __FILE__, msg, ##__VA_ARGS__)
|
#define YughLog(cat, pri, msg, ...) mYughLog(cat, pri, __LINE__, __FILE__, msg, ##__VA_ARGS__)
|
||||||
#define YughInfo(msg, ...) mYughLog(0, 0, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
#define YughInfo(msg, ...) mYughLog(0, 0, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
||||||
#define YughWarn(msg, ...) mYughLog(0, 1, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
#define YughWarn(msg, ...) mYughLog(0, 1, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
JSContext *js = NULL;
|
JSContext *js = NULL;
|
||||||
JSRuntime *rt = NULL;
|
JSRuntime *rt = NULL;
|
||||||
|
|
||||||
#ifdef DBG
|
#ifndef NDEBUG
|
||||||
#define JS_EVAL_FLAGS JS_EVAL_FLAG_STRICT
|
#define JS_EVAL_FLAGS JS_EVAL_FLAG_STRICT
|
||||||
#else
|
#else
|
||||||
#define JS_EVAL_FLAGS JS_EVAL_FLAG_STRICT | JS_EVAL_FLAG_STRIP
|
#define JS_EVAL_FLAGS JS_EVAL_FLAG_STRICT | JS_EVAL_FLAG_STRIP
|
||||||
|
@ -47,7 +47,7 @@ void script_startup() {
|
||||||
JSValue num_cache[100] = {0};
|
JSValue num_cache[100] = {0};
|
||||||
|
|
||||||
int js_print_exception(JSValue v) {
|
int js_print_exception(JSValue v) {
|
||||||
#ifdef DBG
|
#ifndef NDEBUG
|
||||||
if (JS_IsException(v)) {
|
if (JS_IsException(v)) {
|
||||||
JSValue exception = JS_GetException(js);
|
JSValue exception = JS_GetException(js);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ time_t file_mod_secs(const char *file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void js_stacktrace() {
|
void js_stacktrace() {
|
||||||
#ifdef DBG
|
#ifndef NDEBUG
|
||||||
call_callee(&stacktrace_callee);
|
call_callee(&stacktrace_callee);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "samplerate.h"
|
#include "samplerate.h"
|
||||||
|
|
||||||
#include "stb_ds.h"
|
#include "stb_ds.h"
|
||||||
|
|
|
@ -88,9 +88,9 @@ struct Texture *texture_pullfromfile(const char *path) {
|
||||||
|
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
char *ext = strrchr(path, '.')+1;
|
char *ext = strrchr(path, '.');
|
||||||
|
|
||||||
if (!strcmp(ext, "qoi")) {
|
if (ext && !strcmp(ext, ".qoi")) {
|
||||||
qoi_desc qoi;
|
qoi_desc qoi;
|
||||||
data = qoi_read(path, &qoi, 4);
|
data = qoi_read(path, &qoi, 4);
|
||||||
tex->width = qoi.width;
|
tex->width = qoi.width;
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Uncomment to enable specific converters */
|
||||||
|
//#define ENABLE_SINC_BEST_CONVERTER
|
||||||
|
//#define ENABLE_SINC_FAST_CONVERTER
|
||||||
|
//#define ENABLE_SINC_MEDIUM_CONVERTER
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef HAVE_VISIBILITY
|
#ifdef HAVE_VISIBILITY
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
#define CPU_IS_LITTLE_ENDIAN 1
|
#define CPU_IS_LITTLE_ENDIAN 1
|
||||||
|
|
||||||
/* Enable sinc best converter. */
|
/* Enable sinc best converter. */
|
||||||
#define ENABLE_SINC_BEST_CONVERTER 1
|
#define ENABLE_SINC_BEST_CONVERTER 0
|
||||||
|
|
||||||
/* Enable sinc fast converter. */
|
/* Enable sinc fast converter. */
|
||||||
#define ENABLE_SINC_FAST_CONVERTER 1
|
#define ENABLE_SINC_FAST_CONVERTER 0
|
||||||
|
|
||||||
/* Enable sinc balanced converter. */
|
/* Enable sinc balanced converter. */
|
||||||
#define ENABLE_SINC_MEDIUM_CONVERTER 1
|
#define ENABLE_SINC_MEDIUM_CONVERTER 0
|
||||||
|
|
||||||
/* Define to 1 if you have the `alarm' function. */
|
/* Define to 1 if you have the `alarm' function. */
|
||||||
#define HAVE_ALARM 1
|
#define HAVE_ALARM 1
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "2dphysics.h"
|
#include "2dphysics.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __GLIBC__
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,13 +34,9 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#define SOKOL_TRACE_HOOKS
|
#define SOKOL_TRACE_HOOKS
|
||||||
#ifdef DBG
|
|
||||||
#define SOKOL_DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SOKOL_IMPL
|
#define SOKOL_IMPL
|
||||||
|
|
||||||
#if defined __linux__
|
#if defined __GLIBC__
|
||||||
#define SOKOL_GLCORE33
|
#define SOKOL_GLCORE33
|
||||||
#elif __EMSCRIPTEN__
|
#elif __EMSCRIPTEN__
|
||||||
#define SOKOL_GLES3
|
#define SOKOL_GLES3
|
||||||
|
@ -121,7 +117,7 @@ int backtrace(void **buffer, int size) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void print_stacktrace() {
|
void print_stacktrace() {
|
||||||
#ifdef __linux__
|
#ifdef __GLIBC__
|
||||||
void *ents[512];
|
void *ents[512];
|
||||||
size_t size = backtrace(ents, 512);
|
size_t size = backtrace(ents, 512);
|
||||||
|
|
||||||
|
@ -138,7 +134,7 @@ void print_stacktrace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void seghandle(int sig) {
|
void seghandle(int sig) {
|
||||||
#ifdef __linux__
|
#ifdef __GLIBC__
|
||||||
if (strsignal(sig))
|
if (strsignal(sig))
|
||||||
YughCritical("CRASH! Signal: %s.", strsignal(sig));
|
YughCritical("CRASH! Signal: %s.", strsignal(sig));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue