librw/Make.common
2017-07-12 10:10:57 +02:00

29 lines
724 B
Plaintext

BUILDDIR=build-$(BUILD)
SRCDIR=src
SRC := $(wildcard $(SRCDIR)/*.cpp $(SRCDIR)/*/*.cpp)
OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC))
DEP := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.d,$(SRC))
INC := $(INC) -I/usr/local/include
# define render target, e.g. null -> -DRW_NULL
BUILDDEF := $(shell echo $(BUILD) | tr a-z A-Z | sed 's/^/-DRW_/')
CFLAGS := $(CFLAGS) $(BUILDDEF)
default: $(TARGET)
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(INC) -c $< -o $@
$(BUILDDIR)/%.d: $(SRCDIR)/%.cpp
@mkdir -p $(@D)
$(CXX) -MM -MT '$(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$<)' $(CFLAGS) $(INC) $< > $@
clean:
rm -rf $(BUILDDIR)
cleanall:
rm -rf $(BUILDDIR)
rm $(TARGET)
-include $(DEP)