49 lines
867 B
Makefile
49 lines
867 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=gnu++20
|
|
LDFLAGS =
|
|
|
|
|
|
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) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
$(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)
|