1# 2# $FreeBSD: releng/10.3/lib/libkse/test/Makefile 125468 2004-02-05 02:55:20Z davidxu $ 3# 4# Automated test suite for libpthread (pthreads). 5# 6 7# File lists. 8 9# Tests written in C. 10CTESTS := hello_d.c hello_s.c join_leak_d.c mutex_d.c sem_d.c sigsuspend_d.c \ 11 sigwait_d.c 12 13# C programs that are used internally by the tests. The build system merely 14# compiles these. 15BTESTS := guard_b.c hello_b.c 16 17# Tests written in perl. 18PTESTS := guard_s.pl propagate_s.pl 19 20# Munge the file lists to their final executable names (strip the .c). 21CTESTS := $(CTESTS:R) 22BTESTS := $(BTESTS:R) 23 24CPPFLAGS := -D_LIBC_R_ -D_REENTRANT 25CFLAGS := -Wall -pipe -g3 26LDFLAGS_A := -static 27LDFLAGS_P := -pg 28LDFLAGS_S := 29LIBS := -lpthread 30 31# Flags passed to verify. "-v" or "-u" may be useful. 32VERIFY = perl verify 33VFLAGS := 34 35all : default 36 37# Only use the following suffixes, in order to avoid any strange built-in rules. 38.SUFFIXES : 39.SUFFIXES : .c .o .d .pl 40 41# Clear out all paths, then set just one (default path) for the main build 42# directory. 43.PATH : 44.PATH : . 45 46# Build the C programs. 47.for bin in $(CTESTS) $(BTESTS) 48$(bin)_a : $(bin:S/$/&.c/) 49 $(CC) $(CFLAGS) $(CPPFLAGS) -c $(bin:S/$/&.c/) -o $(@:S/$/&.o/) 50 $(CC) -o $@ $(@:S/$/&.o/) $(LDFLAGS_A) $(LIBS) 51 @$(SHELL) -ec "$(CC) -M $(CPPFLAGS) $(bin:S/$/&.c/) | sed \"s/\($(bin:T)\)\.o\([ :]*\)/$(bin:H:S!/!\\/!g)\/\1_a.o \2/g\" > $(@:R:S/$/&.d/)" 52 53$(bin)_p : $(bin:S/$/&.c/) 54 $(CC) $(CFLAGS) $(CPPFLAGS) -c $(bin:S/$/&.c/) -o $(@:S/$/&.o/) 55 $(CC) -o $@ $(@:S/$/&.o/) $(LDFLAGS_P) $(LIBS) 56 @$(SHELL) -ec "$(CC) -M $(CPPFLAGS) $(bin:S/$/&.c/) | sed \"s/\($(bin:T)\)\.o\([ :]*\)/$(bin:H:S!/!\\/!g)\/\1_p.o \2/g\" > $(@:R:S/$/&.d/)" 57 58$(bin)_s : $(bin:S/$/&.c/) 59 $(CC) $(CFLAGS) $(CPPFLAGS) -c $(bin:S/$/&.c/) -o $(@:S/$/&.o/) 60 $(CC) -o $@ $(@:S/$/&.o/) $(LDFLAGS_S) $(LIBS) 61 @$(SHELL) -ec "$(CC) -M $(CPPFLAGS) $(bin:S/$/&.c/) | sed \"s/\($(bin:T)\)\.o\([ :]*\)/$(bin:H:S!/!\\/!g)\/\1_s.o \2/g\" > $(@:R:S/$/&.d/)" 62.endfor 63 64# Dependency file inclusion. 65.for depfile in $(CTESTS:R:S/$/&_a.d/) $(BTESTS:R:S/$/&_a.d/) \ 66 $(CTESTS:R:S/$/&_p.d/) $(BTESTS:R:S/$/&_p.d/) \ 67 $(CTESTS:R:S/$/&_s.d/) $(BTESTS:R:S/$/&_s.d/) 68.if exists($(depfile)) 69.include "$(depfile)" 70.endif 71.endfor 72 73default : check 74 75tests_a : $(CTESTS:S/$/&_a/) $(BTESTS:S/$/&_a/) 76tests_p : $(CTESTS:S/$/&_p/) $(BTESTS:S/$/&_p/) 77tests_s : $(CTESTS:S/$/&_s/) $(BTESTS:S/$/&_s/) 78 79tests : tests_a tests_p tests_s 80 81check_a : tests_a 82.for bin in $(CTESTS) $(BTESTS) 83 @cp $(bin)_a $(bin) 84.endfor 85 @echo "Test static library:" 86 @$(VERIFY) $(VFLAGS) $(CTESTS) $(PTESTS) 87 88check_p : tests_p 89.for bin in $(CTESTS) $(BTESTS) 90 @cp $(bin)_p $(bin) 91.endfor 92 @echo "Test profile library:" 93 @$(VERIFY) $(VFLAGS) $(CTESTS) $(PTESTS) 94 95check_s : tests_s 96.for bin in $(CTESTS) $(BTESTS) 97 @cp $(bin)_s $(bin) 98.endfor 99 @echo "Test shared library:" 100 @$(VERIFY) $(VFLAGS) $(CTESTS) $(PTESTS) 101 102check : check_a check_p check_s 103 104clean : 105 rm -f *~ 106 rm -f *.core 107 rm -f *.out 108 rm -f *.perf 109 rm -f *.diff 110 rm -f *.gmon 111 rm -f $(CTESTS) $(BTESTS) 112 rm -f $(CTESTS:S/$/&_a/) $(BTESTS:S/$/&_a/) 113 rm -f $(CTESTS:S/$/&_p/) $(BTESTS:S/$/&_p/) 114 rm -f $(CTESTS:S/$/&_s/) $(BTESTS:S/$/&_s/) 115 rm -f *.d 116 rm -f *.o 117