48 lines
844 B
Makefile
48 lines
844 B
Makefile
include OBJECTS
|
|
|
|
OBJDIR = build/linux
|
|
|
|
SRC_PATH = $(SRC:%=$(SRCDIR)/%)
|
|
OBJ = $(SRC_PATH:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
|
|
|
|
REMOVEDIR = rm -rf
|
|
|
|
CFLAGS += -std=gnu99
|
|
CXXFLAGS += -std=c++17
|
|
|
|
|
|
CFLAGS += -I$(INCDIR) -DLINUX
|
|
CXXFLAGS += -I$(INCDIR) -DLINUX
|
|
LDFLAGS += -lSDL2
|
|
|
|
linux: $(OBJDIR)/$(TARGET)
|
|
|
|
all: $(OBJDIR)/$(TARGET)
|
|
|
|
|
|
.SECONDARY: $(TARGET)
|
|
.PRECIOUS: $(OBJ)
|
|
$(OBJDIR)/$(TARGET): $(OBJ) | $(OBJDIR)
|
|
@echo link $^
|
|
@$(CXX) $(LDFLAGS) -o $@ $^
|
|
|
|
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
|
|
@echo compile $<
|
|
@mkdir -p $(dir $@)
|
|
@$(CC) -c $(CFLAGS) $< -o $@
|
|
|
|
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
|
|
@echo compile $<
|
|
@mkdir -p $(dir $@)
|
|
@$(CXX) -c $(CXXFLAGS) $< -o $@
|
|
|
|
$(OBJDIR):
|
|
mkdir -p $(OBJDIR)
|
|
|
|
clean:
|
|
@$(REMOVEDIR) "$(OBJDIR)"
|
|
@echo clean $(OBJDIR)
|
|
|
|
run: $(OBJDIR)/$(TARGET)
|
|
@echo run $(OBJDIR)/$(TARGET)
|
|
@$(OBJDIR)/$(TARGET)
|