fortify-headers

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

Makefile (5975B)


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