Created
September 30, 2018 15:22
-
-
Save rafacouto/73762854e3b7ee063ba330b5c0dedd9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET_EXEC ?= simul | |
TARGET_PLATFORM ?= linux | |
SRC_DIRS ?= . ../src | |
SRCS := $(shell find $(SRC_DIRS) -name '*.s') | |
SRCS += $(shell find $(SRC_DIRS) -name '*.c') | |
SRCS += $(shell find $(SRC_DIRS) -name '*.cpp') | |
OBJS := $(SRCS:%=%.o) | |
DEPS := $(OBJS:.o=.d) | |
INC_DIRS := $(shell find $(SRC_DIRS) -type d) | |
CPPFLAGS ?= $(addprefix -I,$(INC_DIRS)) -MMD -MP -Wall | |
CPPFLAGS += -DPLATFORM=$(TARGET_PLATFORM) | |
$(TARGET_EXEC): $(OBJS) | |
$(CXX) $(LDFLAGS) -o $@ $(OBJS) | |
# assembly | |
%.s.o: %.s | |
$(AS) $(ASFLAGS) -o $@ -c $< | |
# c source | |
%.c.o: %.c | |
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< | |
# c++ source | |
%.cpp.o: %.cpp | |
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $< | |
.PHONY: clean | |
clean: | |
$(RM) $(TARGET_EXEC) $(OBJS) $(DEPS) | |
-include $(DEPS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment