wut/rpl/common/rules.mk

75 lines
1.8 KiB
Makefile
Raw Normal View History

2015-12-27 03:10:38 +01:00
.SUFFIXES:
2016-06-03 01:04:22 +02:00
ifeq ($(OS),Windows_NT)
CUR_DIR := $(shell cygpath -w ${CURDIR})
else
CUR_DIR := $(CURDIR)
endif
TARGET := $(notdir $(CUR_DIR))
2015-12-27 03:10:38 +01:00
BUILD := build
SOURCE := ../common .
INCLUDE := .
DATA := data
LIBS :=
ifneq ($(BUILD),$(notdir $(CURDIR)))
2016-06-03 01:04:22 +02:00
WUT_ROOT := $(CUR_DIR)/../..
2015-12-27 03:10:38 +01:00
else
2016-06-03 01:04:22 +02:00
WUT_ROOT := $(CUR_DIR)/../../..
2015-12-27 03:10:38 +01:00
endif
include $(WUT_ROOT)/rules/ppc.mk
LD := $(PREFIX)ld
2015-12-27 14:45:32 +01:00
RPLCFLAGS := -Wno-unused-variable -fno-builtin
2015-12-27 03:10:38 +01:00
CFLAGS += -O2 -Wall -std=c11 $(RPLCFLAGS)
ODEPS := stub.o lib.o
ifneq ($(BUILD),$(notdir $(CURDIR)))
2016-06-03 01:04:22 +02:00
export OUTPUT := $(CUR_DIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCE),$(CUR_DIR)/$(dir)) \
$(foreach dir,$(DATA),$(CUR_DIR)/$(dir))
export BUILDDIR := $(CUR_DIR)/$(BUILD)
2015-12-27 03:10:38 +01:00
export DEPSDIR := $(BUILDDIR)
CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c)))
CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S)))
export OFILES := $(CFILES:.c=.o) \
$(CXXFILES:.cpp=.o) \
$(SFILES:.S=.o)
2016-06-03 01:04:22 +02:00
export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CUR_DIR)/$(dir)) \
-I$(CUR_DIR)/$(BUILD)
2015-12-27 03:10:38 +01:00
.PHONY: $(BUILD) clean
$(BUILD):
@[ -d $@ ] || mkdir -p $@
2016-06-03 01:04:22 +02:00
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CUR_DIR)/Makefile
2015-12-27 03:10:38 +01:00
clean:
@echo "[RM] $(notdir $(OUTPUT))"
@rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).a
else
DEPENDS := $(OFILES:.o=.d)
OFILES := $(filter-out $(ODEPS),$(OFILES))
$(OUTPUT).a: rpl.o $(OFILES)
lib.o: lib.c
@echo "[CC] $(notdir $<)"
2015-12-27 03:58:07 +01:00
@$(CC) $(EXTRA_OPTIONS) $(RPLCFLAGS) -S $(INCLUDES) $< -o lib.S
@$(CC) $(EXTRA_OPTIONS) $(RPLCFLAGS) -c lib.S -o $@
2015-12-27 03:10:38 +01:00
rpl.o: $(ODEPS)
2015-12-27 03:58:07 +01:00
@$(LD) $(EXTRA_OPTIONS) $(LDFLAGS) -r $(ODEPS) -o $@
2015-12-27 03:10:38 +01:00
-include $(DEPENDS)
endif