Makefile simplification
This commit is contained in:
parent
008458c7f1
commit
40974a5261
124
Makefile
124
Makefile
|
@ -16,129 +16,100 @@ OPT ?= 0
|
||||||
INFO :=
|
INFO :=
|
||||||
|
|
||||||
ifeq ($(DBG),1)
|
ifeq ($(DBG),1)
|
||||||
QFLAGS += -g
|
CFLAGS += -g
|
||||||
INFO = dbg
|
INFO += dbg
|
||||||
else
|
else
|
||||||
QFLAGS += -DNDEBUG -s
|
CFLAGS += -DNDEBUG
|
||||||
INFO = rel
|
LDFLAGS += -s
|
||||||
|
INFO += rel
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(OPT),1)
|
ifeq ($(OPT),small)
|
||||||
QFLAGS += -O2 -flto
|
CFLAGS += -Os
|
||||||
|
AR = ar
|
||||||
|
INFO := $(addsuffix _small,$(INFO))
|
||||||
|
else
|
||||||
|
ifeq ($(OPT), 1)
|
||||||
|
CFLAGS += -O2 -flto
|
||||||
AR = llvm-ar
|
AR = llvm-ar
|
||||||
INFO = opt
|
INFO := $(addsuffix _opt,$(INFO))
|
||||||
else
|
else
|
||||||
QFLAGS += -O0
|
CFLAGS += -O0
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
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)
|
CFLAGS += -DHAVE_CEIL -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) -MD $(WARNING_FLAGS) -I. -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\"
|
||||||
|
|
||||||
ELIBS = engine quickjs
|
PKGCMD = tar --directory $(BIN) --exclude="./*.a" --exclude="./obj" -czf $(DISTDIR)/$(DIST) .
|
||||||
|
|
||||||
PKGCMD = tar --directory $(BIN) --exclude="./*.a" --exclude="./obj" --exclude="./include" -czf $(DISTDIR)/$(DIST) .
|
|
||||||
ZIP = .tar.gz
|
ZIP = .tar.gz
|
||||||
UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
||||||
|
|
||||||
ARCH = x64
|
ARCH = x64
|
||||||
|
|
||||||
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -I. -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -c $< -o $@
|
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
LINKER_FLAGS += -mwin32 -static
|
LDFLAGS += -mwin32 -static
|
||||||
COMPILER_FLAGS += -mwin32
|
CFLAGS += -mwin32
|
||||||
ELIBS += mingw32 kernel32 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
|
LDLIBS += mingw32 kernel32 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
|
||||||
EXT = .exe
|
EXT = .exe
|
||||||
PLAT = w64
|
PLAT = w64
|
||||||
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
||||||
ZIP = .zip
|
ZIP = .zip
|
||||||
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
||||||
else ifeq ($(CC), emcc)
|
else ifeq ($(CC), emcc)
|
||||||
LINKER_FLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -pthread --preload-file test.db -s ALLOW_MEMORY_GROWTH=1
|
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -pthread -s ALLOW_MEMORY_GROWTH=1
|
||||||
COMPILER_FLAGS += -pthread
|
CFLAGS += -pthread
|
||||||
ELIBS += pthread quickjs GL openal c m dl
|
LDLIBS += pthread quickjs GL openal c m dl
|
||||||
CC = emcc
|
CC = emcc
|
||||||
EXT = .html
|
EXT = .html
|
||||||
PLAT = html5
|
PLAT = html5
|
||||||
else
|
else
|
||||||
UNAME != uname -s
|
UNAME != uname -s
|
||||||
ifeq ($(UNAME), Linux)
|
ifeq ($(UNAME), Linux)
|
||||||
LINKER_FLAGS += -pthread -rdynamic
|
LDFLAGS += -pthread -rdynamic
|
||||||
ELIBS += GL pthread c m dl X11 Xi Xcursor EGL asound
|
LDLIBS += GL pthread c m dl X11 Xi Xcursor EGL asound
|
||||||
PLAT = linux-$(ARCH)
|
PLAT = linux-$(ARCH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME), Darwin)
|
ifeq ($(UNAME), Darwin)
|
||||||
ifeq ($(PLATFORM), macosx)
|
ifeq ($(PLATFORM), macosx)
|
||||||
ELIBS = Coca QuartzCore OpenGL
|
LDLIBS += Coca QuartzCore OpenGL
|
||||||
PLAT = mac-$(ARCH)
|
PLAT = mac-$(ARCH)
|
||||||
else ifeq ($(PLATFORM), iphoneos)
|
else ifeq ($(PLATFORM), iphoneos)
|
||||||
ELIBS = Foundation UIKit OpenGLES GLKit
|
LDLIBS += Foundation UIKit OpenGLES GLKit
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BIN = bin/$(CC)/$(INFO)/
|
BIN = bin/$(CC)/$(INFO)
|
||||||
|
|
||||||
objprefix = $(BIN)obj
|
OBJDIR = $(BIN)/obj
|
||||||
|
|
||||||
define prefix
|
|
||||||
echo $(1) | tr " " "\n" | sed 's/.*/$(2)&$(3)/'
|
|
||||||
endef
|
|
||||||
|
|
||||||
define rm
|
|
||||||
tmp=$$(mktemp); \
|
|
||||||
echo $(2) | tr " " "\n" > $${tmp}; \
|
|
||||||
echo $(1) | tr " " "\n" | grep -v -f $${tmp}; \
|
|
||||||
rm $${tmp}
|
|
||||||
endef
|
|
||||||
|
|
||||||
# All other sources
|
# All other sources
|
||||||
edirs != find source -type d -name include
|
OBJS != find source/engine -type f -name '*.c'
|
||||||
subengs = sound 3d
|
OBJS := $(patsubst %.c, %.o,$(OBJS))
|
||||||
|
OBJS := $(addprefix $(BIN)/obj/, $(OBJS))
|
||||||
|
|
||||||
ifeq ($(DBG), 1)
|
engineincs != find source/engine -maxdepth 1 -type d
|
||||||
subengs += debug
|
|
||||||
endif
|
|
||||||
|
|
||||||
edirs += source/engine $(addprefix source/engine/, $(subengs)) source/engine/thirdparty/Nuklear
|
|
||||||
ehead != find source/engine source/engine/sound source/engine/debug -maxdepth 1 -type f -name *.h
|
|
||||||
eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs
|
|
||||||
|
|
||||||
engincs != find source/engine -maxdepth 1 -type d
|
|
||||||
includeflag != find source -type d -name include
|
includeflag != find source -type d -name include
|
||||||
includeflag += $(engincs) source/engine/thirdparty/Nuklear
|
includeflag += $(engineincs) source/engine/thirdparty/Nuklear
|
||||||
includeflag := $(addprefix -I, $(includeflag))
|
includeflag := $(addprefix -I, $(includeflag))
|
||||||
|
|
||||||
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types #-Wall -Wno-incompatible-function-pointer-types -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function -Wno-int-conversion
|
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types #-Wall -Wno-incompatible-function-pointer-types -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function -Wno-int-conversion
|
||||||
|
|
||||||
|
NAME = yugine$(EXT)
|
||||||
SEM = 0.0.1
|
SEM = 0.0.1
|
||||||
COM != fossil describe
|
COM != fossil describe
|
||||||
VER = $(SEM)-$(COM)
|
VER = $(SEM)-$(COM)
|
||||||
|
|
||||||
|
LDLIBS := $(addprefix -l, $(LDLIBS))
|
||||||
|
|
||||||
LIBPATH = -L$(BIN)
|
DEPENDS = $(OBJS:.o=.d)
|
||||||
|
|
||||||
NAME = yugine$(EXT)
|
|
||||||
|
|
||||||
ELIBS != $(call prefix, $(ELIBS), -l)
|
|
||||||
|
|
||||||
objects = $(eobjects)
|
|
||||||
DEPENDS = $(objects:.o=.d)
|
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
ENGINE = $(BIN)libengine.a
|
|
||||||
|
|
||||||
SCRIPTS = $(shell ls source/scripts/*.js)
|
SCRIPTS = $(shell ls source/scripts/*.js)
|
||||||
|
|
||||||
LINK = $(LIBPATH) $(LINKER_FLAGS) $(ELIBS)
|
|
||||||
|
|
||||||
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
||||||
|
|
||||||
DIST = yugine-$(PLAT)-$(COM)$(ZIP)
|
DIST = yugine-$(PLAT)-$(COM)$(ZIP)
|
||||||
|
@ -154,12 +125,12 @@ install: $(DISTDIR)/$(DIST)
|
||||||
# @unzip $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
# @unzip $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
||||||
@$(UNZIP)
|
@$(UNZIP)
|
||||||
|
|
||||||
$(BIN)$(NAME): $(objprefix)/source/engine/yugine.o $(ENGINE) $(BIN)libquickjs.a
|
$(BIN)/$(NAME): $(BIN)/libengine.a $(BIN)/libquickjs.a
|
||||||
@echo Linking $(NAME)
|
@echo Linking $(NAME)
|
||||||
$(CC) $< $(LINK) -o $(BIN)$(NAME)
|
$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||||
@echo Finished build
|
@echo Finished build
|
||||||
|
|
||||||
$(DISTDIR)/$(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 $(DISTDIR)
|
@mkdir -p $(DISTDIR)
|
||||||
@cp -rf assets/* $(BIN)
|
@cp -rf assets/* $(BIN)
|
||||||
|
@ -167,19 +138,18 @@ $(DISTDIR)/$(DIST): $(BIN)$(NAME) source/shaders/* $(SCRIPTS) assets/*
|
||||||
@cp -r source/scripts $(BIN)
|
@cp -r source/scripts $(BIN)
|
||||||
@$(PKGCMD)
|
@$(PKGCMD)
|
||||||
|
|
||||||
$(BIN)libquickjs.a:
|
$(BIN)/libengine.a: $(OBJS)
|
||||||
|
@$(AR) r $@ $^
|
||||||
|
|
||||||
|
$(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)
|
||||||
|
|
||||||
$(ENGINE): $(eobjects)
|
$(OBJDIR)/%.o:%.c
|
||||||
@echo Making library engine.a
|
|
||||||
@$(AR) r $(ENGINE) $(eobjects)
|
|
||||||
|
|
||||||
$(objprefix)/%.o:%.c
|
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@echo Making C object $@
|
@echo Making C object $@
|
||||||
@$(CC) $(COMPILER_FLAGS)
|
@$(CC) $(CFLAGS) -c $^ -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo Cleaning project
|
@echo Cleaning project
|
||||||
|
|
|
@ -318,7 +318,7 @@ void pack_engine()
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void packengine(){
|
void pack_engine(){
|
||||||
YughError("Cannot pack engine on a web build.");
|
YughError("Cannot pack engine on a web build.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
22857
source/engine/thirdparty/sqlite3/shell.c
vendored
22857
source/engine/thirdparty/sqlite3/shell.c
vendored
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue