make: optimize Makefile

pull/5179/head
yuyi 2020-06-03 00:11:58 +08:00 committed by GitHub
parent 1386c5df13
commit f1f4e380a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 13 deletions

View File

@ -2,9 +2,9 @@ CC ?= cc
CFLAGS ?= CFLAGS ?=
LDFLAGS ?= LDFLAGS ?=
TMPDIR ?= /tmp TMPDIR ?= /tmp
VC ?= ./vc
VCFILE := v.c VCFILE := v.c
TMPVC := $(TMPDIR)/vc
TMPTCC := /var/tmp/tcc TMPTCC := /var/tmp/tcc
VCREPO := https://github.com/vlang/vc VCREPO := https://github.com/vlang/vc
TCCREPO := https://github.com/vlang/tccbin TCCREPO := https://github.com/vlang/tccbin
@ -45,20 +45,27 @@ endif
all: latest_vc latest_tcc all: latest_vc latest_tcc
ifdef WIN32 ifdef WIN32
$(CC) $(CFLAGS) -g -std=c99 -municode -w -o v.exe $(TMPVC)/$(VCFILE) $(LDFLAGS) $(CC) $(CFLAGS) -g -std=c99 -municode -w -o v.exe $(VC)/$(VCFILE) $(LDFLAGS)
./v.exe self ifdef prod
./v.exe -prod self
else else
$(CC) $(CFLAGS) -g -std=gnu11 -w -o v $(TMPVC)/$(VCFILE) $(LDFLAGS) -lm -lpthread ./v.exe self
endif
else
$(CC) $(CFLAGS) -g -std=gnu11 -w -o v $(VC)/$(VCFILE) $(LDFLAGS) -lm -lpthread
ifdef ANDROID ifdef ANDROID
chmod 755 v chmod 755 v
endif endif
ifdef prod
./v -prod self
else
./v self ./v self
endif
ifndef ANDROID ifndef ANDROID
$(MAKE) modules $(MAKE) modules
endif endif
endif
ifdef V_ALWAYS_CLEAN_TMP
$(MAKE) clean_tmp
endif endif
@echo "V has been successfully built" @echo "V has been successfully built"
@./v -version @./v -version
@ -68,19 +75,26 @@ endif
clean: clean:
rm -rf $(TMPTCC) rm -rf $(TMPTCC)
rm -rf $(TMPVC) rm -rf $(VC)
latest_vc: $(TMPVC)/.git/config latest_vc: $(VC)/.git/config
cd $(TMPVC) && $(GITCLEANPULL) ifndef local
cd $(VC) && $(GITCLEANPULL)
else
@echo "Using local vc"
endif
fresh_vc: fresh_vc:
rm -rf $(TMPVC) $(GITFASTCLONE) $(VCREPO) $(VC)
$(GITFASTCLONE) $(VCREPO) $(TMPVC)
latest_tcc: $(TMPTCC)/.git/config latest_tcc: $(TMPTCC)/.git/config
ifndef ANDROID ifndef ANDROID
ifndef MAC ifndef MAC
ifndef local
cd $(TMPTCC) && $(GITCLEANPULL) cd $(TMPTCC) && $(GITCLEANPULL)
else
@echo "Using local tcc"
endif
endif endif
endif endif
@ -97,7 +111,7 @@ ifndef MAC
$(MAKE) fresh_tcc $(MAKE) fresh_tcc
endif endif
$(TMPVC)/.git/config: $(VC)/.git/config:
$(MAKE) fresh_vc $(MAKE) fresh_vc
selfcompile: selfcompile: