Add makefile for csources
This should speed up compilation of csources significantly, as it can be used with "make -j $NUMPROCS" Only tested on Linux so far
This commit is contained in:
parent
1b7d7ae1cb
commit
02432f1052
4 changed files with 176 additions and 3 deletions
2
koch.nim
2
koch.nim
|
|
@ -320,7 +320,7 @@ proc winRelease() =
|
||||||
|
|
||||||
run7z("win32", "bin/nim.exe", "bin/c2nim.exe", "bin/nimgrep.exe",
|
run7z("win32", "bin/nim.exe", "bin/c2nim.exe", "bin/nimgrep.exe",
|
||||||
"bin/nimfix.exe",
|
"bin/nimfix.exe",
|
||||||
"bin/babel.exe", "bin/*.dll",
|
"bin/nimble.exe", "bin/*.dll",
|
||||||
"config", "dist/*.dll", "examples", "lib",
|
"config", "dist/*.dll", "examples", "lib",
|
||||||
"readme.txt", "contributors.txt", "copying.txt")
|
"readme.txt", "contributors.txt", "copying.txt")
|
||||||
# second step: XXX build 64 bit version
|
# second step: XXX build 64 bit version
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#! stdtmpl(subsChar='?') | standard
|
#! stdtmpl(subsChar='?') | standard
|
||||||
#proc generateBuildShellScript(c: ConfigData): string =
|
#proc generateBuildShellScript(c: ConfigData): string =
|
||||||
# result = "#! /bin/sh\n# Generated from niminst\n" &
|
# result = "#! /bin/sh\n# Generated from niminst\n" &
|
||||||
# "# Template is in tools/buildsh.tmpl\n" &
|
# "# Template is in tools/niminst/buildsh.tmpl\n" &
|
||||||
# "# To regenerate run ``niminst csource`` or ``koch csource``\n"
|
# "# To regenerate run ``niminst csource`` or ``koch csource``\n"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
@ -111,7 +111,7 @@ case $ucpu in
|
||||||
LINK_FLAGS="$LINK_FLAGS -m64"
|
LINK_FLAGS="$LINK_FLAGS -m64"
|
||||||
fi
|
fi
|
||||||
mycpu="powerpc64" ;;
|
mycpu="powerpc64" ;;
|
||||||
*power*|*Power*|*ppc* )
|
*power*|*ppc* )
|
||||||
mycpu="powerpc" ;;
|
mycpu="powerpc" ;;
|
||||||
*mips* )
|
*mips* )
|
||||||
mycpu="mips" ;;
|
mycpu="mips" ;;
|
||||||
|
|
|
||||||
168
tools/niminst/makefile.tmpl
Normal file
168
tools/niminst/makefile.tmpl
Normal file
|
|
@ -0,0 +1,168 @@
|
||||||
|
#! stdtmpl(subsChar='?') | standard
|
||||||
|
#proc generateMakefile(c: ConfigData): string =
|
||||||
|
# result = "# Generated from niminst\n" &
|
||||||
|
# "# Template is in tools/niminst/makefile.tmpl\n" &
|
||||||
|
# "# To regenerate run ``niminst csource`` or ``koch csource``\n"
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
LINKER = gcc
|
||||||
|
COMP_FLAGS = ?{c.ccompiler.flags}
|
||||||
|
LINK_FLAGS = ?{c.linker.flags}
|
||||||
|
binDir = ?{firstBinPath(c).toUnix}
|
||||||
|
|
||||||
|
koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"')
|
||||||
|
ifeq ($(koch),yes)
|
||||||
|
binDir = ../bin
|
||||||
|
endif
|
||||||
|
|
||||||
|
ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"')
|
||||||
|
uos := $(shell sh -c 'uname | tr "[:upper:]" "[:lower:]"')
|
||||||
|
|
||||||
|
ifeq ($(uos),linux)
|
||||||
|
myos = linux
|
||||||
|
LINK_FLAGS += -ldl -lm
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),dragonfly)
|
||||||
|
myos = freebsd
|
||||||
|
LINK_FLAGS += -lm
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),freebsd)
|
||||||
|
myos= freebsd
|
||||||
|
CC = clang
|
||||||
|
LINKER = clang
|
||||||
|
LINK_FLAGS += -lm
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),openbsd)
|
||||||
|
myos = openbsd
|
||||||
|
LINK_FLAGS += -lm
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),netbsd)
|
||||||
|
myos = netbsd
|
||||||
|
LINK_FLAGS += -lm
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),darwin)
|
||||||
|
myos = macosx
|
||||||
|
CC = clang
|
||||||
|
LINKER = clang
|
||||||
|
LINK_FLAGS += -ldl -lm
|
||||||
|
ifeq ($HOSTTYPE,x86_64)
|
||||||
|
ucpu = amd64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),aix)
|
||||||
|
myos = aix
|
||||||
|
LINK_FLAGS += -dl -lm
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),solaris)
|
||||||
|
myos = solaris
|
||||||
|
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),sun)
|
||||||
|
myos = solaris
|
||||||
|
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
||||||
|
endif
|
||||||
|
ifeq ($(uos),haiku)
|
||||||
|
myos = haiku
|
||||||
|
endif
|
||||||
|
ifndef uos
|
||||||
|
@echo "Error: unknown operating system: $(uos)"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ucpu),i386)
|
||||||
|
mycpu = i386
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),i486)
|
||||||
|
mycpu = i386
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),i586)
|
||||||
|
mycpu = i386
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),i686)
|
||||||
|
mycpu = i386
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),bepc)
|
||||||
|
mycpu = i386
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),i86pc)
|
||||||
|
mycpu = i386
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),amd64)
|
||||||
|
mycpu = amd64
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),x86-64)
|
||||||
|
mycpu = amd64
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),x86_64)
|
||||||
|
mycpu = amd64
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),sparc)
|
||||||
|
mycpu = sparc
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),sun)
|
||||||
|
mycpu = sparc
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),ppc64)
|
||||||
|
mycpu = powerpc64
|
||||||
|
ifeq ($(myos),linux)
|
||||||
|
COMP_FLAGS += -m64
|
||||||
|
LINK_FLAGS += -m64
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),powerpc)
|
||||||
|
mycpu = powerpc
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),ppc)
|
||||||
|
mycpu = ppc
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),mips)
|
||||||
|
mycpu = mips
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),arm)
|
||||||
|
mycpu = arm
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),armeb)
|
||||||
|
mycpu = arm
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),armel)
|
||||||
|
mycpu = arm
|
||||||
|
endif
|
||||||
|
ifeq ($(ucpu),armv6l)
|
||||||
|
mycpu = arm
|
||||||
|
endif
|
||||||
|
ifndef ucpu
|
||||||
|
@echo "Error: unknown processor : $(ucpu)"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
# for osA in 1..c.oses.len:
|
||||||
|
ifeq ($(myos),?{c.oses[osA-1]})
|
||||||
|
# for cpuA in 1..c.cpus.len:
|
||||||
|
ifeq ($(mycpu),?{c.cpus[cpuA-1]})
|
||||||
|
# var oFiles = ""
|
||||||
|
# for ff in c.cfiles[osA][cpuA].items:
|
||||||
|
# oFiles.add(" " & changeFileExt(ff.toUnix, "o"))
|
||||||
|
# end for
|
||||||
|
oFiles =?oFiles
|
||||||
|
endif
|
||||||
|
# end for
|
||||||
|
endif
|
||||||
|
# end for
|
||||||
|
|
||||||
|
ifeq ($(strip $(oFiles)),)
|
||||||
|
@echo "Error: no C code generated for: [$(myos): $(mycpu)]"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(COMP_FLAGS) -Ic_code -c $< -o $@
|
||||||
|
|
||||||
|
?{"$(binDir)/" & toLower(c.name)}: $(oFiles)
|
||||||
|
@mkdir -p $(binDir)
|
||||||
|
$(LINKER) -o $@ $^ $(LINK_FLAGS)
|
||||||
|
@echo "SUCCESS"
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(oFiles) ?{"$(binDir)/" & toLower(c.name)}
|
||||||
|
|
@ -22,6 +22,7 @@ const
|
||||||
buildShFile = "build.sh"
|
buildShFile = "build.sh"
|
||||||
buildBatFile32 = "build.bat"
|
buildBatFile32 = "build.bat"
|
||||||
buildBatFile64 = "build64.bat"
|
buildBatFile64 = "build64.bat"
|
||||||
|
makeFile = "makefile"
|
||||||
installShFile = "install.sh"
|
installShFile = "install.sh"
|
||||||
deinstallShFile = "deinstall.sh"
|
deinstallShFile = "deinstall.sh"
|
||||||
|
|
||||||
|
|
@ -122,6 +123,7 @@ proc skipRoot(f: string): string =
|
||||||
include "inno.tmpl"
|
include "inno.tmpl"
|
||||||
include "nsis.tmpl"
|
include "nsis.tmpl"
|
||||||
include "buildsh.tmpl"
|
include "buildsh.tmpl"
|
||||||
|
include "makefile.tmpl"
|
||||||
include "buildbat.tmpl"
|
include "buildbat.tmpl"
|
||||||
include "install.tmpl"
|
include "install.tmpl"
|
||||||
include "deinstall.tmpl"
|
include "deinstall.tmpl"
|
||||||
|
|
@ -479,6 +481,7 @@ proc srcdist(c: var ConfigData) =
|
||||||
removeDuplicateFiles(c)
|
removeDuplicateFiles(c)
|
||||||
writeFile(getOutputDir(c) / buildShFile, generateBuildShellScript(c), "\10")
|
writeFile(getOutputDir(c) / buildShFile, generateBuildShellScript(c), "\10")
|
||||||
inclFilePermissions(getOutputDir(c) / buildShFile, {fpUserExec, fpGroupExec, fpOthersExec})
|
inclFilePermissions(getOutputDir(c) / buildShFile, {fpUserExec, fpGroupExec, fpOthersExec})
|
||||||
|
writeFile(getOutputDir(c) / makeFile, generateMakefile(c), "\10")
|
||||||
if winIndex >= 0:
|
if winIndex >= 0:
|
||||||
if intel32Index >= 0:
|
if intel32Index >= 0:
|
||||||
writeFile(getOutputDir(c) / buildBatFile32,
|
writeFile(getOutputDir(c) / buildBatFile32,
|
||||||
|
|
@ -534,6 +537,7 @@ when haveZipLib:
|
||||||
addFile(z, proj / buildBatFile32, "build" / buildBatFile32)
|
addFile(z, proj / buildBatFile32, "build" / buildBatFile32)
|
||||||
addFile(z, proj / buildBatFile64, "build" / buildBatFile64)
|
addFile(z, proj / buildBatFile64, "build" / buildBatFile64)
|
||||||
addFile(z, proj / buildShFile, "build" / buildShFile)
|
addFile(z, proj / buildShFile, "build" / buildShFile)
|
||||||
|
addFile(z, proj / makeFile, "build" / makeFile)
|
||||||
addFile(z, proj / installShFile, installShFile)
|
addFile(z, proj / installShFile, installShFile)
|
||||||
addFile(z, proj / deinstallShFile, deinstallShFile)
|
addFile(z, proj / deinstallShFile, deinstallShFile)
|
||||||
for f in walkFiles(c.libpath / "lib/*.h"):
|
for f in walkFiles(c.libpath / "lib/*.h"):
|
||||||
|
|
@ -574,6 +578,7 @@ proc debDist(c: var ConfigData) =
|
||||||
|
|
||||||
# Don't copy all files, only the ones specified in the config:
|
# Don't copy all files, only the ones specified in the config:
|
||||||
copyNimDist(buildShFile, buildShFile)
|
copyNimDist(buildShFile, buildShFile)
|
||||||
|
copyNimDist(makeFile, makeFile)
|
||||||
copyNimDist(installShFile, installShFile)
|
copyNimDist(installShFile, installShFile)
|
||||||
createDir(workingDir / upstreamSource / "build")
|
createDir(workingDir / upstreamSource / "build")
|
||||||
for f in walkFiles(c.libpath / "lib/*.h"):
|
for f in walkFiles(c.libpath / "lib/*.h"):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue