Makefile (6239B)
1 MACHINE := $(shell uname -m) 2 _FORTIFY_SOURCE ?= 3 3 CFLAGS ?= -std=gnu99 4 COMMON_FLAGS += -I../include/ -D_FORTIFY_SOURCE=$(_FORTIFY_SOURCE) -static -O2 -Wall -Wextra -Werror -Werror=pointer-arith 5 COMMON_FLAGS += -Wno-format -Wno-array-bounds -Wno-shift-count-negative -Wno-unused-variable -Wno-unused-parameter 6 7 RUNTIME_TARGETS= \ 8 test_FD_CLR_SETSIZE \ 9 test_FD_CLR_negative \ 10 test_FD_SET_SETSIZE \ 11 test_FD_SET_negative \ 12 test_bcopy_dynamic_read \ 13 test_bcopy_dynamic_write \ 14 test_bcopy_static_read \ 15 test_bcopy_static_write \ 16 test_bzero_dynamic_write \ 17 test_bzero_static_write \ 18 test_compile \ 19 test_confstr_dynamic \ 20 test_confstr_static \ 21 test_fgets_dynamic \ 22 test_fgets_static \ 23 test_fgetws_dynamic \ 24 test_fgetws_static \ 25 test_fread_int_overflow \ 26 test_fread_overwrite_dynamic \ 27 test_fread_overwrite_static \ 28 test_fwrite_int_overflow \ 29 test_fwrite_overwrite_dynamic \ 30 test_fwrite_overwrite_static \ 31 test_getcwd_dynamic \ 32 test_getcwd_static \ 33 test_getdomainname_dynamic \ 34 test_getdomainname_static \ 35 test_getgroups_dynamic \ 36 test_getgroups_static \ 37 test_gethostname_dynamic \ 38 test_gethostname_static \ 39 test_getlogin_r_dynamic \ 40 test_getlogin_r_static \ 41 test_memcpy_dynamic_read \ 42 test_memcpy_dynamic_write \ 43 test_memcpy_overlap \ 44 test_memcpy_static_read \ 45 test_memcpy_static_write \ 46 test_memmove_dynamic_read \ 47 test_memmove_dynamic_write \ 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_static_write \ 56 test_mbsnrtowcs_dynamic \ 57 test_mbsnrtowcs_static \ 58 test_mbsrtowcs_dynamic \ 59 test_mbsrtowcs_static \ 60 test_mbstowcs_dynamic \ 61 test_mbstowcs_static \ 62 test_poll_dynamic \ 63 test_poll_static \ 64 test_ppoll_dynamic \ 65 test_ppoll_static \ 66 test_pread_dynamic \ 67 test_pread_static \ 68 test_read_dynamic \ 69 test_read_static \ 70 test_readlink_dynamic \ 71 test_readlink_static \ 72 test_readlinkat_dynamic \ 73 test_readlinkat_static \ 74 test_realpath_null \ 75 test_realpath \ 76 test_recv_dynamic \ 77 test_recv_static \ 78 test_recvfrom_dynamic \ 79 test_recvfrom_static \ 80 test_send_dynamic \ 81 test_send_static \ 82 test_sendto_dynamic \ 83 test_sendto_static \ 84 test_snprintf_dynamic \ 85 test_snprintf_static \ 86 test_sprintf \ 87 test_sprintf_62 \ 88 test_stpcpy_dynamic_write \ 89 test_stpcpy_static_write \ 90 test_stpncpy_dynamic_write \ 91 test_stpncpy_static_write \ 92 test_strcat_dynamic_write \ 93 test_strcat_static_write \ 94 test_strcpy_dynamic_write \ 95 test_strcpy_static_write \ 96 test_strlcat_dynamic_write \ 97 test_strlcat_static_write \ 98 test_strlcpy_dynamic_write \ 99 test_strlcpy_static_write \ 100 test_strncat_dynamic_write \ 101 test_strncat_n_eq_buf \ 102 test_strncat_n_gt_buf \ 103 test_strncat_n_lt_buf \ 104 test_strncat_n_one \ 105 test_strncat_safe \ 106 test_strncat_static_write \ 107 test_strncpy_dynamic_write \ 108 test_strncpy_static_write \ 109 test_swab_dynamic_read \ 110 test_swab_dynamic_write \ 111 test_swab_negative \ 112 test_swab_static_read \ 113 test_swab_static_write \ 114 test_ttyname_r_dynamic \ 115 test_ttyname_r_static \ 116 test_vsnprintf_dynamic \ 117 test_vsnprintf_static \ 118 test_vsprintf \ 119 test_wcrtomb \ 120 test_wcsnrtombs_dynamic \ 121 test_wcsnrtombs_static \ 122 test_wcscat_dynamic_write \ 123 test_wcscat_static_write \ 124 test_wcscpy_dynamic_write \ 125 test_wcscpy_static_write \ 126 test_wcsncat_dynamic_write \ 127 test_wcsncat_n_eq_buf \ 128 test_wcsncat_n_gt_buf \ 129 test_wcsncat_n_lt_buf \ 130 test_wcsncat_n_one \ 131 test_wcsncat_safe \ 132 test_wcsncat_static_write \ 133 test_wcsncpy_dynamic_write \ 134 test_wcsncpy_static_write \ 135 test_wcsrtombs_dynamic \ 136 test_wcsrtombs_static \ 137 test_wcstombs_dynamic \ 138 test_wcstombs_static \ 139 test_wmemcpy_dynamic_read \ 140 test_wmemcpy_dynamic_write \ 141 test_wmemcpy_static_read \ 142 test_wmemcpy_static_write \ 143 test_wmemmove_dynamic_read \ 144 test_wmemmove_dynamic_write \ 145 test_wmemmove_static_read \ 146 test_wmemmove_static_write \ 147 test_wmemset_dynamic \ 148 test_wmemset_static \ 149 test_write_dynamic \ 150 test_write_static \ 151 152 gcc: CC=../$(MACHINE)-linux-musl-native/bin/gcc 153 gcc: CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow -ffreestanding 154 gcc: $(RUNTIME_TARGETS) 155 156 clang: CC=clang 157 clang: CFLAGS+=-I/usr/include/$(MACHINE)-linux-musl 158 clang: CFLAGS+=-I../$(MACHINE)-linux-musl-native/include/ 159 clang: CFLAGS+=-I$(MACHINE)-linux-musl-native/include/ 160 clang: CFLAGS+=-nostdinc 161 clang: CXX=clang++ 162 clang: CXXFLAGS+=-I/usr/include/$(MACHINE)-linux-musl 163 clang: CXXFLAGS+=-I../$(MACHINE)-linux-musl-native/include/ 164 clang: CXXFLAGS+=-I$(MACHINE)-linux-musl-native/include/ 165 clang: CXXFLAGS+=-nostdinc -Wno-fortify-source 166 clang: $(RUNTIME_TARGETS) cpp 167 168 all: gcc 169 170 171 $(RUNTIME_TARGETS): %: %.c 172 $(CC) $(COMMON_FLAGS) $(CFLAGS) -o $@ $< 173 174 cpp: test_compile.cc 175 $(CXX) $(COMMON_FLAGS) $(CXXFLAGS) test_compile.cc -o ./test_compile_cc 176 timeout 1s ./test_compile_cc 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ 177 178 run: $(RUNTIME_TARGETS) 179 $(foreach EXE, $(RUNTIME_TARGETS), \ 180 timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \ 181 ) 182 183 clean: 184 $(foreach EXE, $(RUNTIME_TARGETS), \ 185 rm -f ./$(EXE) \ 186 ) 187 rm -f ./test_compile_cc 188