bootmii-utils/common.mk

61 lines
1.3 KiB
Makefile
Raw Permalink Normal View History

2009-05-15 16:06:07 +02:00
AR = $(PREFIX)ar
AS = $(PREFIX)as
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
LD = $(PREFIX)ld
OBJCOPY = $(PREFIX)objcopy
RANLIB = $(PREFIX)ranlib
STRIP = $(PREFIX)strip
BIN2S = $(DEVKITPPC)/bin/bin2s
ifeq ($(NOMAPFILE),)
LDFLAGS += -Wl,-Map,$(TARGET).map
endif
ifneq ($(LDSCRIPT),)
LDFLAGS += -Wl,-T$(LDSCRIPT)
endif
DEPDIR = .deps
all: $(TARGET)
$(TARGET): $(OBJS)
@echo " LINK $@"
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
ifneq ($(LDSCRIPT),)
$(TARGET): $(LDSCRIPT)
endif
%.o: %.c
@echo " COMPILE $<"
@mkdir -p $(DEPDIR)
@$(CC) $(CFLAGS) $(DEFINES) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -c $< -o $@
%.o: %.s
@echo " ASSEMBLE $<"
@$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@
%.o: %.S
@echo " ASSEMBLE $<"
@$(CC) $(CFLAGS) $(DEFINES) $(ASFLAGS) -c $< -o $@
clean:
rm -rf $(DEPDIR)
rm -f $(TARGET) $(TARGET).map $(OBJS)
define bin2o
@echo " BIN2S $(notdir $<)"
@$(BIN2S) -a 32 $< | $(AS) -o $(@)
@echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
@echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
@echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef
-include $(DEPDIR)/*
.PHONY: clean