Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. # * http://www.apache.org/licenses/LICENSE-2.0
  10. # * Unless required by applicable law or agreed to in writing,
  11. # software distributed under the License is distributed on an
  12. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. # KIND, either express or implied. See the License for the
  14. # specific language governing permissions and limitations
  15. # under the License.
  16. #
  17. # Toolchain commands
  18. CROSS_COMPILE ?=
  19. CC := ccache $(CROSS_COMPILE)gcc
  20. CXX := ccache $(CROSS_COMPILE)g++
  21. LD := $(CROSS_COMPILE)gcc
  22. AR := $(CROSS_COMPILE)ar
  23. AS := $(CROSS_COMPILE)as
  24. NM := $(CROSS_COMPILE)nm
  25. OBJDUMP := $(CROSS_COMPILE)objdump
  26. OBJCOPY := $(CROSS_COMPILE)objcopy
  27. SIZE := $(CROSS_COMPILE)size
  28. # Configure NimBLE variables
  29. NIMBLE_ROOT := ../../..
  30. NIMBLE_CFG_TINYCRYPT := 1
  31. # Skip files that don't build for this port
  32. NIMBLE_IGNORE := $(NIMBLE_ROOT)/porting/nimble/src/hal_timer.c \
  33. $(NIMBLE_ROOT)/porting/nimble/src/os_cputime.c \
  34. $(NIMBLE_ROOT)/porting/nimble/src/os_cputime_pwr2.c \
  35. $(NULL)
  36. include $(NIMBLE_ROOT)/porting/nimble/Makefile.defs
  37. include $(NIMBLE_ROOT)/porting/nimble/Makefile.mesh
  38. SRC := $(NIMBLE_SRC)
  39. # Source files for NPL OSAL
  40. SRC += \
  41. $(wildcard $(NIMBLE_ROOT)/porting/npl/linux/src/*.c) \
  42. $(wildcard $(NIMBLE_ROOT)/porting/npl/linux/src/*.cc) \
  43. $(wildcard $(NIMBLE_ROOT)/nimble/transport/socket/src/*.c) \
  44. $(TINYCRYPT_SRC) \
  45. $(NULL)
  46. # Source files for demo app
  47. SRC += \
  48. ./ble.c \
  49. ./main.c \
  50. $(NULL)
  51. # Add NPL and all NimBLE directories to include paths
  52. INC = \
  53. ./include \
  54. $(NIMBLE_ROOT)/porting/npl/linux/include \
  55. $(NIMBLE_ROOT)/porting/npl/linux/src \
  56. $(NIMBLE_ROOT)/nimble/transport/socket/include \
  57. $(NIMBLE_INCLUDE) \
  58. $(TINYCRYPT_INCLUDE) \
  59. $(NULL)
  60. INCLUDES := $(addprefix -I, $(INC))
  61. SRC_C = $(filter %.c, $(SRC))
  62. SRC_CC = $(filter %.cc, $(SRC))
  63. OBJ := $(SRC_C:.c=.o)
  64. OBJ += $(SRC_CC:.cc=.o)
  65. TINYCRYPT_OBJ := $(TINYCRYPT_SRC:.c=.o)
  66. CFLAGS = \
  67. $(NIMBLE_CFLAGS) \
  68. $(INCLUDES) \
  69. -g \
  70. -D_GNU_SOURCE \
  71. $(NULL)
  72. LIBS := $(NIMBLE_LDFLAGS) -lrt -lpthread -lstdc++
  73. .PHONY: all clean
  74. .DEFAULT: all
  75. all: nimble-linux-blemesh
  76. clean:
  77. rm $(OBJ) -f
  78. rm nimble-linux-blemesh -f
  79. $(TINYCRYPT_OBJ): CFLAGS+=$(TINYCRYPT_CFLAGS)
  80. %.o: %.c
  81. $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
  82. %.o: %.cc
  83. $(CXX) -c $(INCLUDES) $(CFLAGS) -o $@ $<
  84. nimble-linux-blemesh: $(OBJ) $(TINYCRYPT_OBJ)
  85. $(LD) -o $@ $^ $(LIBS)
  86. $(SIZE) $@