36 lines
923 B
Makefile
36 lines
923 B
Makefile
CC=gcc
|
|
CFLAGS=-DFREEGLUT -g3 -iquote include/
|
|
LFLAGS=-lglfw -L/usr/lib64 -lGLEW -lGL -lX11 -lGLU -lassimp -lm
|
|
LD=ld
|
|
SRCDIR=src
|
|
BINDIR=build
|
|
TSTDIR=tests
|
|
|
|
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)
|
|
|
|
init:
|
|
mkdir -p $(BINDIR)
|
|
mkdir -p $(BINDIR)/tests
|
|
|
|
all: init $(LIB_OBJS)
|
|
$(LD) -relocatable $(LIB_OBJS) -o $(BINDIR)/rendlib
|
|
|
|
$(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:
|
|
rm -rf $(BINDIR)
|