Makefile (4807B)
1 MACHINE := $(shell uname -m) 2 CFLAGS ?= -std=gnu99 3 CFLAGS += -I../include/ -D_FORTIFY_SOURCE=3 -static -O2 -Wall -Wextra -Werror -Werror=pointer-arith 4 CFLAGS += -Wno-format -Wno-array-bounds -Wno-shift-count-negative -Wno-unused-variable -Wno-unused-parameter 5 6 RUNTIME_TARGETS= \ 7 test_FD_CLR_SETSIZE \ 8 test_FD_CLR_negative \ 9 test_FD_SET_SETSIZE \ 10 test_FD_SET_negative \ 11 test_bcopy_dynamic_read \ 12 test_bcopy_dynamic_write \ 13 test_bcopy_static_read \ 14 test_bcopy_static_write \ 15 test_bzero_dynamic_write \ 16 test_bzero_static_write \ 17 test_compile \ 18 test_confstr_dynamic \ 19 test_fgets_dynamic \ 20 test_fgets_static \ 21 test_fgetws_dynamic \ 22 test_fgetws_static \ 23 test_fread_int_overflow \ 24 test_fread_overwrite_dynamic \ 25 test_fread_overwrite_static \ 26 test_fwrite_int_overflow \ 27 test_fwrite_overwrite_dynamic \ 28 test_fwrite_overwrite_static \ 29 test_getcwd_dynamic \ 30 test_getcwd_static \ 31 test_getdomainname_dynamic \ 32 test_getdomainname_static \ 33 test_getgroups_dynamic \ 34 test_getgroups_static \ 35 test_gethostname_dynamic \ 36 test_gethostname_static \ 37 test_getlogin_r_dynamic \ 38 test_getlogin_r_static \ 39 test_memcpy_dynamic_read \ 40 test_memcpy_dynamic_write \ 41 test_memcpy_null_dst \ 42 test_memcpy_null_src \ 43 test_memcpy_static_read \ 44 test_memmove_dynamic_read \ 45 test_memmove_dynamic_write \ 46 test_memmove_null_dst \ 47 test_memmove_null_src \ 48 test_memmove_static_read \ 49 test_memmove_static_write \ 50 test_mempcpy_dynamic_read \ 51 test_mempcpy_dynamic_write \ 52 test_mempcpy_static_read \ 53 test_mempcpy_static_write \ 54 test_memset_dynamic_write \ 55 test_memset_null \ 56 test_memset_static_write \ 57 test_poll_dynamic \ 58 test_poll_static \ 59 test_ppoll_dynamic \ 60 test_ppoll_static \ 61 test_read_dynamic \ 62 test_read_static \ 63 test_readlink_dynamic \ 64 test_readlink_static \ 65 test_recv_dynamic \ 66 test_recv_static \ 67 test_recvfrom_dynamic \ 68 test_recvfrom_static \ 69 test_send_dynamic \ 70 test_send_static \ 71 test_sendto_dynamic \ 72 test_sendto_static \ 73 test_sprintf \ 74 test_sprintf_62 \ 75 test_stpcpy_dynamic_write \ 76 test_stpcpy_static_write \ 77 test_stpncpy_dynamic_write \ 78 test_stpncpy_static_write \ 79 test_strcat_static_write \ 80 test_strcpy_dynamic_write \ 81 test_strcpy_static_write \ 82 test_strlcat_dynamic_write \ 83 test_strlcat_static_write \ 84 test_strlcpy_dynamic_write \ 85 test_strlcpy_static_write \ 86 test_strncat_dynamic_write \ 87 test_strncat_static_write \ 88 test_strncpy_dynamic_write \ 89 test_strncpy_static_write \ 90 test_swab_dynamic_read \ 91 test_swab_dynamic_write \ 92 test_swab_static_read \ 93 test_ttyname_r_dynamic \ 94 test_ttyname_r_static \ 95 test_vsnprintf_dynamic \ 96 test_vsnprintf_static \ 97 test_vsprintf \ 98 test_wcscat_static_write \ 99 test_wcscpy_static_write \ 100 test_wcsncat_static_write \ 101 test_wcsncpy_static_write \ 102 test_wmemcpy_dynamic_write \ 103 test_wmemcpy_static_write \ 104 test_wmemmove_dynamic_write \ 105 test_wmemmove_static_write \ 106 test_wmemset_dynamic \ 107 test_wmemset_static \ 108 test_write_dynamic \ 109 test_write_static \ 110 111 gcc: CC=../$(MACHINE)-linux-musl-native/bin/gcc 112 gcc: CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow -ffreestanding 113 gcc: $(RUNTIME_TARGETS) 114 115 clang: CC=clang 116 clang: CFLAGS+=-I/usr/include/$(MACHINE)-linux-musl 117 clang: CFLAGS+=-I../$(MACHINE)-linux-musl-native/include/ 118 clang: CFLAGS+=-I$(MACHINE)-linux-musl-native/include/ 119 clang: CFLAGS+=-nostdinc 120 clang: CXX=clang++ 121 clang: CXXFLAGS+=-I/usr/include/$(MACHINE)-linux-musl 122 clang: CXXFLAGS+=-I../$(MACHINE)-linux-musl-native/include/ 123 clang: CXXFLAGS+=-I$(MACHINE)-linux-musl-native/include/ 124 clang: CXXFLAGS+=-nostdinc 125 clang: $(RUNTIME_TARGETS) cpp 126 127 all: gcc 128 129 130 $(RUNTIME_TARGETS): %: %.c 131 $(CC) $(CFLAGS) -o $@ $< 132 133 cpp: test_compile.cc 134 $(CXX) $(CXXFLAGS) test_compile.cc -o ./test_compile_cc 135 timeout 1s ./test_compile_cc 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ 136 137 run: $(RUNTIME_TARGETS) 138 $(foreach EXE, $(RUNTIME_TARGETS), \ 139 timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ 140 ) 141 142 clean: 143 $(foreach EXE, $(RUNTIME_TARGETS), \ 144 rm -f ./$(EXE) \ 145 ) 146 rm -f ./test_compile_cc 147