1# Makefile for tpl built-in test suite 2# 3# This Makefile has three useful targets: 4# 5# all (default): 6# Build and run all self-tests by compiling tpl into each test. 7# 8# Note: On Cygwin/MinGW, compiling the tpl source directly into the tests is 9# not supported (as they use 'replacement' functions which get included only 10# in libtpl), so on these platforms the 'alt' target is the default. 11# 12# alt: 13# Build and run all the self-tests by linking them with libtpl, which must 14# have been created beforehand (by running 'configure; make' in the 15# top-level directory); a reminder will be printed if you have not done so. 16# 17# Note, libtool will create wrappers around each test to accomodate the 18# pre-installed state of ../src/libtpl.la. In a real program, you'd link 19# against an installed libtpl.la, and these wrappers would not be used. 20# 21# clean: 22# Clean up all the compiled bits. 23# 24PROGS = test1 test2 test3 test4 test5 test6 test7 test8 \ 25 test9 test10 test11 test12 test13 test14 test15 test16 \ 26 test17 test18 test19 test20 test21 test22 test23 test24 \ 27 test25 test26 test27 test28 test29 test30 test31 test32 \ 28 test33 test34 test35 test36 test37 test38 test39 test40 \ 29 test41 test42 test43 test44 test45 test46 test47 test48 \ 30 test49 test50 test51 test52 test53 test54 test55 test56 \ 31 test57 test58 test59 test60 test61 test62 test63 test64 \ 32 test65 test66 test67 test68 test69 test70 test71 test72 \ 33 test73 test74 test75 test76 test77 test78 test79 test80 \ 34 test81 test82 test83 test84 test85 test86 test87 test88 \ 35 test89 test90 test91 test92 test93 test94 test95 test96 \ 36 test97 test98 test99 test100 test101 test102 test103 test104 \ 37 test105 test106 test107 test108 test109 test110 test111 test112 \ 38 test113 test114 test115 test116 test117 test118 test119 test120 \ 39 test121 test122 test123 test124 40 41TPLSRC = ../src 42CFLAGS = -I$(TPLSRC) -g 43CFLAGS += -pedantic 44CFLAGS += -Wall 45#CFLAGS += -m32 46#CFLAGS += -m64 47CFLAGS += -O3 48#For testing without C99 feature support 49#CFLAGS += -std=c89 50 51# Prefer 64-bit compilation on Mac OS X (not necessary, just faster) 52ifneq ($(strip $(shell $(CC) -v 2>&1 |egrep "i[0-9]+-apple-darwin")),) 53 CFLAGS += -m64 54endif 55 56# detect Cygwin or MinGW 57ifneq ($(strip $(shell $(CC) -v 2>&1 |egrep "cygwin|mingw")),) 58 TESTS=./do_tests.cygwin 59 # divert to the alt target; use tpl as a lib for Cygwin/Mingw 60 TARGET=alt 61else 62 TESTS=./do_tests 63 TARGET=$(PROGS) run_tests 64endif 65 66all: $(TARGET) 67 68tpl.o : $(TPLSRC)/tpl.c $(TPLSRC)/tpl.h 69 $(CC) -c $(CFLAGS) $(TPLSRC)/tpl.c 70 71$(PROGS) : tpl.o 72 $(CC) $(CFLAGS) -o $@ $(@).c tpl.o 73 74run_tests: 75 perl $(TESTS) 76 77# This target can be used to compile the tests as dependent on 78# the tpl library (rather than compiling in the tpl source). 79alt: mkalttests run_tests 80 81mkalttests: 82 @$(MAKE) -f Makefile.alt PROGS="$(PROGS)" 83 84.PHONY: clean 85 86clean: 87 rm -f $(PROGS) tpl.o test*.out test*.err test*.exe 88 rm -rf $(PROGS) test*.dSYM 89