fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

Makefile (5817B)


      1 CFLAGS+=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2
      2 
      3 COMPTIME_TARGETS= \
      4 	test_memcpy_overwrite_under  \
      5 	test_memcpy_static_write     \
      6 
      7 
      8 RUNTIME_TARGETS= \
      9 	test_FD_CLR_SETSIZE          \
     10 	test_FD_CLR_negative         \
     11 	test_FD_SET_SETSIZE          \
     12 	test_FD_SET_negative         \
     13 	test_FD_ISSET_SETSIZE        \
     14 	test_FD_ISSET_negative       \
     15 	test_bcopy_dynamic_read      \
     16 	test_bcopy_dynamic_write     \
     17 	test_bcopy_static_read       \
     18 	test_bcopy_static_write      \
     19 	test_bzero_dynamic_write     \
     20 	test_bzero_static_write      \
     21 	test_compile                 \
     22 	test_confstr_dynamic         \
     23 	test_confstr_static          \
     24 	test_fgets_dynamic           \
     25 	test_fgets_static            \
     26 	test_fgetws_dynamic          \
     27 	test_fgetws_static           \
     28 	test_fprintf                 \
     29 	test_fread_int_overflow      \
     30 	test_fread_overwrite_dynamic \
     31 	test_fread_overwrite_static  \
     32 	test_fwrite_int_overflow     \
     33 	test_fwrite_overwrite_dynamic \
     34 	test_fwrite_overwrite_static \
     35 	test_getcwd_dynamic          \
     36 	test_getcwd_static           \
     37 	test_getdomainname_dynamic   \
     38 	test_getdomainname_static    \
     39 	test_getgroups_dynamic       \
     40 	test_getgroups_static        \
     41 	test_gethostname_dynamic     \
     42 	test_gethostname_static      \
     43 	test_getlogin_r_dynamic      \
     44 	test_getlogin_r_static       \
     45 	test_mbsrtowcs_dynamic       \
     46 	test_mbsrtowcs_static        \
     47 	test_mbstowcs_dynamic        \
     48 	test_mbstowcs_static         \
     49 	test_memchr_dynamic_read     \
     50 	test_memchr_static_read      \
     51 	test_memchr_null             \
     52 	test_memcpy_dynamic_read     \
     53 	test_memcpy_dynamic_write    \
     54 	test_memcpy_overwrite_over   \
     55 	test_memcpy_static_read      \
     56 	test_memcpy_null_src         \
     57 	test_memcpy_null_dst         \
     58 	test_memmove_null_src        \
     59 	test_memmove_null_dst        \
     60 	test_memmove_dynamic_read    \
     61 	test_memmove_dynamic_write   \
     62 	test_memmove_static_read     \
     63 	test_memmove_static_write    \
     64 	test_mempcpy_dynamic_read    \
     65 	test_mempcpy_dynamic_write   \
     66 	test_mempcpy_static_read     \
     67 	test_mempcpy_static_write    \
     68 	test_memset_dynamic_write    \
     69 	test_memset_static_write     \
     70 	test_memset_null             \
     71 	test_poll_dynamic            \
     72 	test_poll_static             \
     73 	test_ppoll_dynamic           \
     74 	test_ppoll_static            \
     75 	test_pread_dynamic           \
     76 	test_pread_static            \
     77 	test_printf                  \
     78 	test_pwrite_dynamic          \
     79 	test_pwrite_static           \
     80 	test_qsort_dynamic           \
     81 	test_qsort_static            \
     82 	test_read_dynamic            \
     83 	test_read_static             \
     84 	test_readlink_dynamic        \
     85 	test_readlink_static         \
     86 	test_recv_dynamic            \
     87 	test_recv_static             \
     88 	test_recvfrom_dynamic        \
     89 	test_recvfrom_static         \
     90 	test_select_dynamic          \
     91 	test_select_static           \
     92 	test_send_dynamic            \
     93 	test_send_static             \
     94 	test_sendto_dynamic          \
     95 	test_sendto_static           \
     96 	test_stpcpy_dynamic_write    \
     97 	test_stpcpy_overwrite_over   \
     98 	test_stpcpy_overwrite_under  \
     99 	test_stpcpy_static_write     \
    100 	test_stpncpy_dynamic_write   \
    101 	test_stpncpy_overwrite_over  \
    102 	test_stpncpy_overwrite_under \
    103 	test_stpncpy_static_write    \
    104 	test_strlen_static_read      \
    105 	test_strcat_static_write     \
    106 	test_strchr_dynamic_read     \
    107 	test_strchr_static_read      \
    108 	test_strcpy_dynamic_write    \
    109 	test_strcpy_overwrite_over   \
    110 	test_strcpy_overwrite_under  \
    111 	test_strcpy_static_write     \
    112 	test_strlcat_dynamic_write   \
    113 	test_strlcat_static_write    \
    114 	test_strlcpy_dynamic_write   \
    115 	test_strlcpy_static_write    \
    116 	test_strncat_dynamic_write   \
    117 	test_strncat_static_write    \
    118 	test_strncpy_dynamic_write   \
    119 	test_strncpy_overwrite_over  \
    120 	test_strncpy_overwrite_under \
    121 	test_strncpy_static_write    \
    122 	test_strrchr_dynamic_read    \
    123 	test_strrchr_static_read     \
    124 	test_ttyname_r_dynamic       \
    125 	test_ttyname_r_static        \
    126 	test_umask                   \
    127 	test_vsnprintf_dynamic       \
    128 	test_vsnprintf_static        \
    129 	test_vsprintf                \
    130 	test_vfprintf                \
    131 	test_vprintf                 \
    132 	test_wcscat_static_write     \
    133 	test_wcscpy_static_write     \
    134 	test_wcsncat_static_write    \
    135 	test_wcsncpy_static_write    \
    136 	test_wmemcpy_dynamic_write   \
    137 	test_wmemcpy_static_write    \
    138 	test_wmemmove_dynamic_write  \
    139 	test_wmemmove_static_write   \
    140 	test_wmemset_dynamic         \
    141 	test_wmemset_static          \
    142 	test_write_dynamic           \
    143 	test_write_static            \
    144 
    145 .SILENT:
    146 
    147 gcc: CC=../x86_64-linux-musl-native/bin/gcc
    148 gcc: $(RUNTIME_TARGETS)
    149 
    150 clang: CC=clang
    151 clang: CFLAGS+=-I/usr/include/x86_64-linux-musl
    152 clang: CFLAGS+=-I../x86_64-linux-musl-native/include/
    153 clang: CFLAGS+=-Ix86_64-linux-musl-native/include/
    154 clang: CFLAGS+=-nostdinc
    155 clang: comptime $(RUNTIME_TARGETS)
    156 
    157 coverage: CFLAGS += -fprofile-arcs -ftest-coverage
    158 coverage: CC=../x86_64-linux-musl-native/bin/gcc
    159 coverage: GCOV=../x86_64-linux-musl-native/bin/gcov
    160 coverage: $(RUNTIME_TARGETS) run
    161 	$(GCOV) *.c
    162 	lcov --capture --directory . --output-file coverage.info
    163 	lcov --remove ./coverage.info "*/tests/*" --output-file cleaned-coverage.info
    164 	genhtml cleaned-coverage.info --output-directory coverage
    165 
    166 all: gcc
    167 
    168 
    169 $(RUNTIME_TARGETS): %: %.c
    170 	$(CC) $(CFLAGS) -o $@ $<
    171 
    172 run: $(RUNTIME_TARGETS)
    173 	$(foreach EXE, $(RUNTIME_TARGETS), \
    174 		timeout 1s ./$(EXE) 1234567890 2 3 4 5 6 7 8 9 0 >/dev/null && echo "$(EXE) OK" || echo "$(EXE) FAIL"; \
    175 	)
    176 
    177 comptime:  # only works on clang, as gcc doesn't have the diagnose_if attribute
    178 	$(foreach EXE, $(COMPTIME_TARGETS), \
    179 		($(CC) $(CFLAGS) -o ./$(EXE) ./$(EXE).c 1>/dev/null 2>/dev/null && echo "$(EXE) FAIL" || echo "$(EXE) OK") || true ;\
    180 	)
    181 
    182 clean:
    183 	$(foreach EXE, $(RUNTIME_TARGETS) $(COMPTIME_TARGETS), \
    184 		rm -f ./$(EXE) \
    185 	)
    186 	rm -rf ./*.gcno ./*.gcda ./*.gcov ./coverage.info ./coverage
    187