Skip to content

Commit

Permalink
[feature] opa-create: Makefile improved for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Jun 8, 2012
1 parent 3a1ec75 commit 7eb2647
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
9 changes: 7 additions & 2 deletions tools/opa-create/template/mvc/Makefile
@@ -1,7 +1,12 @@
########################################
# USER VARIABLES

EXE = application_name.exe
ifdef SystemRoot
RUN_CMD = $(EXE)
else
RUN_CMD = ./$(EXE)
endif

PACKNAME =
SRC =
PCKDIR = ./plugins/
Expand All @@ -21,6 +26,6 @@ RUN_OPT = --db-local db/
default: exe

run: exe
./$(EXE) $(RUN_OPT) || true
$(RUN_CMD) $(RUN_OPT) || true

include Makefile.common
27 changes: 15 additions & 12 deletions tools/opa-create/template/mvc/Makefile.common
Expand Up @@ -3,7 +3,7 @@
OPACOMPILER ?= opa
OPA = $(OPACOMPILER) $(FLAG) $(OPAOPT)
PWD ?= $(shell pwd)
BUILDDIR ?= $(PWD)/_build
BUILDDIR ?= _build
export BUILDDIR
OPAGENAPI ?= $(OPACOMPILER) --api-only
DEPENDS = $(SRC) $(PCK:%=$(BUILDDIR)/%) $(PLUGIN:%=$(BUILDDIR)/%)
Expand All @@ -14,23 +14,30 @@ else
CONFIG =
endif

_ = $(shell mkdir -p $(BUILDDIR))
ifdef SystemRoot
RM = rmdir /s /q
RMFILE = del /s /q
else
RM = rm -rf
RMFILE = rm
endif

# Hack to bypass the lack of "make -p" on Windows:
_ = $(shell mkdir _build 2>/dev/null)

########################################
# MAIN RULE
exe : $(EXE)
pack : $(PACKNAME)
doc : $(PACKDOC) doc.sub

########################################
# MAIN PACKAGE BUILDING
$(PACKNAME) : $(BUILDDIR)/$(PACKNAME)

$(BUILDDIR)/$(PACKNAME) : $(DEPENDS)
@echo "### Building package $(PACKNAME)"
mkdir -p $(BUILDDIR)
$(OPA) --autocompile $(SRC) $(PLUGIN:%=$(BUILDDIR)/%) --build-dir $(BUILDDIR) -I $(BUILDDIR) $(OPAOPT)
@rm -rf $(BUILDDIR)/$(PACKNAME)
$(RM) $(BUILDDIR)/$(PACKNAME)
@mv $(PACKNAME) $(BUILDDIR)/

########################################
Expand All @@ -45,7 +52,6 @@ $(BUILDDIR)/%.opp :
# EXECUTABLE BUILDING
$(EXE) : pack $(SRC) $(MAINSRC) $(DEPENDS) $(OTHER_DEPENDS)
@echo "### Building executable $(EXE) "
mkdir -p $(BUILDDIR)
$(OPA) $(COMPILOPT) $(MAINSRC) $(CONFIG) $(PLUGIN:%=$(BUILDDIR)/%) -o $@ --build-dir $(BUILDDIR)/$(EXE)

$(EXE:%.exe=%.run) : $(EXE)
Expand All @@ -60,10 +66,7 @@ pack.depends :
# CLEANING
clean ::
@$(PCK:%.opx=make -C $(PCKDIR)/% clean &&) $(PLUGIN:%.opp=make -C $(PLUGINDIR)/% clean &&) echo "### Cleaning $(BUILDDIR)";
@rm -rf $(BUILDDIR)/* _tracks/*;
@if [ -n "$(EXE)" ]; then rm -rf $(EXE); fi
@if [ -n "$(PACKDOC)" ]; then rm -rf $(PACKDOC); fi

deep-clean :: clean
@rm -rf opa-debug
$(RM) $(BUILDDIR) 2>/dev/null
$(RMFILE) $(EXE) 2>/dev/null


0 comments on commit 7eb2647

Please sign in to comment.