| 1 |
IDIR = include |
| 2 |
MKDIR_P = mkdir -p |
| 3 |
CC=gcc |
| 4 |
CFLAGS=-I$(IDIR) -fstack-protector-strong -fPIE -fPIC -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security |
| 5 |
LDFLAGS=-z noexecstack -z relo -z now |
| 6 |
|
| 7 |
ODIR=obj |
| 8 |
OTDIR=objtest |
| 9 |
SRCDIR=safeclib |
| 10 |
TESTDIR=unittests |
| 11 |
|
| 12 |
|
| 13 |
_DEPS = safe_lib_errno.h safe_lib.h safe_str_lib.h safe_types.h.in safe_lib_errno.h.in safe_mem_lib.h safe_types.h |
| 14 |
|
| 15 |
_ODEPS = mem_primitives_lib.h safeclib_private.h safe_mem_constraint.h safe_str_constraint.h |
| 16 |
|
| 17 |
all: directories libsafestring.a safestringtest |
| 18 |
|
| 19 |
|
| 20 |
DEPS = $(addprefix $(IDIR)/,$(_DEPS)) |
| 21 |
ODEPS = $(addprefix $(SRCDIR)/,$(_ODEPS)) |
| 22 |
|
| 23 |
|
| 24 |
_CLIB = abort_handler_s.c stpcpy_s.c strlastsame_s.c ignore_handler_s.c stpncpy_s.c strljustify_s.c memcmp16_s.c strcasecmp_s.c strncat_s.c memcmp32_s.c strcasestr_s.c strncpy_s.c memcmp_s.c strcat_s.c strnlen_s.c memcpy16_s.c strcmpfld_s.c strnterminate_s.c memcpy32_s.c strcmp_s.c strpbrk_s.c memcpy_s.c strcpyfldin_s.c strprefix_s.c memmove16_s.c strcpyfldout_s.c strremovews_s.c memmove32_s.c strcpyfld_s.c strspn_s.c memmove_s.c strcpy_s.c strstr_s.c mem_primitives_lib.c strcspn_s.c strtok_s.c strfirstchar_s.c strtolowercase_s.c memset16_s.c strfirstdiff_s.c strtouppercase_s.c memset32_s.c strfirstsame_s.c strzero_s.c memset_s.c strisalphanumeric_s.c wcpcpy_s.c memzero16_s.c strisascii_s.c wcscat_s.c memzero32_s.c strisdigit_s.c wcscpy_s.c memzero_s.c strishex_s.c wcsncat_s.c strislowercase_s.c wcsncpy_s.c safe_mem_constraint.c strismixedcase_s.c wcsnlen_s.c strispassword_s.c wmemcmp_s.c safe_str_constraint.c strisuppercase_s.c wmemcpy_s.c strlastchar_s.c wmemmove_s.c snprintf_support.c strlastdiff_s.c wmemset_s.c |
| 25 |
|
| 26 |
_TLIST = $(addprefix $(ODIR)/,$(_CLIB)) |
| 27 |
OBJ = $(patsubst %.c,%.o,$(_TLIST)) |
| 28 |
CLIB =$(addprefix $(SRCDIR)/,$(_CLIB)) |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
$(ODIR)/%.o: $(SRCDIR)/%.c $(DEPS) $(ODEPS) |
| 33 |
$(CC) $(LDFLAGS) -c -o $@ $< $(CFLAGS) |
| 34 |
|
| 35 |
libsafestring.a: $(OBJ) |
| 36 |
ar rcs $@ $^ |
| 37 |
|
| 38 |
|
| 39 |
_TESTFUNCS = Safe_String_UnitTestMain.c test_strcmp_s.c test_strnlen_s.c test_memcmp16_s.c test_strcpyfldin_s.c test_strnterminate_s.c test_memcmp32_s.c test_strcpyfldout_s.c test_strpbrk_s.c test_memcmp_s.c test_strcpyfld_s.c test_strprefix_s.c test_memcpy16_s.c test_strcpy_s.c test_strremovews_s.c test_memcpy32_s.c test_strcspn_s.c test_strspn_s.c test_memcpy_s.c test_strfirstchar_s.c test_strstr_s.c test_memmove16_s.c test_strfirstdiff_s.c test_strtok_s.c test_memmove32_s.c test_strfirstsame_s.c test_strtolowercase_s.c test_memmove_s.c test_strisalphanumeric_s.c test_strtouppercase_s.c test_memset16_s.c test_strisascii_s.c test_strzero_s.c test_memset32_s.c test_strisdigit_s.c test_wcpcpy_s.c test_memset_s.c test_strishex_s.c test_wcscat_s.c test_memzero16_s.c test_strislowercase_s.c test_wcscpy_s.c test_memzero32_s.c test_strismixed_s.c test_wcsncat_s.c test_memzero_s.c test_strispassword_s.c test_wcsncpy_s.c test_strisuppercase_s.c test_wcsnlen_s.c test_stpcpy_s.c test_strlastchar_s.c test_wmemcmp_s.c test_stpncpy_s.c test_strlastdiff_s.c test_wmemcpy_s.c test_strcasecmp_s.c test_strlastsame_s.c test_wmemmove_s.c test_strcasestr_s.c test_strljustify_s.c test_wmemset_s.c test_strcat_s.c test_strncat_s.c test_strcmpfld_s.c test_strncpy_s.c |
| 40 |
|
| 41 |
_TLIST2 = $(addprefix $(OTDIR)/,$(_TESTFUNCS)) |
| 42 |
TOBJ = $(patsubst %.c,%.o,$(_TLIST2)) |
| 43 |
TCLIB =$(addprefix $(TESTDIR)/,$(_TESTFUNCS)) |
| 44 |
|
| 45 |
|
| 46 |
$(OTDIR)/%.o: $(TESTDIR)/%.c $(TESTDIR)/test_private.h |
| 47 |
$(CC) -c -o $@ $< $(CFLAGS) |
| 48 |
|
| 49 |
|
| 50 |
safestringtest: directories libsafestring.a $(TOBJ) |
| 51 |
$(CC) $(LDFLAGS) -static -o $@ $(TOBJ) libsafestring.a |
| 52 |
|
| 53 |
|
| 54 |
.PHONY: directories |
| 55 |
|
| 56 |
directories: ${ODIR} ${OTDIR} |
| 57 |
|
| 58 |
${ODIR}: |
| 59 |
${MKDIR_P} ${ODIR} |
| 60 |
|
| 61 |
${OTDIR}: |
| 62 |
${MKDIR_P} ${OTDIR} |
| 63 |
|
| 64 |
.PHONY: clean |
| 65 |
|
| 66 |
clean: |
| 67 |
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ $(OTDIR)/*.o |
| 68 |
rm -f libsafestring.a |
| 69 |
rm -f safestringtest |