Skip to content

Commit

Permalink
Improve Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed Jan 24, 2025
1 parent 9f60749 commit 03a390c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# Set HAVE_WOLFSSL or HAVE_MBEDTLS variable if you want to use WOLFSSL or
# MBEDTLS instead of LIBTOMCRYPT

OBJECTS_O = onvif_simple_server.o device_service.o media_service.o media2_service.o ptz_service.o events_service.o deviceio_service.o fault.o conf.o utils.o log.o ezxml_wrapper.o ezxml/ezxml.o
OBJECTS_O = onvif_simple_server.o device_service.o media_service.o media2_service.o ptz_service.o events_service.o deviceio_service.o fault.o conf.o utils_zlib.o log.o ezxml_wrapper.o ezxml/ezxml.o
OBJECTS_N = onvif_notify_server.o conf.o utils.o log.o ezxml_wrapper.o ezxml/ezxml.o
OBJECTS_W = wsd_simple_server.o utils.o log.o ezxml_wrapper.o ezxml/ezxml.o
ifdef HAVE_WOLFSSL
INCLUDE = -DHAVE_WOLFSSL -Iextras/wolfssl -ffunction-sections -fdata-sections -lrt
LIBS_O = -Wl,--gc-sections extras/wolfssl/src/.libs/libwolfssl.a -lpthread -lrt
LIBS_N = -Wl,--gc-sections extras/wolfssl/src/.libs/libwolfssl.a -lpthread -lrt
INCLUDE = -DHAVE_WOLFSSL -ffunction-sections -fdata-sections
LIBS_O = -Wl,--gc-sections -lwolfssl -lz -lpthread -lrt
LIBS_N = -Wl,--gc-sections -lwolfssl -lpthread -lrt
else
ifdef HAVE_MBEDTLS
INCLUDE = -DHAVE_MBEDTLS -Iextras/mbedtls/include -ffunction-sections -fdata-sections -lrt
LIBS_O = -Wl,--gc-sections extras/mbedtls/library/libmbedcrypto.a -lpthread -lrt
LIBS_N = -Wl,--gc-sections extras/mbedtls/library/libmbedcrypto.a -lpthread -lrt
INCLUDE = -DHAVE_MBEDTLS -ffunction-sections -fdata-sections
LIBS_O = -Wl,--gc-sections -lmbedcrypto -lz -lpthread -lrt
LIBS_N = -Wl,--gc-sections -lmbedcrypto -lpthread -lrt
else
INCLUDE = -Iextras/libtomcrypt/src/headers -ffunction-sections -fdata-sections -lrt
LIBS_O = -Wl,--gc-sections extras/libtomcrypt/libtomcrypt.a -lpthread -lrt
LIBS_N = -Wl,--gc-sections extras/libtomcrypt/libtomcrypt.a -lpthread -lrt
INCLUDE = -ffunction-sections -fdata-sections
LIBS_O = -Wl,--gc-sections -ltomcrypt -lz -lpthread -lrt
LIBS_N = -Wl,--gc-sections -ltomcrypt -lpthread -lrt
endif
endif
LIBS_W = -Wl,--gc-sections

ifdef USE_ZLIB
DUSE_ZLIB = -DUSE_ZLIB
endif

ifeq ($(STRIP), )
STRIP=echo
endif
Expand All @@ -30,6 +34,9 @@ all: onvif_simple_server onvif_notify_server wsd_simple_server
log.o: log.c $(HEADERS)
$(CC) -c $< -std=c99 -fPIC -Os $(INCLUDE) -o $@

utils_zlib.o: utils.c $(HEADERS)
$(CC) -c $< $(DUSE_ZLIB) -fPIC -Os $(INCLUDE) -o $@

%.o: %.c $(HEADERS)
$(CC) -c $< -fPIC -Os $(INCLUDE) -o $@

Expand Down
63 changes: 63 additions & 0 deletions Makefile.static
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Set HAVE_WOLFSSL or HAVE_MBEDTLS variable if you want to use WOLFSSL or
# MBEDTLS instead of LIBTOMCRYPT

OBJECTS_O = onvif_simple_server.o device_service.o media_service.o media2_service.o ptz_service.o events_service.o deviceio_service.o fault.o conf.o utils_zlib.o log.o ezxml_wrapper.o ezxml/ezxml.o
OBJECTS_N = onvif_notify_server.o conf.o utils.o log.o ezxml_wrapper.o ezxml/ezxml.o
OBJECTS_W = wsd_simple_server.o utils.o log.o ezxml_wrapper.o ezxml/ezxml.o
ifdef HAVE_WOLFSSL
INCLUDE = -DHAVE_WOLFSSL -Iextras/wolfssl -Iextras/zlib -ffunction-sections -fdata-sections -lrt
LIBS_O = -Wl,--gc-sections extras/wolfssl/src/.libs/libwolfssl.a extras/zlib/libz.a -lpthread -lrt
LIBS_N = -Wl,--gc-sections extras/wolfssl/src/.libs/libwolfssl.a -lpthread -lrt
else
ifdef HAVE_MBEDTLS
INCLUDE = -DHAVE_MBEDTLS -Iextras/mbedtls/include -Iextras/zlib -ffunction-sections -fdata-sections -lrt
LIBS_O = -Wl,--gc-sections extras/mbedtls/library/libmbedcrypto.a extras/zlib/libz.a -lpthread -lrt
LIBS_N = -Wl,--gc-sections extras/mbedtls/library/libmbedcrypto.a -lpthread -lrt
else
INCLUDE = -Iextras/libtomcrypt/src/headers -Iextras/zlib -ffunction-sections -fdata-sections -lrt
LIBS_O = -Wl,--gc-sections extras/libtomcrypt/libtomcrypt.a extras/zlib/libz.a -lpthread -lrt
LIBS_N = -Wl,--gc-sections extras/libtomcrypt/libtomcrypt.a -lpthread -lrt
endif
endif
LIBS_W = -Wl,--gc-sections

ifdef USE_ZLIB
DUSE_ZLIB = -DUSE_ZLIB
endif

ifeq ($(STRIP), )
STRIP=echo
endif

all: onvif_simple_server onvif_notify_server wsd_simple_server

log.o: log.c $(HEADERS)
$(CC) -c $< -std=c99 -fPIC -Os $(INCLUDE) -o $@

utils_zlib.o: utils.c $(HEADERS)
$(CC) -c $< $(DUSE_ZLIB) -fPIC -Os $(INCLUDE) -o $@

%.o: %.c $(HEADERS)
$(CC) -c $< -fPIC -Os $(INCLUDE) -o $@

onvif_simple_server: $(OBJECTS_O)
$(CC) $(OBJECTS_O) $(LIBS_O) -fPIC -Os -o $@
$(STRIP) $@

onvif_notify_server: $(OBJECTS_N)
$(CC) $(OBJECTS_N) $(LIBS_N) -fPIC -Os -o $@
$(STRIP) $@

wsd_simple_server: $(OBJECTS_W)
$(CC) $(OBJECTS_W) $(LIBS_W) -fPIC -Os -o $@
$(STRIP) $@

.PHONY: clean

clean:
rm -f onvif_simple_server
rm -f onvif_notify_server
rm -f wsd_simple_server
rm -f $(OBJECTS_O)
rm -f $(OBJECTS_N)
rm -f $(OBJECTS_W)

0 comments on commit 03a390c

Please sign in to comment.