rendlib/Makefile

36 lines
923 B
Makefile
Raw Permalink Normal View History

CC=gcc
2024-10-14 20:40:35 +00:00
CFLAGS=-DFREEGLUT -g3 -iquote include/
LFLAGS=-lglfw -L/usr/lib64 -lGLEW -lGL -lX11 -lGLU -lassimp -lm
LD=ld
2024-10-14 20:40:35 +00:00
SRCDIR=src
BINDIR=build
TSTDIR=tests
2024-10-14 20:40:35 +00:00
LIB_SRCS = $(wildcard $(SRCDIR)/*.c)
LIB_OBJS = $(addprefix $(BINDIR)/, $(notdir $(LIB_SRCS:.c=.o)))
TST_SRCS = $(wildcard $(TSTDIR)/*.c)
TST_OBJS = $(addprefix $(BINDIR)/$(TSTDIR)/, $(notdir $(TST_SRCS:.c=.o)))
TST_ASST = $(shell find $(TSTDIR) -maxdepth 1 -mindepth 1 -type d)
2024-10-14 20:40:35 +00:00
init:
mkdir -p $(BINDIR)
mkdir -p $(BINDIR)/tests
2024-10-14 20:40:35 +00:00
all: init $(LIB_OBJS)
$(LD) -relocatable $(LIB_OBJS) -o $(BINDIR)/rendlib
2024-10-14 20:40:35 +00:00
$(BINDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LFLAGS)
$(BINDIR)/$(TSTDIR)/test-%.o: $(TSTDIR)/test-%.c $(TSTDIR)/assets-% | all
$(CC) $(CFLAGS) $< $(BINDIR)/rendlib -o $@ $(LFLAGS)
cp -rf $(word 2,$^) $(BINDIR)/$(TSTDIR)/
test: $(TST_OBJS)
runt%: $(BINDIR)/$(TSTDIR)/test-%.o
cd $(BINDIR)/$(TSTDIR); ./test-$*.o
clean:
2024-10-14 20:40:35 +00:00
rm -rf $(BINDIR)