lite icon indicating copy to clipboard operation
lite copied to clipboard

build.sh tweaks

Open herbygillot opened this issue 5 years ago • 6 comments

  • support environmentally-declared CFLAGS and LDFLAGS
  • indicate build failure with an error exit code

herbygillot avatar May 09 '20 18:05 herbygillot

Any reason this shouldn't just be done as a makefile instead? Would be nice to have it more declarative.

technomancy avatar May 09 '20 18:05 technomancy

Totally agree it should be a Makefile, just wanted to make it a less intrusive change.

herbygillot avatar May 09 '20 18:05 herbygillot

As a GNU / Linux user, I agree about the use of a makefile; it's my standard procedure for small to medium projects.

But what I'm wondering is the following: since it's an app that can be used on multiple environments, would not it make more sense to use something like Meson?

About CMake, I have no idea how to use it, but Meson is Python and I already know how to use it so...yeah.

stefanos82 avatar May 10 '20 15:05 stefanos82

Any reason this shouldn't just be done as a makefile instead? Would be nice to have it more declarative. @technomancy

CFLAGS ?= -Wall -O3 -g -std=gnu11
LDFLAGS ?= -lSDL2 -lm
CPPFLAGS ?= -Isrc

src/lib/stb/%.o: CPPFLAGS =

SRCS := $(wildcard src/*.c src/api/*.c src/lib/*.c src/lib/stb/*.c src/lib/lua52/*.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))

ifeq ($(OS),Windows_NT)

OUT := lite.exe
CC := x86_64-w64-mingw32-gcc
src/lib/lua52/%.o: CPPFLAGS = -DLUA_USE_POPEN
CPPFLAGS += -Iwinlib/SDL2-2.0.10/x86_64-w64-mingw32/include
LDFLAGS += -Lwinlib/SDL2-2.0.10/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -mwindows
OBJS += res.res

else

OUT := lite
src/lib/lua52/%.o: CPPFLAGS = -DLUA_USE_POSIX

endif

$(OUT): $(OBJS)
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)

res.res: res.rc
	x86_64-w64-mingw32-windres $< -O coff $(OUTPUT_OPTION)

clean:
	-rm -f $(OUT) $(OBJS)

.PHONY: clean

(I haven't tested the Windows part, though.)

ghost avatar Jun 02 '20 20:06 ghost

Any reason this shouldn't just be done as a makefile instead? Would be nice to have it more declarative. @technomancy

CFLAGS ?= -Wall -O3 -g -std=gnu11
LDFLAGS ?= -lSDL2 -lm
CPPFLAGS ?= -Isrc

src/lib/stb/%.o: CPPFLAGS =

SRCS := $(wildcard src/*.c src/api/*.c src/lib/*.c src/lib/stb/*.c src/lib/lua52/*.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))

ifeq ($(OS),Windows_NT)

OUT := lite.exe
CC := x86_64-w64-mingw32-gcc
src/lib/lua52/%.o: CPPFLAGS = -DLUA_USE_POPEN
CPPFLAGS += -Iwinlib/SDL2-2.0.10/x86_64-w64-mingw32/include
LDFLAGS += -Lwinlib/SDL2-2.0.10/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -mwindows
OBJS += res.res

else

OUT := lite
src/lib/lua52/%.o: CPPFLAGS = -DLUA_USE_POSIX

endif

$(OUT): $(OBJS)
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)

res.res: res.rc
	x86_64-w64-mingw32-windres $< -O coff $(OUTPUT_OPTION)

clean:
	-rm -f $(OUT) $(OBJS)

.PHONY: clean

(I haven't tested the Windows part, though.)

Is it possible for you to add an install section, I can't figure out how to install it post compilation.

mmatongo avatar Jun 30 '20 20:06 mmatongo

I've added Makefile in #257, but I haven't tested the Windows part. It should work on Linux/MacOS, though in order to properly install the package, there are more changes needed.

deric avatar Feb 20 '21 08:02 deric