Fix another malloc/delete mismatch, and improve makefile

This commit is contained in:
2021-12-09 14:51:28 -05:00
parent d5cb25276b
commit 46f38b8360
2 changed files with 18 additions and 7 deletions

View File

@@ -1,15 +1,26 @@
OS=unspecified
ifeq ($(OS),mingw)
EXE=main.exe
LIBS=-lws2_32
LUAFLAGS=-DLUA_COMPAT_ALL
OPT=-g -O1
DRIVER=driver-mingw
else ifeq ($(OS),linux)
EXE=main
LIBS=
LUAFLAGS=-DLUA_USE_POSIX
OPT=-g -O1
DRIVER=driver-linux
else
$(error You must specify OS=linux or OS=mingw)
# In this case, any attempt to build luprex will trigger an error,
# But making 'clean' will still work.
ERROR=$(error You must specify OS=linux or OS=mingw)
EXE=main
LIBS=$(ERROR)
LUAFLAGS=$(ERROR)
OPT=$(ERROR)
DRIVER=driver-xxx
endif
LUA_OBJ_FILES=\
@@ -80,18 +91,18 @@ CORE_OBJ_FILES=\
obj/drivertests.o\
obj/printbuffer.o\
obj/main.o \
obj/driver-$(OS).o\
obj/$(DRIVER).o\
lobj/%.o: ../eris-master/src/%.c
gcc -Wall -g -DLUA_USE_APICHECK $(LUAFLAGS) -c -MMD $< -o $@
gcc -Wall $(OPT) -DLUA_USE_APICHECK $(LUAFLAGS) -c -MMD $< -o $@
obj/%.o: cpp/%.cpp
g++ -std=c++17 -Wall -g -Iinc -Icpp -c -MMD $< -o $@
g++ -std=c++17 -Wall $(OPT) -Iinc -Icpp -c -MMD $< -o $@
$(EXE): $(CORE_OBJ_FILES) $(LUA_OBJ_FILES)
g++ -std=c++17 -Wall -g -o $@ $(CORE_OBJ_FILES) $(LUA_OBJ_FILES) $(LIBS)
g++ -std=c++17 -Wall $(OPT) -o $@ $(CORE_OBJ_FILES) $(LUA_OBJ_FILES) $(LIBS)
clean:
rm -f main.exe main obj/* lobj/*