83 lines
2.3 KiB
Makefile
83 lines
2.3 KiB
Makefile
#Compiler and Linker
|
|
CC := clang
|
|
|
|
#The Target Binary Program
|
|
TARGET := wotos
|
|
|
|
#The Directories, Source, Includes, Objects, Binary and Resources
|
|
SRCDIR := src
|
|
INCDIR := lib
|
|
BUILDDIR := build
|
|
TARGETDIR := bin
|
|
RESDIR := res
|
|
SRCEXT := c
|
|
DEPEXT := d
|
|
OBJEXT := o
|
|
|
|
#Flags, Libraries and Includes
|
|
CFLAGS := -Wall -pedantic -Wno-gnu-statement-expression
|
|
CFLAGS += -Ilib/cglm/include -Ilib/glad/include -Ilib/glfw/include -Ilib/stb
|
|
CFLAGS += -Iinclude/ -I/usr/include/freetype2 -I/usr/include/stb
|
|
LDFLAGS := -lglfw -ldl -lmpv -lfreetype -lm
|
|
INC := -I$(INCDIR) -I/usr/local/include
|
|
INCDEP := -I$(INCDIR)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
#DO NOT EDIT BELOW THIS LINE
|
|
#---------------------------------------------------------------------------------
|
|
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
|
|
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
|
|
|
|
#Defauilt Make
|
|
all: resources $(TARGET)
|
|
|
|
#Custom install
|
|
libs:
|
|
cd lib/cglm && cmake . -DCGLM_STATIC=ON && make
|
|
cd lib/glad && $(CC) -o src/glad.o -Iinclude -c src/glad.c
|
|
cd lib/glfw && cmake . && make
|
|
|
|
#Remake
|
|
remake: cleaner all
|
|
|
|
#Copy Resources from Resources Directory to Target Directory
|
|
resources: directories
|
|
@cp -r $(RESDIR)/* $(TARGETDIR)/
|
|
|
|
#Make the Directories
|
|
directories:
|
|
@mkdir -p $(TARGETDIR)
|
|
@mkdir -p $(BUILDDIR)
|
|
|
|
#Clean only Objecst
|
|
clean:
|
|
@$(RM) -rf $(BUILDDIR)
|
|
|
|
#Full Clean, Objects and Binaries
|
|
cleaner: clean
|
|
@$(RM) -rf $(TARGETDIR)
|
|
|
|
#Pull in dependency info for *existing* .o files
|
|
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
|
|
|
|
#Link
|
|
$(TARGET): $(OBJECTS)
|
|
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LDFLAGS)
|
|
|
|
#Compile
|
|
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
|
|
@mkdir -p $(dir $@)
|
|
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
|
|
@$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
|
|
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
|
|
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
|
|
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
|
|
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
|
|
|
|
#Run
|
|
run: all
|
|
@$(TARGETDIR)/$(TARGET) $(ARGS)
|
|
|
|
#Non-File Targets
|
|
.PHONY: all remake clean cleaner resources
|