From f3c530f96cc4936c7e0957488388aec86aebf34e Mon Sep 17 00:00:00 2001 From: James Benton Date: Fri, 3 Jun 2016 00:04:22 +0100 Subject: [PATCH] Fix Windows builds with cygwin. --- Makefile | 7 +++++++ rpl/common/rules.mk | 26 ++++++++++++++++---------- samples/helloworld/Makefile | 21 ++++++++++++++------- tools/Makefile | 23 ++++++++++++++++++----- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index e26ae311..7915402e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ +ifeq ($(OS),Windows_NT) +WUT_ROOT := $(shell cygpath -w ${CURDIR}) +else WUT_ROOT := $(CURDIR) +endif + TARGETS := crt rpl tools +export WUT_ROOT + all: @for dir in $(TARGETS); do \ echo; \ diff --git a/rpl/common/rules.mk b/rpl/common/rules.mk index e2f8fd58..d69c801d 100644 --- a/rpl/common/rules.mk +++ b/rpl/common/rules.mk @@ -1,6 +1,12 @@ .SUFFIXES: -TARGET := $(notdir $(CURDIR)) +ifeq ($(OS),Windows_NT) +CUR_DIR := $(shell cygpath -w ${CURDIR}) +else +CUR_DIR := $(CURDIR) +endif + +TARGET := $(notdir $(CUR_DIR)) BUILD := build SOURCE := ../common . INCLUDE := . @@ -8,9 +14,9 @@ DATA := data LIBS := ifneq ($(BUILD),$(notdir $(CURDIR))) -WUT_ROOT := $(CURDIR)/../.. +WUT_ROOT := $(CUR_DIR)/../.. else -WUT_ROOT := $(CURDIR)/../../.. +WUT_ROOT := $(CUR_DIR)/../../.. endif include $(WUT_ROOT)/rules/ppc.mk @@ -21,10 +27,10 @@ ODEPS := stub.o lib.o ifneq ($(BUILD),$(notdir $(CURDIR))) -export OUTPUT := $(CURDIR)/$(TARGET) -export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) -export BUILDDIR := $(CURDIR)/$(BUILD) +export OUTPUT := $(CUR_DIR)/$(TARGET) +export VPATH := $(foreach dir,$(SOURCE),$(CUR_DIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CUR_DIR)/$(dir)) +export BUILDDIR := $(CUR_DIR)/$(BUILD) export DEPSDIR := $(BUILDDIR) CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) @@ -35,14 +41,14 @@ export OFILES := $(CFILES:.c=.o) \ $(CXXFILES:.cpp=.o) \ $(SFILES:.S=.o) -export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ - -I$(CURDIR)/$(BUILD) +export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CUR_DIR)/$(dir)) \ + -I$(CUR_DIR)/$(BUILD) .PHONY: $(BUILD) clean $(BUILD): @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CUR_DIR)/Makefile clean: @echo "[RM] $(notdir $(OUTPUT))" diff --git a/samples/helloworld/Makefile b/samples/helloworld/Makefile index 5cd587c0..79f027ca 100644 --- a/samples/helloworld/Makefile +++ b/samples/helloworld/Makefile @@ -4,6 +4,13 @@ ifeq ($(strip $(WUT_ROOT)),) $(error "Please ensure WUT_ROOT is in your environment.") endif +ifeq ($(OS),Windows_NT) +CUR_DIR := $(shell cygpath -w ${CURDIR}) +WUT_ROOT := $(shell cygpath -w ${WUT_ROOT}) +else +CUR_DIR := $(CURDIR) +endif + include $(WUT_ROOT)/rules/rpl.mk TARGET := $(notdir $(CURDIR)) @@ -19,10 +26,10 @@ LDFLAGS += -lgx2 ifneq ($(BUILD),$(notdir $(CURDIR))) -export OUTPUT := $(CURDIR)/$(TARGET) -export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) -export BUILDDIR := $(CURDIR) +export OUTPUT := $(CUR_DIR)/$(TARGET) +export VPATH := $(foreach dir,$(SOURCE),$(CUR_DIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CUR_DIR)/$(dir)) +export BUILDDIR := $(CUR_DIR) export DEPSDIR := $(BUILDDIR) CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) @@ -38,14 +45,14 @@ endif export OFILES := $(CFILES:.c=.o) \ $(CXXFILES:.cpp=.o) \ $(SFILES:.S=.o) -export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ - -I$(CURDIR)/$(BUILD) +export INCLUDES := $(foreach dir,$(INCLUDE),-I$(CUR_DIR)/$(dir)) \ + -I$(CUR_DIR)/$(BUILD) .PHONY: $(BUILD) clean $(BUILD): @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CUR_DIR)/Makefile clean: @echo "[RM] $(notdir $(OUTPUT))" diff --git a/tools/Makefile b/tools/Makefile index 1f8c6843..adf84f95 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -5,13 +5,26 @@ TARGETS := elf2rpl readrpl ifeq ($(OS),Windows_NT) all: - @echo "Please build tools with make-tools.bat" - -install: - @echo "Please build tools with make-tools.bat" +ifeq (, $(shell which msbuild 2> /dev/null)) + $(warning "msbuild not found, try building with make-tools.bat from a vcvars prompt.") +else + $(shell msbuild tools/tools.sln /p:Configuration=Release) +endif clean: - @echo "Please build tools with make-tools.bat" +ifeq (, $(shell which msbuild 2> /dev/null)) + $(shell msbuild tools/tools.sln /p:Configuration=Release /target:Clean) +else + $(warning "msbuild not found, try building with make-tools.bat from a vcvars prompt.") +endif + +install: all + @mkdir -p $(WUT_ROOT)/bin + @for dir in $(TARGETS); do \ + echo Installing $$dir; \ + cp bin/$$dir $(WUT_ROOT)/bin; \ + done + else all: @for dir in $(TARGETS); do \