Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.sh tweaks #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

herbygillot
Copy link

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

- support environmentally-declared CFLAGS and LDFLAGS
- indicate build failure with an error exit code
@herbygillot herbygillot changed the title Tweak build.sh: build.sh tweaks May 9, 2020
@technomancy
Copy link

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

@herbygillot
Copy link
Author

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

@stefanos82
Copy link

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.

@ghost
Copy link

ghost commented Jun 2, 2020

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.)

@mmatongo
Copy link

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.

@deric
Copy link

deric commented Feb 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants