switch to premake

This commit is contained in:
sam 2024-05-08 17:27:06 +12:00
parent 7d230f2ccf
commit 8ab0f72f56
29 changed files with 492 additions and 62 deletions

View file

@ -1,25 +1,58 @@
LIBRARY=libgearlib.a
CC:=gcc
AR=ar
CFLAGS=-O3 -Iinclude -g
LDFLAGS=-lglfw -lm
CFILES=$(shell cd src && find -L * -type f -name '*.c')
OBJDIR=obj
OBJ=$(addprefix $(OBJDIR)/, $(CFILES:.c=.o))
$(LIBRARY): $(OBJ) Makefile
$(AR) rcs $(LIBRARY) $(OBJ)
obj/%.o: src/%.c
mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
run: $(LIBRARY)
make -C examples test
cd examples && ./test
clean:
rm -rf $(OBJ) $(LIBRARY)
make -C examples clean
# Alternative GNU Make workspace makefile autogenerated by Premake
ifndef config
config=debug
endif
ifndef verbose
SILENT = @
endif
ifeq ($(config),debug)
gearlib_config = debug
test_config = debug
else ifeq ($(config),release)
gearlib_config = release
test_config = release
else
$(error "invalid configuration $(config)")
endif
PROJECTS := gearlib test
.PHONY: all clean help $(PROJECTS)
all: $(PROJECTS)
gearlib:
ifneq (,$(gearlib_config))
@echo "==== Building gearlib ($(gearlib_config)) ===="
@${MAKE} --no-print-directory -C . -f gearlib.make config=$(gearlib_config)
endif
test: gearlib
ifneq (,$(test_config))
@echo "==== Building test ($(test_config)) ===="
@${MAKE} --no-print-directory -C . -f test.make config=$(test_config)
endif
clean:
@${MAKE} --no-print-directory -C . -f gearlib.make clean
@${MAKE} --no-print-directory -C . -f test.make clean
help:
@echo "Usage: make [config=name] [target]"
@echo ""
@echo "CONFIGURATIONS:"
@echo " debug"
@echo " release"
@echo ""
@echo "TARGETS:"
@echo " all (default)"
@echo " clean"
@echo " gearlib"
@echo " test"
@echo ""
@echo "For more information, see https://github.com/premake/premake-core/wiki"