wut/samples/helloworld/Makefile

70 lines
1.5 KiB
Makefile
Raw Normal View History

2015-12-27 03:22:53 +01:00
.SUFFIXES:
ifeq ($(strip $(WUT_ROOT)),)
$(error "Please ensure WUT_ROOT is in your environment.")
endif
2016-06-03 01:04:22 +02:00
ifeq ($(OS),Windows_NT)
2016-06-08 01:59:58 +02:00
ROOT := $(shell cygpath -w ${CURDIR})
2016-06-03 01:04:22 +02:00
WUT_ROOT := $(shell cygpath -w ${WUT_ROOT})
else
2016-06-08 01:59:58 +02:00
ROOT := $(CURDIR)
2016-06-03 01:04:22 +02:00
endif
2015-12-27 03:22:53 +01:00
include $(WUT_ROOT)/rules/rpl.mk
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCE := src
INCLUDE := include
DATA := data
LIBS := -lcoreinit
2016-06-08 01:59:58 +02:00
CFLAGS += -O2 -Wall -std=c11
2015-12-27 03:22:53 +01:00
CXXFLAGS += -O2 -Wall
ifneq ($(BUILD),$(notdir $(CURDIR)))
2016-06-08 01:59:58 +02:00
export OUTPUT := $(ROOT)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCE),$(ROOT)/$(dir)) \
$(foreach dir,$(DATA),$(ROOT)/$(dir))
export BUILDDIR := $(ROOT)
2015-12-27 03:22:53 +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)))
ifeq ($(strip $(CXXFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(CFILES:.c=.o) \
$(CXXFILES:.cpp=.o) \
$(SFILES:.S=.o)
2016-06-08 01:59:58 +02:00
export INCLUDES := $(foreach dir,$(INCLUDE),-I$(ROOT)/$(dir)) \
-I$(ROOT)/$(BUILD)
2015-12-27 03:22:53 +01:00
2016-01-04 14:17:43 +01:00
.PHONY: $(BUILD) clean
2015-12-27 03:22:53 +01:00
$(BUILD):
@[ -d $@ ] || mkdir -p $@
2016-06-08 01:59:58 +02:00
@$(MAKE) --no-print-directory -C $(BUILD) -f $(ROOT)/Makefile
2015-12-27 03:22:53 +01:00
clean:
@echo "[RM] $(notdir $(OUTPUT))"
@rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).rpx $(OUTPUT).a
else
DEPENDS := $(OFILES:.o=.d)
2016-01-04 15:35:58 +01:00
$(OUTPUT).rpx: $(OUTPUT).elf
2015-12-27 03:22:53 +01:00
$(OUTPUT).elf: $(OFILES)
-include $(DEPENDS)
endif