Makefile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2020 Timotej Šiškovič
  2. # SPDX-License-Identifier: GPL-3.0-only
  3. #
  4. # This program is free software: you can redistribute it and/or modify it
  5. # under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
  6. #
  7. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  8. # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with this program.
  12. # If not, see <https://www.gnu.org/licenses/>.
  13. CC = gcc -std=gnu99
  14. CFLAGS = -Wextra -Wall `pkg-config --cflags openssl` `pkg-config --cflags libcrypto`
  15. BUILD_DIR = build
  16. INCLUDES = -Isrc/include -Ic-rbuf/include -Ic_rhash/include -Imqtt/include
  17. all: test
  18. $(BUILD_DIR)/c_rhash.o: c_rhash/src/c_rhash.c c_rhash/src/c_rhash_internal.h c_rhash/include/c_rhash.h
  19. $(CC) -o $(BUILD_DIR)/c_rhash.o -c c_rhash/src/c_rhash.c $(CFLAGS) $(INCLUDES)
  20. c-rbuf/build/ringbuffer.o:
  21. cd c-rbuf && $(MAKE) build/ringbuffer.o
  22. $(BUILD_DIR)/ws_client.o: src/ws_client.c src/include/ws_client.h src/include/common_internal.h
  23. $(CC) -o $(BUILD_DIR)/ws_client.o -c src/ws_client.c $(CFLAGS) $(INCLUDES)
  24. $(BUILD_DIR)/test.o: src/test.c src/include/ws_client.h libmqttwebsockets.a
  25. $(CC) -o $(BUILD_DIR)/test.o -c src/test.c $(CFLAGS) $(INCLUDES)
  26. $(BUILD_DIR)/mqtt_wss_log.o: src/mqtt_wss_log.c src/include/mqtt_wss_log.h
  27. $(CC) -o $(BUILD_DIR)/mqtt_wss_log.o -c src/mqtt_wss_log.c $(CFLAGS) $(INCLUDES)
  28. $(BUILD_DIR)/mqtt_wss_client.o: src/mqtt_wss_client.c src/include/mqtt_wss_client.h src/include/ws_client.h src/include/common_internal.h $(BUILD_DIR)/common_public.o
  29. $(CC) -o $(BUILD_DIR)/mqtt_wss_client.o -c src/mqtt_wss_client.c $(CFLAGS) $(INCLUDES)
  30. $(BUILD_DIR)/mqtt_ng.o: src/mqtt_ng.c src/include/mqtt_ng.h src/include/common_internal.h $(BUILD_DIR)/common_public.o
  31. $(CC) -o $(BUILD_DIR)/mqtt_ng.o -c src/mqtt_ng.c $(CFLAGS) $(INCLUDES)
  32. $(BUILD_DIR)/common_public.o: src/common_public.c src/include/common_public.h
  33. $(CC) -o $(BUILD_DIR)/common_public.o -c src/common_public.c $(CFLAGS) $(INCLUDES)
  34. libmqttwebsockets.a: $(BUILD_DIR)/mqtt_wss_client.o $(BUILD_DIR)/ws_client.o c-rbuf/build/ringbuffer.o $(BUILD_DIR)/c_rhash.o $(BUILD_DIR)/mqtt_wss_log.o $(BUILD_DIR)/mqtt_ng.o $(BUILD_DIR)/common_public.o
  35. ar rcs libmqttwebsockets.a $(BUILD_DIR)/mqtt_wss_client.o $(BUILD_DIR)/ws_client.o c-rbuf/build/ringbuffer.o $(BUILD_DIR)/c_rhash.o $(BUILD_DIR)/mqtt_wss_log.o $(BUILD_DIR)/mqtt_ng.o $(BUILD_DIR)/common_public.o
  36. test: $(BUILD_DIR)/test.o libmqttwebsockets.a
  37. $(CC) -o test $(BUILD_DIR)/test.o libmqttwebsockets.a `pkg-config --libs openssl` -lpthread $(CFLAGS)
  38. clean:
  39. rm -f $(BUILD_DIR)/*
  40. cd c-rbuf && $(MAKE) clean
  41. rm -f test libmqttwebsockets.a
  42. install:
  43. dist:
  44. distdir: