#Configuration for mymake
#Lines beginning with # are comments.
#Any unknown left-hand sides can be used as variables.

[]

#Extensions for source-files, ie. files that should be compiled.
ext+=cpp
ext+=cc
ext+=cxx
ext+=c++
ext+=c

#Build directory
buildDir=build/

#Executable directory
execDir=bin/

#Ignore files.
ignore=*.template.*

#Include path
include+=./

#Run output by default
execute=yes

#Show compilation time?
#showTime=no

#Precompiled header.
#pch=std.h

#Append the file type to the name of the intermediate file? This is useful if
#a target contains both eg. foo.cpp and foo.cc that should both be compiled.
#appendExt=no

#Pre-build steps.
#preBuild=

#Files generated by the pre-build steps. It is assumed these files will not introduce
#any additional dependencies to the target.
#preBuildCreates=

#Post-build steps.
#postBuild=

#Defines.
#define+=DEBUG

#Compile this target in parallell?
#parallel=yes

#Use max this # of threads to compile this target.
#maxThreads=4

#Define command line. Should not need to be changed.
defines=<defineCl*define>

#Static library
[lib]

#Compile all files into a lib.
input=*

#Do not run.
execute=no

#Link the output of this target into any dependent targets.
linkOutput=yes

#Forward dependencies.
forwardDeps=yes

#Shared library
[sharedlib]

#Compile all files.
input=*

#Do not run.
execute=no


[release]
#Output somewhere else.
buildDir=release/build/
execDir=release/bin/

[unix]

execExt=
intermediateExt=o

includeCl=-iquote
libraryCl=-l
localLibraryCl=
defineCl=-D 

flags=<useStandard*standard> -pipe
warnings=-Wall -Wextra

#standard=c++11
useStandard=-std=

#Send absolute paths to the compiler (better with Emacs).
absolutePath=yes

#Compile the precompiled header.
pchFile=<pch>.gch
usePch=-include <noExt|pchFile>
pchCompile=g++ <defines> <flags> <warnings> <file> -c <includes> -o <output>
pchCompileCombined=no

#Compile a single file.
compile=*:g++ <defines> <flags> <warnings> <usePch*if|pch> <file> -c <includes> -o <output>

#Support C as well. Note that we don't support PCH for C compilation.
cflags=-pipe
compile+=*.c:gcc <defines> <cflags> <warnings> <file> -c <includes> -o <output>

#Link all files
link=g++ <files> <linkFlags> <libs> -o <output>

[unix,!release]
flags+=-g

[unix,release]
flags+=-O3

[unix,reproducible]
absolutePath=no
flags+=-ffile-prefix-map=<projectRoot>=.
# Needed for asm files, at least on GCC.
flags+=-fdebug-prefix-map=<projectRoot>=.

[unix,lib]

execExt=a

#Link, remove the library first so that removed files do not get duplicated.
link=rm -f -- <output>; ar rcs <output> <files>

[unix,sharedlib]
execExt=so
linkFlags+=-shared

[unix,sharedlib,!pic]
# We need PIC on unix.
flags+=-fPIC

[pic,unix]
# We need PIC on unix.
flags+=-fPIC

#Sample configuration for compiling Qt5 applications on Unix.
[unix,qt]
qtLibCl=-I/usr/include/qt5/Qt
qtLibFlag=-lQt5
flags+=-fPIC -I/usr/include/qt5/ <qtLibCl*qtLib>
linkFlags+=<qtLibFlag*qtLib>

#Qt libraries.
qtLib+=Core
qtLib+=Gui
qtLib+=Widgets

ext+=h
appendExt=yes
compile+=*.h:touch <output>.cpp && moc <file> -o <output>.cpp && g++ <defines> <flags> <warnings> <output>.cpp -c -o <output>

[windows]

execExt=exe
intermediateExt=obj

includeCl=/I
libraryCl=
localLibraryCl=
defineCl=/D

#standard=c++17
useStandard=/std:

#/EHsc - exception handling, /FC - full paths in diagnostics
flags=/nologo /EHsc /FC
warnings=/W3
linkFlags=/MANIFEST /NXCOMPAT
manifestId=1

pchFile=<noExt|pch>.pch
usePch=/Yu
namePch=/Fp<pchFile>

pchCompile=1!cl <defines> <file> <includes> <flags> <warnings> /Yc<title|pch> <namePch*if|pch> /c /Fo<output>
pchCompileCombined=yes

compile=*:1!cl <defines> <file> <includes> <flags> <warnings> <usePch*title|pch> <namePch*if|pch> /c /Fo<output>
link=link <linkFlags> <libs> <files> /nologo /OUT:<output>
link+=mt -nologo -manifest <output>.manifest -outputresource:<output>;#<manifestId>

cflags=/nologo /EHsc /FC
compile+=*.c:1!cl <defines> <file> <includes> <cflags> <warnings> /c /Fo<output>

[windows,64]
linkFlags+=/MACHINE:X64

[windows,!release]
flags+=/MDd /DEBUG /Zi /Fd<path|buildDir>
linkFlags+=/DEBUG /INCREMENTAL:NO /PDB:<path|execDir><titleNoExt|output>.pdb

[windows,release]
flags+=/MD /O2

[windows,release,pdb]
flags+=/DEBUG /Zi
linkFlags+=/DEBUG /INCREMENTAL:NO /PDB:<path|execDir><titleNoExt|output>.pdb

[windows,lib]
execExt=lib
link=lib <files> /nologo /OUT:<output>

[windows,sharedlib]
execExt=dll
linkFlags+=/DLL
manifestId=2

[windows,!winMain,!sharedlib,!lib]
#Windows applications have a special entry point...
linkFlags+=/SUBSYSTEM:CONSOLE
define+=_CONSOLE
