Split libs with make + general make cleanups

parent 8d4a613c
......@@ -4,20 +4,23 @@ PREFIX=mbedtls_
.SILENT:
all: programs tests
.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
no_test: programs
all: programs tests
programs: lib
no_test: programs
programs:
$(MAKE) -C programs
lib:
$(MAKE) -C library
tests: lib
tests:
$(MAKE) -C tests
install:
ifndef WINDOWS
install: all
mkdir -p $(DESTDIR)/include/mbedtls
cp -r include/mbedtls $(DESTDIR)/include
......@@ -46,21 +49,24 @@ uninstall:
rm -f $(DESTDIR)/bin/$$o ; \
fi \
done
endif
clean:
$(MAKE) -C library clean
$(MAKE) -C programs clean
$(MAKE) -C tests clean
ifndef WINDOWS
find . \( -name \*.gcno -o -name \*.gcda -o -name *.info \) -exec rm {} +
endif
check: tests
ifndef WINDOWS
check:
$(MAKE) -C tests check
test-ref-configs:
tests/scripts/test-ref-configs.pl
test: check
# note: for coverage testing, build with:
# CFLAGS='--coverage' make OFLAGS='-g3 -O0'
# make CFLAGS='--coverage -g3 -O0'
covtest:
make check
programs/test/selftest
......@@ -82,7 +88,5 @@ apidoc:
doxygen doxygen/mbedtls.doxyfile
apidoc_clean:
if [ -d apidoc ] ; \
then \
rm -rf apidoc ; \
fi
rm -rf apidoc
endif
......@@ -35,7 +35,7 @@ In order to run the tests, enter::
make check
In order to build for a Windows platform, you should use WINDOWS_BUILD=1 if the target is Windows but the build environment is Unix-like (eg when cross-compiling, or compiling from an MSYS shell), and WINDOWS=1 if the build environment is a Windows shell.
In order to build for a Windows platform, you should use WINDOWS_BUILD=1 if the target is Windows but the build environment is Unix-like (eg when cross-compiling, or compiling from an MSYS shell), and WINDOWS=1 if the build environment is a Windows shell (in that case some targets will not be available).
Setting the variable SHARED in your environment will build a shared library in addition to the static library. Setting DEBUG gives you a debug build. You can override CFLAGS and LDFLAGS by setting them in your environment or on the make command line; if you do so, essential parts such as -I will still be preserved. Warning options may be overridden separately using WARNING_CFLAGS.
......
*.o
libmbedtls.*
libmbed*
*.sln
*.vcxproj
......@@ -74,37 +74,86 @@ OBJS=$(OBJS_CRYPTO) $(OBJS_X509) $(OBJS_TLS)
.SILENT:
.PHONY: all static shared clean
ifndef SHARED
all: static
else
all: shared static
endif
static: libmbedtls.a
static: libmbedcrypto.a libmbedx509.a libmbedtls.a
shared: libmbedtls.$(DLEXT)
shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT)
libmbedtls.a: $(OBJS)
# tls
libmbedtls.a: $(OBJS_TLS)
echo " AR $@"
$(AR) rc $@ $(OBJS)
$(AR) rc $@ $(OBJS_TLS)
echo " RL $@"
$(AR) s $@
libmbedtls.$(SOEXT): $(OBJS)
libmbedtls.$(SOEXT): $(OBJS_TLS)
echo " LD $@"
$(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS)
$(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
libmbedtls.so: libmbedtls.$(SOEXT)
echo " LN $@ -> libmbedtls.$(SOEXT)"
ln -sf libmbedtls.$(SOEXT) $@
libmbedtls.dylib: $(OBJS)
libmbedtls.dylib: $(OBJS_TLS)
echo " LD $@"
$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_TLS)
libmbedtls.dll: $(OBJS_TLS)
echo " LD $@"
$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_TLS) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
# x509
libmbedx509.a: $(OBJS_X509)
echo " AR $@"
$(AR) rc $@ $(OBJS_X509)
echo " RL $@"
$(AR) s $@
libmbedx509.$(SOEXT): $(OBJS_X509)
echo " LD $@"
$(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
libmbedx509.so: libmbedx509.$(SOEXT)
echo " LN $@ -> libmbedx509.$(SOEXT)"
ln -sf libmbedx509.$(SOEXT) $@
libmbedx509.dylib: $(OBJS_X509)
echo " LD $@"
$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
libmbedx509.dll: $(OBJS_X509)
echo " LD $@"
$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS)
$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
libmbedtls.dll: $(OBJS)
# crypto
libmbedcrypto.a: $(OBJS_CRYPTO)
echo " AR $@"
$(AR) rc $@ $(OBJS_CRYPTO)
echo " RL $@"
$(AR) s $@
libmbedcrypto.$(SOEXT): $(OBJS_CRYPTO)
echo " LD $@"
$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
$(CC) -shared -Wl,-soname,$@ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
libmbedcrypto.so: libmbedcrypto.$(SOEXT)
echo " LN $@ -> libmbedcrypto.$(SOEXT)"
ln -sf libmbedcrypto.$(SOEXT) $@
libmbedcrypto.dylib: $(OBJS_CRYPTO)
echo " LD $@"
$(CC) -dynamiclib $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_CRYPTO)
libmbedcrypto.dll: $(OBJS_CRYPTO)
echo " LD $@"
$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_CRYPTO) -lws2_32 -lwinmm -lgdi32 $(LOCAL_LDFLAGS) $(LDFLAGS)
.c.o:
echo " CC $<"
......@@ -112,8 +161,7 @@ libmbedtls.dll: $(OBJS)
clean:
ifndef WINDOWS
rm -f *.o libmbedtls.*
endif
ifdef WINDOWS
del /Q /F *.o libmbedtls.*
rm -f *.o libmbed*
else
del /Q /F *.o libmbed*
endif
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment