use more make conventions (#6789)
* use more make conventions improves compatibility with cross compilation systems * use make implicit rule
This commit is contained in:
parent
d3394be555
commit
89fa438857
1 changed files with 14 additions and 17 deletions
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
CC ??= gcc
|
CC ??= gcc
|
||||||
LD ??= gcc
|
LD ??= gcc
|
||||||
COMP_FLAGS = $(CPPFLAGS) $(CFLAGS) ?{c.ccompiler.flags}
|
CFLAGS += -Ic_code ?{c.ccompiler.flags}
|
||||||
LINK_FLAGS = $(LDFLAGS) ?{c.linker.flags}
|
LDFLAGS += ?{c.linker.flags}
|
||||||
binDir = ?{firstBinPath(c).toUnix}
|
binDir = ?{firstBinPath(c).toUnix}
|
||||||
|
|
||||||
koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"')
|
koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"')
|
||||||
|
|
@ -20,46 +20,46 @@ uos := $(shell sh -c 'uname | tr "[:upper:]" "[:lower:]"')
|
||||||
|
|
||||||
ifeq ($(uos),linux)
|
ifeq ($(uos),linux)
|
||||||
myos = linux
|
myos = linux
|
||||||
LINK_FLAGS += -ldl -lm
|
LDFLAGS += -ldl -lm
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),dragonfly)
|
ifeq ($(uos),dragonfly)
|
||||||
myos = freebsd
|
myos = freebsd
|
||||||
LINK_FLAGS += -lm
|
LDFLAGS += -lm
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),freebsd)
|
ifeq ($(uos),freebsd)
|
||||||
myos= freebsd
|
myos= freebsd
|
||||||
CC = clang
|
CC = clang
|
||||||
LD = clang
|
LD = clang
|
||||||
LINK_FLAGS += -lm
|
LDFLAGS += -lm
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),openbsd)
|
ifeq ($(uos),openbsd)
|
||||||
myos = openbsd
|
myos = openbsd
|
||||||
LINK_FLAGS += -lm
|
LDFLAGS += -lm
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),netbsd)
|
ifeq ($(uos),netbsd)
|
||||||
myos = netbsd
|
myos = netbsd
|
||||||
LINK_FLAGS += -lm
|
LDFLAGS += -lm
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),darwin)
|
ifeq ($(uos),darwin)
|
||||||
myos = macosx
|
myos = macosx
|
||||||
CC = clang
|
CC = clang
|
||||||
LD = clang
|
LD = clang
|
||||||
LINK_FLAGS += -ldl -lm
|
LDFLAGS += -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
|
LDFLAGS += -dl -lm
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),solaris)
|
ifeq ($(uos),solaris)
|
||||||
myos = solaris
|
myos = solaris
|
||||||
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
LDFLAGS += -ldl -lm -lsocket -lnsl
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),sun)
|
ifeq ($(uos),sun)
|
||||||
myos = solaris
|
myos = solaris
|
||||||
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
LDFLAGS += -ldl -lm -lsocket -lnsl
|
||||||
endif
|
endif
|
||||||
ifeq ($(uos),haiku)
|
ifeq ($(uos),haiku)
|
||||||
myos = haiku
|
myos = haiku
|
||||||
|
|
@ -107,8 +107,8 @@ endif
|
||||||
ifeq ($(ucpu),ppc64)
|
ifeq ($(ucpu),ppc64)
|
||||||
mycpu = powerpc64
|
mycpu = powerpc64
|
||||||
ifeq ($(myos),linux)
|
ifeq ($(myos),linux)
|
||||||
COMP_FLAGS += -m64
|
CFLAGS += -m64
|
||||||
LINK_FLAGS += -m64
|
LDFLAGS += -m64
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(ucpu),powerpc)
|
ifeq ($(ucpu),powerpc)
|
||||||
|
|
@ -166,12 +166,9 @@ ifeq ($(strip $(oFiles)),)
|
||||||
$(error no C code generated for: [$(myos): $(mycpu)])
|
$(error no C code generated for: [$(myos): $(mycpu)])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(COMP_FLAGS) -Ic_code -c $< -o $@
|
|
||||||
|
|
||||||
?{"$(binDir)/" & toLowerAscii(c.name)}: $(oFiles)
|
?{"$(binDir)/" & toLowerAscii(c.name)}: $(oFiles)
|
||||||
@mkdir -p $(binDir)
|
@mkdir -p $(binDir)
|
||||||
$(LD) -o $@ $^ $(LINK_FLAGS)
|
$(LD) -o $@ $^ $(LDFLAGS)
|
||||||
@echo "SUCCESS"
|
@echo "SUCCESS"
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue