Makefile 20.7 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
# Let's discover something about where we run
ifeq ($(OS),Windows_NT)
OS = Windows
endif
ifeq ($(OS),Windows)
SYSTEM = win
else
SYSTEM = unix
endif

.SECONDARY:

# Useful directories.
INC_DIR = include
EX_DIR = examples
CPP_EX_DIR = examples/cpp
CPP_EX_PATH = $(subst /,$S,$(CPP_EX_DIR))
JAVA_EX_DIR = examples/java
JAVA_EX_PATH = $(subst /,$S,$(JAVA_EX_DIR))
DOTNET_EX_DIR = examples/dotnet
DOTNET_EX_PATH = $(subst /,$S,$(DOTNET_EX_DIR))
OBJ_DIR = objs
CLASS_DIR = classes
LIB_DIR = lib
BIN_DIR = bin

# Unix specific part.
ifeq ($(SYSTEM),unix)
  OS = $(shell uname -s)
# C++
  ifeq ($(OS),Linux)
    CXX = g++
    LDFLAGS = \
-Wl,-rpath,"\$$ORIGIN" \
-Wl,-rpath,"\$$ORIGIN/../lib64" \
-Wl,-rpath,"\$$ORIGIN/../lib" \
-lz -lrt -lpthread
    LBITS = $(shell getconf LONG_BIT)
    ifeq ($(LBITS),64)
      PORT = Linux64
      ARCH = -DARCH_K8
      NETPLATFORM = anycpu
    else
      PORT = Linux32
      ARCH =
      NETPLATFORM = x86
    endif
    MONO = LD_LIBRARY_PATH=$(LIB_DIR):$(LD_LIBRARY_PATH) mono
    L = .so
  endif # ifeq($(OS),Linux)
  ifeq ($(OS),Darwin) # Assume Mac Os X
    CXX = clang++
    LDFLAGS = \
-Wl,-rpath,@loader_path \
-Wl,-rpath,@loader_path/../lib \
-lz -framework CoreFoundation
    PORT = MacOsX64
    ARCH = -DARCH_K8
    NETPLATFORM = x64
    MONO = DYLD_FALLBACK_LIBRARY_PATH=$(LIB_DIR):$(DYLD_LIBRARY_PATH) mono
    L = .dylib
  endif # ifeq($(OS),Darwin)
  CXX_BIN := $(shell command -v $(CXX) 2> /dev/null)
  DEBUG = -O4 -DNDEBUG
  CXXFLAGS = -fPIC -std=c++11 $(DEBUG) \
 -I$(INC_DIR) -I. $(ARCH) -Wno-deprecated \
 -DUSE_CBC -DUSE_CLP -DUSE_BOP -DUSE_GLOP
  LIB_PREFIX = lib
  PRE_LIB = -Llib -Llib64
  CBC_LNK = -lCbcSolver -lCbc -lOsiCbc -lCgl -lClpSolver -lClp -lOsiClp -lOsi -lCoinUtils
  OR_TOOLS_LNK = $(PRE_LIB) -lprotobuf -lglog -lgflags $(CBC_LNK) -lortools
  OBJ_OUT = -o #
  EXE_OUT = -o #
  O = .o
  J = .jar
  D = .dll
  E =
# Java
ifneq ($(JAVA_HOME),)
  JAVAC_BIN := $(shell command -v $(JAVA_HOME)/bin/javac 2> /dev/null)
  JAR_BIN := $(shell command -v $(JAVA_HOME)/bin/jar 2> /dev/null)
  JAVA_BIN := $(shell command -v $(JAVA_HOME)/bin/java 2> /dev/null)
else
  JAVAC_BIN := $(shell command -v javac 2> /dev/null)
  JAR_BIN := $(shell command -v jar 2> /dev/null)
  JAVA_BIN := $(shell command -v java 2> /dev/null)
endif
  JAVAFLAGS = -Djava.library.path=$(LIB_DIR)
  CPSEP = :
# .Net
  DOTNET = dotnet
  DOTNET_BIN := $(shell command -v $(DOTNET) 2> /dev/null)
# Makefile
  S = /
  DEL = rm -f
  DEL_REC = rm -rf
  MKDIR = mkdir
endif # SYSTEM == unix

# Windows specific part.
ifeq ($(SYSTEM),win)
  WHICH = tools\\win\\which.exe
  ifeq ("$(Platform)","X64")
    PLATFORM = Win64
  endif
  ifeq ("$(Platform)","x64")
    PLATFORM = Win64
  endif
  ifeq ("$(PLATFORM)","Win64")
    PORT = VisualStudio$(VISUAL_STUDIO)-64b
    NETPLATFORM = x64
  else
    PORT = VisualStudio$(VISUAL_STUDIO)-32b
    NETPLATFORM = x86
  endif
  CXX = cl
  # We can't use `where` since it's return all matching pathnames
  # so we ship which.exe and use it
  CXX_BIN := $(shell $(WHICH) $(CXX) 2> NUL)
  DEBUG = /O2 -DNDEBUG
  CXXFLAGS = /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo $(DEBUG) \
    /D__WIN32__ /DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS \
    /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= \
    /I$(INC_DIR)\\src\\windows /I$(INC_DIR) /I. \
    -DUSE_CBC -DUSE_CLP -DUSE_BOP -DUSE_GLOP
  LDFLAGS = psapi.lib ws2_32.lib
  LIB_PREFIX =
  OR_TOOLS_LNK = lib\\ortools.lib
  OBJ_OUT = /Fo
  EXE_OUT = /Fe
  O = .obj
  L = .lib
  J = .jar
  D = .dll
  E = .exe
# Java
  JAVAC_BIN := $(shell $(WHICH) javac 2> NUL)
  JAR_BIN := $(shell $(WHICH) jar 2> NUL)
  JAVA_BIN := $(shell $(WHICH) java 2> NUL)
  JAVAFLAGS = -Djava.library.path=$(LIB_DIR)
  CPSEP = ;
# .Net
  DOTNET = dotnet
  DOTNET_BIN := $(shell $(WHICH) $(DOTNET) 2> NUL)
# Makefile
  S = \\
  DEL = del
  DEL_REC = rd /S /Q
  MKDIR = md
endif # SYSTEM == win

OR_TOOLS_LIBS = $(LIB_DIR)/$(LIB_PREFIX)ortools$L

.PHONY: all
all: detect cc java dotnet test

.PHONY: detect
detect: detect_port detect_cc detect_java detect_dotnet
	@echo SOURCE = $(SOURCE)
	@echo SOURCE_PATH = $(SOURCE_PATH)
	@echo SOURCE_NAME = $(SOURCE_NAME)
	@echo SOURCE_SUFFIX = $(SOURCE_SUFFIX)
ifeq ($(SYSTEM),win)
	@echo off & echo(
else
	@echo
endif

.PHONY: test
test: test_cc test_java test_dotnet

.PHONY: clean
clean:
	-$(DEL) $(EXE)
	-$(DEL_REC) $(OBJ_DIR)
	-$(DEL_REC) $(CLASS_DIR)

.PHONY: detect_port
detect_port:
	@echo SHELL = $(SHELL)
	@echo SYSTEM = $(SYSTEM)
	@echo PORT = $(PORT)
	@echo OS = $(OS)
ifeq ($(SYSTEM),win)
	@echo off & echo(
else
	@echo
endif

##############
##  SOURCE  ##
##############
# Check SOURCE argument
SOURCE_SUFFIX = $(suffix $(SOURCE))
# will contain “/any/path/foo.cc” on unix and “\\any\\path\\foo.cc” on windows
SOURCE_PATH = $(subst /,$S,$(SOURCE))
SOURCE_NAME = $(basename $(notdir $(SOURCE)))
ifeq ($(SOURCE),) # Those rules will be used if SOURCE is empty
.PHONY: build run
build run:
	$(error no source file provided, the "$@" target must be used like so: \
 make $@ SOURCE=relative/path/to/filename.extension)
else
ifeq (,$(wildcard $(SOURCE)))
$(error File "$(SOURCE)" does not exist !)
endif
endif

###########
##  C++  ##
###########
EXE = \
$(BIN_DIR)/simple_ls_program$E \
$(BIN_DIR)/rabbits_and_pheasants_cp$E \
$(BIN_DIR)/nurses_cp$E \
$(BIN_DIR)/minimal_jobshop_cp$E \
\
$(BIN_DIR)/constraint_programming_cp$E \
$(BIN_DIR)/costas_array_sat$E \
$(BIN_DIR)/cvrp_disjoint_tw$E \
$(BIN_DIR)/cvrptw$E \
$(BIN_DIR)/cvrptw_with_breaks$E \
$(BIN_DIR)/cvrptw_with_refueling$E \
$(BIN_DIR)/cvrptw_with_resources$E \
$(BIN_DIR)/cvrptw_with_stop_times_and_resources$E \
$(BIN_DIR)/dimacs_assignment$E \
$(BIN_DIR)/dobble_ls$E \
$(BIN_DIR)/flow_api$E \
$(BIN_DIR)/frequency_assignment_problem$E \
$(BIN_DIR)/golomb_sat$E \
$(BIN_DIR)/integer_programming$E \
$(BIN_DIR)/jobshop_sat$E \
$(BIN_DIR)/knapsack$E \
$(BIN_DIR)/linear_assignment_api$E \
$(BIN_DIR)/linear_programming$E \
$(BIN_DIR)/linear_solver_protocol_buffers$E \
$(BIN_DIR)/magic_square_sat$E \
$(BIN_DIR)/max_flow$E \
$(BIN_DIR)/min_cost_flow$E \
$(BIN_DIR)/mps_driver$E \
$(BIN_DIR)/network_routing_sat$E \
$(BIN_DIR)/nqueens$E \
$(BIN_DIR)/random_tsp$E \
$(BIN_DIR)/pdptw$E \
$(BIN_DIR)/shift_minimization_sat$E \
$(BIN_DIR)/solve$E \
$(BIN_DIR)/sports_scheduling_sat$E \
$(BIN_DIR)/strawberry_fields_with_column_generation$E \
$(BIN_DIR)/tsp$E \
$(BIN_DIR)/vrp$E \
$(BIN_DIR)/weighted_tardiness_sat$E

.PHONY: cc test_cc
ifndef CXX_BIN
cc test_cc:
	@echo the $(CXX) command was not found in your PATH
	exit 127
else
cc: $(EXE)
test_cc: detect_cc
	$(MAKE) run SOURCE=examples/cpp/simple_knapsack_program.cc
	$(MAKE) run SOURCE=examples/cpp/simple_max_flow_program.cc
	$(MAKE) run SOURCE=examples/cpp/simple_min_cost_flow_program.cc
	$(MAKE) run SOURCE=examples/cpp/simple_lp_program.cc
	$(MAKE) run SOURCE=examples/cpp/simple_mip_program.cc
	$(MAKE) run SOURCE=examples/cpp/simple_sat_program.cc
	$(MAKE) run SOURCE=examples/cpp/simple_ls_program.cc
	$(MAKE) run SOURCE=examples/cpp/tsp.cc
	$(MAKE) run SOURCE=examples/cpp/vrp.cc
	$(MAKE) run SOURCE=examples/cpp/nurses_cp.cc
	$(MAKE) run SOURCE=examples/cpp/minimal_jobshop_cp.cc

##################
##  C++ SOURCE  ##
##################
ifeq ($(SOURCE_SUFFIX),.cc) # Those rules will be used if SOURCE contain a .cc file
$(OBJ_DIR)/$(SOURCE_NAME).$O: $(SOURCE) | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) \
 -c $(SOURCE_PATH) \
 $(OBJ_OUT)$(OBJ_DIR)$S$(SOURCE_NAME).$O

$(BIN_DIR)/$(SOURCE_NAME)$E: $(OBJ_DIR)/$(SOURCE_NAME).$O | $(BIN_DIR)
	$(CXX) $(CXXFLAGS) \
 $(OBJ_DIR)$S$(SOURCE_NAME).$O \
 $(OR_TOOLS_LNK) $(LDFLAGS) \
 $(EXE_OUT)$(BIN_DIR)$S$(SOURCE_NAME)$E

.PHONY: build # Build a C++ program.
build: $(BIN_DIR)/$(SOURCE_NAME)$E

.PHONY: run # Run a C++ program.
run: build
	$(BIN_DIR)$S$(SOURCE_NAME)$E $(ARGS)
endif # ifeq ($(SOURCE_SUFFIX),.cc)

endif # ifndef CXX_BIN

$(OBJ_DIR):
	-$(MKDIR) $(OBJ_DIR)

$(OBJ_DIR)/%$O: $(CPP_EX_DIR)/%.cc | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) -c $(CPP_EX_PATH)$S$*.cc $(OBJ_OUT)$(OBJ_DIR)$S$*$O

$(BIN_DIR)/%$E: $(OBJ_DIR)/%$O
	$(CXX) $(CXXFLAGS) $(OBJ_DIR)$S$*$O $(OR_TOOLS_LNK) $(LDFLAGS) $(EXE_OUT)$(BIN_DIR)$S$*$E

.PHONY: detect_cc
detect_cc:
	@echo CXX = $(CXX)
	@echo CXX_BIN = $(CXX_BIN)
	@echo CXXFLAGS = $(CXXFLAGS)
	@echo LDFLAGS = $(LDFLAGS)
	@echo OR_TOOLS_LNK = $(OR_TOOLS_LNK)
ifeq ($(SYSTEM),win)
	@echo off & echo(
else
	@echo
endif

############
##  JAVA  ##
############
JAR = \
$(LIB_DIR)/LinearProgramming$J \
$(LIB_DIR)/IntegerProgramming$J \
$(LIB_DIR)/RabbitsPheasants$J \
$(LIB_DIR)/Tsp$J \
$(LIB_DIR)/Vrp$J \
$(LIB_DIR)/Knapsack$J \
\
$(LIB_DIR)/AllDifferentExcept0$J \
$(LIB_DIR)/AllInterval$J \
$(LIB_DIR)/CapacitatedVehicleRoutingProblemWithTimeWindows$J \
$(LIB_DIR)/Circuit$J \
$(LIB_DIR)/CoinsGrid$J \
$(LIB_DIR)/CoinsGridMIP$J \
$(LIB_DIR)/ColoringMIP$J \
$(LIB_DIR)/CoveringOpl$J \
$(LIB_DIR)/Crossword$J \
$(LIB_DIR)/DeBruijn$J \
$(LIB_DIR)/Diet$J \
$(LIB_DIR)/DietMIP$J \
$(LIB_DIR)/DivisibleBy9Through1$J \
$(LIB_DIR)/FlowExample$J \
$(LIB_DIR)/GolombRuler$J \
$(LIB_DIR)/Issue173$J \
$(LIB_DIR)/KnapsackMIP$J \
$(LIB_DIR)/LeastDiff$J \
$(LIB_DIR)/LinearAssignmentAPI$J \
$(LIB_DIR)/MagicSquare$J \
$(LIB_DIR)/Map2$J \
$(LIB_DIR)/Map$J \
$(LIB_DIR)/Minesweeper$J \
$(LIB_DIR)/MultiThreadTest$J \
$(LIB_DIR)/NQueens2$J \
$(LIB_DIR)/NQueens$J \
$(LIB_DIR)/Partition$J \
$(LIB_DIR)/QuasigroupCompletion$J \
$(LIB_DIR)/SendMoreMoney2$J \
$(LIB_DIR)/SendMoreMoney$J \
$(LIB_DIR)/SendMostMoney$J \
$(LIB_DIR)/Seseman$J \
$(LIB_DIR)/SetCovering2$J \
$(LIB_DIR)/SetCovering3$J \
$(LIB_DIR)/SetCovering4$J \
$(LIB_DIR)/SetCoveringDeployment$J \
$(LIB_DIR)/SetCovering$J \
$(LIB_DIR)/SimpleRoutingTest$J \
$(LIB_DIR)/StableMarriage$J \
$(LIB_DIR)/StiglerMIP$J \
$(LIB_DIR)/Strimko2$J \
$(LIB_DIR)/Sudoku$J \
$(LIB_DIR)/SurvoPuzzle$J \
$(LIB_DIR)/ToNum$J \
$(LIB_DIR)/WhoKilledAgatha$J \
$(LIB_DIR)/Xkcd$J \
$(LIB_DIR)/YoungTableaux$J

HAS_JAVA = true
ifndef JAVAC_BIN
HAS_JAVA =
endif
ifndef JAR_BIN
HAS_JAVA =
endif
ifndef JAVA_BIN
HAS_JAVA =
endif

.PHONY: java test_java
ifndef HAS_JAVA
java test_java:
	@echo the command 'java', 'javac' or 'jar' was not found in your PATH
	exit 127
else
java: $(JAR)
test_java: detect_java
	$(MAKE) run SOURCE=examples/java/SimpleLpProgram.java
	$(MAKE) run SOURCE=examples/java/SimpleMipProgram.java
	$(MAKE) run SOURCE=examples/java/SimpleSatProgram.java
	$(MAKE) run SOURCE=examples/java/Tsp.java
	$(MAKE) run SOURCE=examples/java/Vrp.java
	$(MAKE) run SOURCE=examples/java/Knapsack.java

###################
##  Java SOURCE  ##
###################
ifeq ($(SOURCE_SUFFIX),.java) # Those rules will be used if SOURCE contain a .java file
$(CLASS_DIR)/$(SOURCE_NAME): $(SOURCE) | $(CLASS_DIR)
	-$(MKDIR) $(CLASS_DIR)$S$(SOURCE_NAME)
	"$(JAVAC_BIN)" -encoding UTF-8 -d $(CLASS_DIR)$S$(SOURCE_NAME) \
 -cp $(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
 $(SOURCE_PATH)

$(LIB_DIR)/$(SOURCE_NAME)$J: $(CLASS_DIR)/$(SOURCE_NAME) | $(LIB_DIR)
	-$(DEL) $(LIB_DIR)$S$(SOURCE_NAME)$J
	"$(JAR_BIN)" cvf $(LIB_DIR)$S$(SOURCE_NAME)$J -C $(CLASS_DIR)$S$(SOURCE_NAME) .

.PHONY: build # Build a Java program.
build: $(LIB_DIR)/$(SOURCE_NAME)$J

.PHONY: run # Run a Java program.
run: build
	"$(JAVA_BIN)" -Xss2048k $(JAVAFLAGS) \
 -cp $(LIB_DIR)$S$(SOURCE_NAME)$J$(CPSEP)$(LIB_DIR)$Scom.google.ortools.jar$(CPSEP)$(LIB_DIR)$Sprotobuf.jar \
 com.google.ortools.examples.$(SOURCE_NAME) $(ARGS)
endif # ifeq ($(SOURCE_SUFFIX),.java)

endif # ifndef HAS_JAVA

$(CLASS_DIR):
	-$(MKDIR) $(CLASS_DIR)

$(CLASS_DIR)/%: $(JAVA_EX_DIR)/%.java | $(CLASS_DIR)
	-$(MKDIR) $(CLASS_DIR)$S$*
	"$(JAVAC_BIN)" -d $(CLASS_DIR)$S$* \
 -cp $(LIB_DIR)$Scom.google.ortools$J$(CPSEP)$(LIB_DIR)$Sprotobuf$J \
 $(JAVA_EX_PATH)$S$*.java

$(LIB_DIR)/%$J: $(CLASS_DIR)/% | $(LIB_DIR)
	"$(JAR_BIN)" cvf $(LIB_DIR)$S$*$J -C $(CLASS_DIR)$S$* .

.PHONY: detect_java
detect_java:
	@echo JAVA_HOME = $(JAVA_HOME)
	@echo JAVAC_BIN = $(JAVAC_BIN)
	@echo CLASS_DIR = $(CLASS_DIR)
	@echo JAR_BIN = $(JAR_BIN)
	@echo JAVA_BIN = $(JAVA_BIN)
	@echo JAVAFLAGS = $(JAVAFLAGS)
ifeq ($(SYSTEM),win)
	@echo off & echo(
else
	@echo
endif

##############
##  DOTNET  ##
##############
.PHONY: dotnet test_dotnet
ifndef DOTNET_BIN
dotnet test_dotnet:
	@echo the command 'dotnet' was not found in your PATH
	exit 127
else
dotnet:
	$(MAKE) run SOURCE=examples/dotnet/3_jugs_regular.cs
# Linear Solver
	$(MAKE) run SOURCE=examples/dotnet/SimpleLpProgram.cs
	$(MAKE) run SOURCE=examples/dotnet/SimpleMipProgram.cs
# Constraint Solver
	$(MAKE) run SOURCE=examples/dotnet/Tsp.cs
	$(MAKE) run SOURCE=examples/dotnet/Vrp.cs
# Sat
	$(MAKE) run SOURCE=examples/dotnet/NursesSat.cs
	$(MAKE) run SOURCE=examples/dotnet/JobshopSat.cs
	$(MAKE) run SOURCE=examples/dotnet/JobshopFt06Sat.cs
	$(MAKE) run SOURCE=examples/dotnet/GateSchedulingSat.cs
	$(MAKE) run SOURCE=examples/dotnet/TaskSchedulingSat.cs
# Misc
	$(MAKE) run SOURCE=examples/dotnet/cslinearprogramming.cs
	$(MAKE) run SOURCE=examples/dotnet/csintegerprogramming.cs
	$(MAKE) run SOURCE=examples/dotnet/assignment.cs
	$(MAKE) run SOURCE=examples/dotnet/alldifferent_except_0.cs
	$(MAKE) run SOURCE=examples/dotnet/all_interval.cs
	$(MAKE) run SOURCE=examples/dotnet/a_puzzle.cs
	$(MAKE) run SOURCE=examples/dotnet/a_round_of_golf.cs
	$(MAKE) run SOURCE=examples/dotnet/broken_weights.cs
	$(MAKE) run SOURCE=examples/dotnet/bus_schedule.cs
	$(MAKE) run SOURCE=examples/dotnet/circuit2.cs
	$(MAKE) run SOURCE=examples/dotnet/circuit.cs
	$(MAKE) run SOURCE=examples/dotnet/coins3.cs
	$(MAKE) run SOURCE=examples/dotnet/coins_grid.cs ARGS="5 2"
	$(MAKE) run SOURCE=examples/dotnet/combinatorial_auction2.cs
	$(MAKE) run SOURCE=examples/dotnet/contiguity_regular.cs
	$(MAKE) run SOURCE=examples/dotnet/contiguity_transition.cs
	$(MAKE) run SOURCE=examples/dotnet/costas_array.cs
	$(MAKE) run SOURCE=examples/dotnet/covering_opl.cs
	$(MAKE) run SOURCE=examples/dotnet/crew.cs
	$(MAKE) run SOURCE=examples/dotnet/crossword.cs
	$(MAKE) run SOURCE=examples/dotnet/crypta.cs
	$(MAKE) run SOURCE=examples/dotnet/crypto.cs
	$(MAKE) run SOURCE=examples/dotnet/cscvrptw.cs
	$(MAKE) run SOURCE=examples/dotnet/csflow.cs
	$(MAKE) run SOURCE=examples/dotnet/csknapsack.cs
	$(MAKE) run SOURCE=examples/dotnet/csls_api.cs
	$(MAKE) run SOURCE=examples/dotnet/csrabbitspheasants.cs
	$(MAKE) run SOURCE=examples/dotnet/cstsp.cs
	$(MAKE) run SOURCE=examples/dotnet/curious_set_of_integers.cs
	$(MAKE) run SOURCE=examples/dotnet/debruijn.cs
	$(MAKE) run SOURCE=examples/dotnet/csdiet.cs
	$(MAKE) run SOURCE=examples/dotnet/discrete_tomography.cs
	$(MAKE) run SOURCE=examples/dotnet/divisible_by_9_through_1.cs
	$(MAKE) run SOURCE=examples/dotnet/dudeney.cs
	$(MAKE) run SOURCE=examples/dotnet/einav_puzzle2.cs
	$(MAKE) run SOURCE=examples/dotnet/eq10.cs
	$(MAKE) run SOURCE=examples/dotnet/eq20.cs
	$(MAKE) run SOURCE=examples/dotnet/fill_a_pix.cs
	$(MAKE) run SOURCE=examples/dotnet/furniture_moving.cs
	$(MAKE) run SOURCE=examples/dotnet/furniture_moving_intervals.cs
	$(MAKE) run SOURCE=examples/dotnet/futoshiki.cs
	$(MAKE) run SOURCE=examples/dotnet/golomb_ruler.cs
	$(MAKE) run SOURCE=examples/dotnet/grocery.cs
	$(MAKE) run SOURCE=examples/dotnet/hidato_table.cs
	$(MAKE) run SOURCE=examples/dotnet/just_forgotten.cs
	$(MAKE) run SOURCE=examples/dotnet/kakuro.cs
	$(MAKE) run SOURCE=examples/dotnet/kenken2.cs
	$(MAKE) run SOURCE=examples/dotnet/killer_sudoku.cs
	$(MAKE) run SOURCE=examples/dotnet/labeled_dice.cs
	$(MAKE) run SOURCE=examples/dotnet/langford.cs
	$(MAKE) run SOURCE=examples/dotnet/least_diff.cs
	$(MAKE) run SOURCE=examples/dotnet/lectures.cs
	$(MAKE) run SOURCE=examples/dotnet/magic_sequence.cs
	$(MAKE) run SOURCE=examples/dotnet/magic_square_and_cards.cs
	$(MAKE) run SOURCE=examples/dotnet/magic_square.cs
	$(MAKE) run SOURCE=examples/dotnet/map2.cs
	$(MAKE) run SOURCE=examples/dotnet/map.cs
	$(MAKE) run SOURCE=examples/dotnet/marathon2.cs
	$(MAKE) run SOURCE=examples/dotnet/max_flow_taha.cs
	$(MAKE) run SOURCE=examples/dotnet/max_flow_winston1.cs
	$(MAKE) run SOURCE=examples/dotnet/minesweeper.cs
	$(MAKE) run SOURCE=examples/dotnet/mr_smith.cs
#	$(MAKE) run SOURCE=examples/dotnet/nontransitive_dice.cs # too long
	$(MAKE) run SOURCE=examples/dotnet/nqueens.cs
	$(MAKE) run SOURCE=examples/dotnet/nurse_rostering_regular.cs
	$(MAKE) run SOURCE=examples/dotnet/nurse_rostering_transition.cs
	$(MAKE) run SOURCE=examples/dotnet/olympic.cs
	$(MAKE) run SOURCE=examples/dotnet/organize_day.cs
	$(MAKE) run SOURCE=examples/dotnet/organize_day_intervals.cs
	$(MAKE) run SOURCE=examples/dotnet/pandigital_numbers.cs
#	$(MAKE) run SOURCE=examples/dotnet/partition.cs # too long
	$(MAKE) run SOURCE=examples/dotnet/perfect_square_sequence.cs
	$(MAKE) run SOURCE=examples/dotnet/photo_problem.cs
	$(MAKE) run SOURCE=examples/dotnet/place_number_puzzle.cs
	$(MAKE) run SOURCE=examples/dotnet/p_median.cs
	$(MAKE) run SOURCE=examples/dotnet/post_office_problem2.cs
	$(MAKE) run SOURCE=examples/dotnet/quasigroup_completion.cs
	$(MAKE) run SOURCE=examples/dotnet/regex.cs
	$(MAKE) run SOURCE=examples/dotnet/rogo2.cs
	$(MAKE) run SOURCE=examples/dotnet/scheduling_speakers.cs
	$(MAKE) run SOURCE=examples/dotnet/secret_santa2.cs
#	$(MAKE) run SOURCE=examples/dotnet/secret_santa.cs # too long
	$(MAKE) run SOURCE=examples/dotnet/send_more_money2.cs
	$(MAKE) run SOURCE=examples/dotnet/send_more_money.cs
	$(MAKE) run SOURCE=examples/dotnet/send_most_money.cs
	$(MAKE) run SOURCE=examples/dotnet/seseman.cs
	$(MAKE) run SOURCE=examples/dotnet/set_covering2.cs
	$(MAKE) run SOURCE=examples/dotnet/set_covering3.cs
	$(MAKE) run SOURCE=examples/dotnet/set_covering4.cs
	$(MAKE) run SOURCE=examples/dotnet/set_covering.cs
	$(MAKE) run SOURCE=examples/dotnet/set_covering_deployment.cs
	$(MAKE) run SOURCE=examples/dotnet/set_covering_skiena.cs
	$(MAKE) run SOURCE=examples/dotnet/set_partition.cs
	$(MAKE) run SOURCE=examples/dotnet/sicherman_dice.cs
	$(MAKE) run SOURCE=examples/dotnet/ski_assignment.cs
	$(MAKE) run SOURCE=examples/dotnet/stable_marriage.cs
	$(MAKE) run SOURCE=examples/dotnet/strimko2.cs
	$(MAKE) run SOURCE=examples/dotnet/subset_sum.cs
	$(MAKE) run SOURCE=examples/dotnet/sudoku.cs
	$(MAKE) run SOURCE=examples/dotnet/survo_puzzle.cs
	$(MAKE) run SOURCE=examples/dotnet/to_num.cs
	$(MAKE) run SOURCE=examples/dotnet/traffic_lights.cs
	$(MAKE) run SOURCE=examples/dotnet/volsay.cs
	$(MAKE) run SOURCE=examples/dotnet/volsay2.cs
	$(MAKE) run SOURCE=examples/dotnet/volsay3.cs
	$(MAKE) run SOURCE=examples/dotnet/wedding_optimal_chart.cs
	$(MAKE) run SOURCE=examples/dotnet/who_killed_agatha.cs
	$(MAKE) run SOURCE=examples/dotnet/xkcd.cs
	$(MAKE) run SOURCE=examples/dotnet/young_tableaux.cs
	$(MAKE) run SOURCE=examples/dotnet/zebra.cs
	$(MAKE) run SOURCE=examples/dotnet/fsintegerprogramming.fs
	$(MAKE) run SOURCE=examples/dotnet/fslinearprogramming.fs
	$(MAKE) run SOURCE=examples/dotnet/fsdiet.fs
	$(MAKE) run SOURCE=examples/dotnet/fsequality.fs
	$(MAKE) run SOURCE=examples/dotnet/fsequality-inequality.fs
	$(MAKE) run SOURCE=examples/dotnet/fsinteger-linear-program.fs
	$(MAKE) run SOURCE=examples/dotnet/fsknapsack.fs
	$(MAKE) run SOURCE=examples/dotnet/fsnetwork-max-flow.fs
	$(MAKE) run SOURCE=examples/dotnet/fsnetwork-max-flow-lpSolve.fs
	$(MAKE) run SOURCE=examples/dotnet/fsnetwork-min-cost-flow.fs
	$(MAKE) run SOURCE=examples/dotnet/fsProgram.fs
	$(MAKE) run SOURCE=examples/dotnet/fsrabbit-pheasant.fs
	$(MAKE) run SOURCE=examples/dotnet/fsvolsay3.fs
	$(MAKE) run SOURCE=examples/dotnet/fsvolsay3-lpSolve.fs
	$(MAKE) run SOURCE=examples/dotnet/fsvolsay.fs
#	$(MAKE) run SOURCE=examples/dotnet/word_square.cs # depends on /usr/share/dict/words

test_dotnet: detect_dotnet
	$(MAKE) run SOURCE=examples/dotnet/SimpleLpProgram.cs
	$(MAKE) run SOURCE=examples/dotnet/SimpleMipProgram.cs
	$(MAKE) run SOURCE=examples/dotnet/Tsp.cs
	$(MAKE) run SOURCE=examples/dotnet/Vrp.cs
	$(MAKE) run SOURCE=examples/dotnet/JobshopSat.cs
	$(MAKE) run SOURCE=examples/dotnet/NursesSat.cs

###################
##  .NET SOURCE  ##
###################
# .Net C#
ifeq ($(SOURCE_SUFFIX),.cs) # Those rules will be used if SOURCE contain a .cs file
ifeq (,$(wildcard $(SOURCE)proj))
$(error File "$(SOURCE)proj" does not exist !)
endif

.PHONY: build # Build a .Net C# program.
build: $(SOURCE) $(SOURCE)proj
	"$(DOTNET_BIN)" build $(SOURCE_PATH)proj

.PHONY: run # Run a .Net C# program.
run: build
	"$(DOTNET_BIN)" run --no-build --project $(SOURCE_PATH)proj -- $(ARGS)
endif # ifeq ($(SOURCE_SUFFIX),.cs)

# .Net F#
ifeq ($(SOURCE_SUFFIX),.fs) # Those rules will be used if SOURCE contain a .cs file
ifeq (,$(wildcard $(SOURCE)proj))
$(error File "$(SOURCE)proj" does not exist !)
endif

.PHONY: build # Build a .Net F# program.
build: $(SOURCE) $(SOURCE)proj
	"$(DOTNET_BIN)" build $(SOURCE_PATH)proj

.PHONY: run # Run a .Net F# program.
run: build
	"$(DOTNET_BIN)" run --no-build --project $(SOURCE_PATH)proj -- $(ARGS)
endif # ifeq ($(SOURCE_SUFFIX),.fs)

endif # ifndef DOTNET_BIN

.PHONY: detect_dotnet
detect_dotnet:
	@echo DOTNET_BIN = $(DOTNET_BIN)
ifeq ($(SYSTEM),win)
	@echo off & echo(
else
	@echo
endif

############
##  MISC  ##
############
# Include user makefile
-include Makefile.user

print-%	: ; @echo $* = $($*)