multiboot_tool/Makefile

38 lines
892 B
Makefile
Raw Normal View History

2014-12-26 11:48:18 +01:00
TARGETS=twiboot mpmboot
TARGET_DIR=~/bin
BUILD_DIR = build
2014-12-26 11:36:32 +01:00
2014-12-26 11:48:18 +01:00
CFLAGS= -pipe -O2 -Wall -Wno-unused-result
CFLAGS+= -MMD -MP -MF $(BUILD_DIR)/$(*D)/$(*F).d
LDFLAGS=
2014-12-26 11:36:32 +01:00
# ------
2014-12-26 11:48:18 +01:00
SRC:= $(wildcard *.c)
2014-12-26 11:36:32 +01:00
2014-12-26 11:48:18 +01:00
all: $(TARGETS)
2014-12-26 11:36:32 +01:00
2014-12-26 11:48:18 +01:00
$(TARGETS): $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
2014-12-26 11:36:32 +01:00
@echo " Linking file: $@"
@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) > /dev/null
2014-12-26 11:48:18 +01:00
$(BUILD_DIR)/%.o: %.c $(MAKEFILE_LIST)
2014-12-26 11:36:32 +01:00
@echo " Building file: $<"
2014-12-26 11:48:18 +01:00
@$(shell test -d $(BUILD_DIR)/$(*D) || mkdir -p $(BUILD_DIR)/$(*D))
@$(CC) $(CFLAGS) -o $@ -c $<
2014-12-26 11:36:32 +01:00
clean:
2014-12-26 11:48:18 +01:00
rm -rf $(BUILD_DIR) $(TARGETS)
2014-12-26 11:36:32 +01:00
2014-12-26 11:48:18 +01:00
install: $(TARGETS)
@mkdir -p $(TARGET_DIR)
rm -f $(patsubst %,$(TARGET_DIR)/%, $(TARGETS))
cp -a $^ $(TARGET_DIR)
install_links: $(TARGETS)
@mkdir -p $(TARGET_DIR)
rm -f $(patsubst %,$(TARGET_DIR)/%, $(TARGETS))
ln -s -t $(TARGET_DIR) $(patsubst %,$(PWD)/%, $(TARGETS))
-include $(shell find $(BUILD_DIR) -name \*.d 2> /dev/null)