Merge pull request #5830 from jcowgill/makefile-indentation

makefile.tmpl: fix error handling and cleanups
This commit is contained in:
Dennis Felsing 2017-06-20 21:31:17 +02:00 • committed by GitHub
commit fd5ddab581

View file

@ -12,146 +12,143 @@ binDir = ?{firstBinPath(c).toUnix}
koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"') koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"')
ifeq ($(koch),yes) ifeq ($(koch),yes)
binDir = ../bin binDir = ../bin
endif endif
ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"') ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"')
uos := $(shell sh -c 'uname | tr "[:upper:]" "[:lower:]"') uos := $(shell sh -c 'uname | tr "[:upper:]" "[:lower:]"')
ifeq ($(uos),linux) ifeq ($(uos),linux)
myos = linux myos = linux
LINK_FLAGS += -ldl -lm LINK_FLAGS += -ldl -lm
endif endif
ifeq ($(uos),dragonfly) ifeq ($(uos),dragonfly)
myos = freebsd myos = freebsd
LINK_FLAGS += -lm LINK_FLAGS += -lm
endif endif
ifeq ($(uos),freebsd) ifeq ($(uos),freebsd)
myos= freebsd myos= freebsd
CC = clang CC = clang
LINKER = clang LINKER = clang
LINK_FLAGS += -lm LINK_FLAGS += -lm
endif endif
ifeq ($(uos),openbsd) ifeq ($(uos),openbsd)
myos = openbsd myos = openbsd
LINK_FLAGS += -lm LINK_FLAGS += -lm
endif endif
ifeq ($(uos),netbsd) ifeq ($(uos),netbsd)
myos = netbsd myos = netbsd
LINK_FLAGS += -lm LINK_FLAGS += -lm
endif endif
ifeq ($(uos),darwin) ifeq ($(uos),darwin)
myos = macosx myos = macosx
CC = clang CC = clang
LINKER = clang LINKER = clang
LINK_FLAGS += -ldl -lm LINK_FLAGS += -ldl -lm
ifeq ($HOSTTYPE,x86_64) ifeq ($HOSTTYPE,x86_64)
ucpu = amd64 ucpu = amd64
endif endif
endif endif
ifeq ($(uos),aix) ifeq ($(uos),aix)
myos = aix myos = aix
LINK_FLAGS += -dl -lm LINK_FLAGS += -dl -lm
endif endif
ifeq ($(uos),solaris) ifeq ($(uos),solaris)
myos = solaris myos = solaris
LINK_FLAGS += -ldl -lm -lsocket -lnsl LINK_FLAGS += -ldl -lm -lsocket -lnsl
endif endif
ifeq ($(uos),sun) ifeq ($(uos),sun)
myos = solaris myos = solaris
LINK_FLAGS += -ldl -lm -lsocket -lnsl LINK_FLAGS += -ldl -lm -lsocket -lnsl
endif endif
ifeq ($(uos),haiku) ifeq ($(uos),haiku)
myos = haiku myos = haiku
endif endif
ifndef uos ifndef uos
@echo "Error: unknown operating system: $(uos)" $(error unknown operating system: $(uos))
@exit 1
endif endif
ifeq ($(ucpu),i386) ifeq ($(ucpu),i386)
mycpu = i386 mycpu = i386
endif endif
ifeq ($(ucpu),i486) ifeq ($(ucpu),i486)
mycpu = i386 mycpu = i386
endif endif
ifeq ($(ucpu),i586) ifeq ($(ucpu),i586)
mycpu = i386 mycpu = i386
endif endif
ifeq ($(ucpu),i686) ifeq ($(ucpu),i686)
mycpu = i386 mycpu = i386
endif endif
ifeq ($(ucpu),bepc) ifeq ($(ucpu),bepc)
mycpu = i386 mycpu = i386
endif endif
ifeq ($(ucpu),i86pc) ifeq ($(ucpu),i86pc)
mycpu = i386 mycpu = i386
endif endif
ifeq ($(ucpu),amd64) ifeq ($(ucpu),amd64)
mycpu = amd64 mycpu = amd64
endif endif
ifeq ($(ucpu),x86-64) ifeq ($(ucpu),x86-64)
mycpu = amd64 mycpu = amd64
endif endif
ifeq ($(ucpu),x86_64) ifeq ($(ucpu),x86_64)
mycpu = amd64 mycpu = amd64
endif endif
ifeq ($(ucpu),sparc) ifeq ($(ucpu),sparc)
mycpu = sparc mycpu = sparc
endif endif
ifeq ($(ucpu),sun) ifeq ($(ucpu),sun)
mycpu = sparc mycpu = sparc
endif endif
ifeq ($(ucpu),ppc64) ifeq ($(ucpu),ppc64)
mycpu = powerpc64 mycpu = powerpc64
ifeq ($(myos),linux) ifeq ($(myos),linux)
COMP_FLAGS += -m64 COMP_FLAGS += -m64
LINK_FLAGS += -m64 LINK_FLAGS += -m64
endif endif
endif endif
ifeq ($(ucpu),powerpc) ifeq ($(ucpu),powerpc)
mycpu = powerpc mycpu = powerpc
endif endif
ifeq ($(ucpu),ppc) ifeq ($(ucpu),ppc)
mycpu = ppc mycpu = ppc
endif endif
ifeq ($(ucpu),mips) ifeq ($(ucpu),mips)
mycpu = mips mycpu = mips
endif endif
ifeq ($(ucpu),arm) ifeq ($(ucpu),arm)
mycpu = arm mycpu = arm
endif endif
ifeq ($(ucpu),armeb) ifeq ($(ucpu),armeb)
mycpu = arm mycpu = arm
endif endif
ifeq ($(ucpu),armel) ifeq ($(ucpu),armel)
mycpu = arm mycpu = arm
endif endif
ifeq ($(ucpu),armv6l) ifeq ($(ucpu),armv6l)
mycpu = arm mycpu = arm
endif endif
ifndef ucpu ifndef ucpu
@echo "Error: unknown processor : $(ucpu)" $(error unknown processor : $(ucpu))
@exit 1
endif endif
# for osA in 1..c.oses.len: # for osA in 1..c.oses.len:
ifeq ($(myos),?{c.oses[osA-1]}) ifeq ($(myos),?{c.oses[osA-1]})
# for cpuA in 1..c.cpus.len: # for cpuA in 1..c.cpus.len:
ifeq ($(mycpu),?{c.cpus[cpuA-1]}) ifeq ($(mycpu),?{c.cpus[cpuA-1]})
# var oFiles = "" # var oFiles = ""
# for ff in c.cfiles[osA][cpuA].items: # for ff in c.cfiles[osA][cpuA].items:
# oFiles.add(" " & changeFileExt(ff.toUnix, "o")) # oFiles.add(" " & changeFileExt(ff.toUnix, "o"))
# end for # end for
oFiles =?oFiles oFiles =?oFiles
endif endif
# end for # end for
endif endif
# end for # end for
ifeq ($(strip $(oFiles)),) ifeq ($(strip $(oFiles)),)
@echo "Error: no C code generated for: [$(myos): $(mycpu)]" $(error no C code generated for: [$(myos): $(mycpu)])
@exit 1
endif endif
%.o: %.c %.o: %.c