mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 02:18:00 +00:00
use more make conventions (#6789)
* use more make conventions improves compatibility with cross compilation systems * use make implicit rule
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
|
||||
CC ??= gcc
|
||||
LD ??= gcc
|
||||
COMP_FLAGS = $(CPPFLAGS) $(CFLAGS) ?{c.ccompiler.flags}
|
||||
LINK_FLAGS = $(LDFLAGS) ?{c.linker.flags}
|
||||
CFLAGS += -Ic_code ?{c.ccompiler.flags}
|
||||
LDFLAGS += ?{c.linker.flags}
|
||||
binDir = ?{firstBinPath(c).toUnix}
|
||||
|
||||
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)
|
||||
myos = linux
|
||||
LINK_FLAGS += -ldl -lm
|
||||
LDFLAGS += -ldl -lm
|
||||
endif
|
||||
ifeq ($(uos),dragonfly)
|
||||
myos = freebsd
|
||||
LINK_FLAGS += -lm
|
||||
LDFLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),freebsd)
|
||||
myos= freebsd
|
||||
CC = clang
|
||||
LD = clang
|
||||
LINK_FLAGS += -lm
|
||||
LDFLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),openbsd)
|
||||
myos = openbsd
|
||||
LINK_FLAGS += -lm
|
||||
LDFLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),netbsd)
|
||||
myos = netbsd
|
||||
LINK_FLAGS += -lm
|
||||
LDFLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),darwin)
|
||||
myos = macosx
|
||||
CC = clang
|
||||
LD = clang
|
||||
LINK_FLAGS += -ldl -lm
|
||||
LDFLAGS += -ldl -lm
|
||||
ifeq ($(HOSTTYPE),x86_64)
|
||||
ucpu = amd64
|
||||
endif
|
||||
endif
|
||||
ifeq ($(uos),aix)
|
||||
myos = aix
|
||||
LINK_FLAGS += -dl -lm
|
||||
LDFLAGS += -dl -lm
|
||||
endif
|
||||
ifeq ($(uos),solaris)
|
||||
myos = solaris
|
||||
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
||||
LDFLAGS += -ldl -lm -lsocket -lnsl
|
||||
endif
|
||||
ifeq ($(uos),sun)
|
||||
myos = solaris
|
||||
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
||||
LDFLAGS += -ldl -lm -lsocket -lnsl
|
||||
endif
|
||||
ifeq ($(uos),haiku)
|
||||
myos = haiku
|
||||
@@ -107,8 +107,8 @@ endif
|
||||
ifeq ($(ucpu),ppc64)
|
||||
mycpu = powerpc64
|
||||
ifeq ($(myos),linux)
|
||||
COMP_FLAGS += -m64
|
||||
LINK_FLAGS += -m64
|
||||
CFLAGS += -m64
|
||||
LDFLAGS += -m64
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ucpu),powerpc)
|
||||
@@ -166,12 +166,9 @@ ifeq ($(strip $(oFiles)),)
|
||||
$(error no C code generated for: [$(myos): $(mycpu)])
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(COMP_FLAGS) -Ic_code -c $< -o $@
|
||||
|
||||
?{"$(binDir)/" & toLowerAscii(c.name)}: $(oFiles)
|
||||
@mkdir -p $(binDir)
|
||||
$(LD) -o $@ $^ $(LINK_FLAGS)
|
||||
$(LD) -o $@ $^ $(LDFLAGS)
|
||||
@echo "SUCCESS"
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
Reference in New Issue
Block a user