@@ -30,13 +30,19 @@ ifdef CONFIG_WIN32
30
30
LIBTCC = libtcc$(DLLSUF )
31
31
LIBTCCDEF = libtcc.def
32
32
endif
33
+ ifneq ($(CONFIG_debug),yes)
34
+ LDFLAGS += -s
35
+ endif
33
36
NATIVE_TARGET = $(ARCH ) -win$(if $(findstring arm,$(ARCH ) ) ,ce,32)
34
37
else
35
38
CFG = -unx
36
- LIBS =-lm -lpthread
39
+ LIBS+ =-lm
37
40
ifneq ($(CONFIG_ldl),no)
38
41
LIBS+ =-ldl
39
42
endif
43
+ ifneq ($(CONFIG_pthread),no)
44
+ LIBS+ =-lpthread
45
+ endif
40
46
# make libtcc as static or dynamic library?
41
47
ifeq ($(CONFIG_static),no)
42
48
LIBTCC =libtcc$(DLLSUF )
68
74
TCCFLAGS-unx = -B$(TOP ) -I$(TOPSRC ) /include -I$(TOPSRC ) -I$(TOP )
69
75
TCCFLAGS-win = -B$(TOPSRC ) /win32 -I$(TOPSRC ) /include -I$(TOPSRC ) -I$(TOP ) -L$(TOP )
70
76
TCCFLAGS = $(TCCFLAGS$(CFG ) )
71
- ifdef USE_TCC_C
72
- TCC = $(TOP ) /tcc_c$(EXESUF ) $(TCCFLAGS )
73
- else
74
- TCC = $(TOP ) /tcc$(EXESUF ) $(TCCFLAGS )
75
- endif
77
+ TCC_LOCAL = $(TOP ) /tcc$(EXESUF )
78
+ TCC = $(TCC_LOCAL ) $(TCCFLAGS )
76
79
77
80
CFLAGS_P = $(CFLAGS ) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
78
81
LIBS_P = $(LIBS )
@@ -181,11 +184,8 @@ DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")
181
184
DEFINES += $(DEF-$(or $(findstring win,$T) ,unx) )
182
185
183
186
ifneq ($(X ) ,)
184
- ifeq ($(CONFIG_WIN32 ) ,yes)
185
- DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
186
- DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\""
187
- else
188
187
DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
188
+ ifneq ($(CONFIG_WIN32 ) ,yes)
189
189
DEF-win += -DCONFIG_TCCDIR="\"$(tccdir ) /win32\""
190
190
endif
191
191
endif
@@ -249,17 +249,14 @@ endif
249
249
250
250
GITHASH: =$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
251
251
ifneq ($(GITHASH ) ,no)
252
- GITHASH: =$(shell git log -1 --pretty='format:% cs $(GITHASH ) @% h')$(shell git diff --quiet || echo '* ')
253
- DEF_GITHASH: = -DTCC_GITHASH="\"$(GITHASH ) \""
252
+ GITHASH: =$(shell git log -1 --date=short --pretty='format:% cd $(GITHASH ) @% h')
253
+ GITMODF: =$(shell git diff --quiet || echo '* ')
254
+ DEF_GITHASH: = -DTCC_GITHASH="\"$(GITHASH )$(GITMODF ) \""
254
255
endif
255
256
256
257
ifeq ($(CONFIG_debug ) ,yes)
257
258
CFLAGS += -g
258
259
LDFLAGS += -g
259
- else
260
- ifndef CONFIG_OSX
261
- LDFLAGS += -s
262
- endif
263
260
endif
264
261
265
262
# convert "include/tccdefs.h" to "tccdefs_.h"
@@ -335,7 +332,11 @@ libtcc1.a : tcc$(EXESUF) FORCE
335
332
.PRECIOUS : % -libtcc1.a
336
333
FORCE :
337
334
338
- run-if = $(if $(shell command -v $1) ,$S $1 $2)
335
+ # WHICH = which $1 2>/dev/null
336
+ # some versions of gnu-make do not recognize 'command' as a shell builtin
337
+ WHICH = sh -c 'command -v $1'
338
+
339
+ run-if = $(if $(shell $(call WHICH,$1) ) ,$S $1 $2)
339
340
S = $(if $(findstring yes,$(SILENT ) ) ,@$(info * $@ ) )
340
341
341
342
# --------------------------------------------------------------------------
@@ -348,7 +349,7 @@ tcc-doc.info: tcc-doc.texi
348
349
349
350
tcc.1 : tcc-doc.pod
350
351
$(call run-if,pod2man,--section=1 --center="Tiny C Compiler" \
351
- --release=" $( VERSION) " $< > $@ && rm -f $< )
352
+ --release=" $( VERSION) " $< > $@ )
352
353
% .pod : % .texi
353
354
$(call run-if,perl,$(TOPSRC ) /texi2pod.pl $< $@ )
354
355
@@ -392,8 +393,9 @@ endif
392
393
393
394
# uninstall
394
395
uninstall-unx :
395
- @rm -fv $(foreach P,$(PROGS ) $(PROGS_CROSS ) ,"$(bindir ) /$P")
396
- @rm -fv " $( libdir) /libtcc.a" " $( libdir) /libtcc.so" " $( libdir) /libtcc.dylib" " $( includedir) /libtcc.h"
396
+ @rm -fv $(addprefix "$(bindir ) /",$(PROGS ) $(PROGS_CROSS ) )
397
+ @rm -fv $(addprefix "$(libdir ) /", libtcc* .a libtcc* .so libtcc.dylib,$P)
398
+ @rm -fv $(addprefix "$(includedir ) /", libtcc.h)
397
399
@rm -fv " $( mandir) /man1/tcc.1" " $( infodir) /tcc-doc.info"
398
400
@rm -fv " $( docdir) /tcc-doc.html"
399
401
@rm -frv " $( tccdir) "
@@ -415,17 +417,19 @@ ifneq "$(wildcard $(LIBTCC1_U))" ""
415
417
$(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/lib/include")
416
418
endif
417
419
418
- # the msys-git shell works to configure && make except it does not have install
419
- ifeq ($(CONFIG_WIN32 ) -$(shell command -v install || echo no) ,yes-no)
420
- install-win : INSTALL = cp
421
- install-win : INSTALLBIN = cp
422
- endif
423
-
424
420
# uninstall on windows
425
421
uninstall-win :
426
- @rm -fv $(foreach P,libtcc.dll $(PROGS ) * -tcc.exe,"$(bindir ) "/$P)
427
- @rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir ) /$P"/* )
428
- @rm -frv $(foreach P,doc examples include lib libtcc,"$(tccdir ) /$P")
422
+ @rm -fv $(addprefix "$(bindir ) /", libtcc* .dll $(PROGS ) * -tcc.exe)
423
+ @rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir ) /$P/* ")
424
+ @rm -frv $(addprefix "$(tccdir ) /", doc examples include lib libtcc)
425
+
426
+ # the msys-git shell works to configure && make except it does not have install
427
+ ifeq ($(OS ) ,Windows_NT)
428
+ ifeq ($(shell $(call WHICH,install) || echo no) ,no)
429
+ INSTALL = cp
430
+ INSTALLBIN = cp
431
+ endif
432
+ endif
429
433
430
434
# --------------------------------------------------------------------------
431
435
# other stuff
@@ -459,66 +463,50 @@ test:
459
463
# run test(s) from tests2 subdir (see make help)
460
464
tests2.% :
461
465
@$(MAKE ) -C tests/tests2 $@
462
-
466
+ # run test(s) from testspp subdir (see make help)
463
467
testspp.% :
464
468
@$(MAKE ) -C tests/pp $@
465
-
466
- # run all tests with code coverage
469
+ # run tests with code coverage
470
+ tcov-tes% : tcc_c$(EXESUF )
471
+ @rm -f $< .tcov
472
+ @$(MAKE ) --no-print-directory TCC_LOCAL=$(CURDIR ) /$< tes$*
467
473
tcc_c$(EXESUF ) : $($T_FILES )
468
- @${TCC} -o $@ -ftest-coverage $< $(DEFINES ) $(CFLAGS ) $(LIBS ) $(LDFLAGS )
469
- testc : tcc_c$(EXESUF )
470
- @rm -f tcc_c.tcov
471
- @USE_TCC_C=yes $(MAKE ) -C tests
472
- testc2.% : tcc_c$(EXESUF )
473
- @rm -f tcc_c.tcov
474
- @USE_TCC_C=yes $(MAKE ) -C tests/tests2 $@
475
- testcpp.% : tcc_c$(EXESUF )
476
- @rm -f tcc_c.tcov
477
- @USE_TCC_C=yes $(MAKE ) -C tests/pp $@
474
+ $S $(TCC ) tcc.c -o $@ -ftest-coverage $(DEFINES )
478
475
479
476
clean :
480
- @rm -f tcc$(EXESUF ) tcc_c$(EXESUF ) tcc_p$(EXESUF ) * -tcc$(EXESUF ) tags ETAGS * .pod
481
- @rm -f * .o * .a * .so* * .out * .log lib* .def * .exe * .dll a.out * .dylib * _.h
477
+ @rm -f tcc$(EXESUF ) tcc_c$(EXESUF ) tcc_p$(EXESUF ) * -tcc$(EXESUF )
478
+ @rm -f tags ETAGS * .o * .a * .so* * .out * .log lib* .def * .exe * .dll
479
+ @rm -f a.out * .dylib * _.h * .pod * .tcov
482
480
@$(MAKE ) -s -C lib $@
483
481
@$(MAKE ) -s -C tests $@
484
482
485
483
distclean : clean
486
- @rm -f config.h config.mak config.texi
487
- @rm -f $(TCCDOCS )
484
+ @rm -vf config.h config.mak config.texi
485
+ @rm -vf $(TCCDOCS )
488
486
489
487
.PHONY : all clean test tar tags ETAGS doc distclean install uninstall FORCE
490
488
491
489
help :
492
490
@echo " make"
493
491
@echo " build native compiler (from separate objects)"
494
- @echo " "
495
492
@echo " make cross"
496
493
@echo " build cross compilers (from one source)"
497
- @echo " "
498
494
@echo " make ONE_SOURCE=no/yes SILENT=no/yes"
499
495
@echo " force building from separate/one object(s), less/more silently"
500
- @echo " "
501
496
@echo " make cross-TARGET"
502
497
@echo " build one specific cross compiler for 'TARGET'. Currently supported:"
503
- @echo " $( wordlist 1,6,$( TCC_X) ) "
504
- @echo " $( wordlist 7,99,$( TCC_X) ) "
505
- @echo " "
498
+ @echo " $( wordlist 1,8,$( TCC_X) ) "
499
+ @echo " $( wordlist 9,99,$( TCC_X) ) "
506
500
@echo " make test"
507
501
@echo " run all tests"
508
- @echo " "
509
- @echo " make tests2.all / make tests2.37 / make tests2.37+ / make tests2.37-"
510
- @echo " run all/single test(s) from tests2, optionally update .expect, display"
511
- @echo " "
502
+ @echo " make tests2.all / make tests2.37 / make tests2.37+"
503
+ @echo " run all/single test(s) from tests2, optionally update .expect"
512
504
@echo " make testspp.all / make testspp.17"
513
505
@echo " run all/single test(s) from tests/pp"
514
- @echo " "
515
- @echo " make testc / testc2.all / testc2.37 / testc2.37+ / testc2.37-"
516
- @echo " make testcpp.all / make testcpp.17"
517
- @echo " run tests with code coverage. After test(s) see tcc_c.tcov"
518
- @echo " "
506
+ @echo " make tcov-test / tcov-tests2... / tcov-testspp..."
507
+ @echo " run tests as above with code coverage. After test(s) see tcc_c$( EXESUF) .tcov"
519
508
@echo " Other supported make targets:"
520
509
@echo " install install-strip doc clean tags ETAGS tar distclean help"
521
- @echo " "
522
510
@echo " Custom configuration:"
523
511
@echo " The makefile includes a file 'config-extra.mak' if it is present."
524
512
@echo " This file may contain some custom configuration. For example:"
0 commit comments