Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. SRC := $(NIMBLE_SRC)
  38. # Source files for NPL OSAL
  39. SRC += \
  40. $(wildcard $(NIMBLE_ROOT)/porting/npl/linux/src/*.c) \
  41. $(wildcard $(NIMBLE_ROOT)/porting/npl/linux/src/*.cc) \
  42. $(wildcard $(NIMBLE_ROOT)/nimble/transport/socket/src/*.c) \
  43. $(TINYCRYPT_SRC) \
  44. $(NULL)
  45. # Source files for demo app
  46. SRC += \
  47. ./ble.c \
  48. ./main.c \
  49. $(NULL)
  50. # Add NPL and all NimBLE directories to include paths
  51. INC = \
  52. ./include \
  53. $(NIMBLE_ROOT)/porting/npl/linux/include \
  54. $(NIMBLE_ROOT)/nimble/transport/socket/include \
  55. $(NIMBLE_INCLUDE) \
  56. $(TINYCRYPT_INCLUDE) \
  57. $(NULL)
  58. INCLUDES := $(addprefix -I, $(INC))
  59. SRC_C = $(filter %.c, $(SRC))
  60. SRC_CC = $(filter %.cc, $(SRC))
  61. OBJ := $(SRC_C:.c=.o)
  62. OBJ += $(SRC_CC:.cc=.o)
  63. TINYCRYPT_OBJ := $(TINYCRYPT_SRC:.c=.o)
  64. CFLAGS = \
  65. $(NIMBLE_CFLAGS) \
  66. $(INCLUDES) \
  67. -g \
  68. -D_GNU_SOURCE \
  69. $(NULL)
  70. LIBS := $(NIMBLE_LDFLAGS) -lrt -lpthread -lstdc++
  71. .PHONY: all clean
  72. .DEFAULT: all
  73. all: nimble-linux
  74. clean:
  75. rm $(OBJ) -f
  76. rm nimble-linux -f
  77. $(TINYCRYPT_OBJ): CFLAGS+=$(TINYCRYPT_CFLAGS)
  78. %.o: %.c
  79. $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
  80. %.o: %.cc
  81. $(CXX) -c $(INCLUDES) $(CFLAGS) -o $@ $<
  82. nimble-linux: $(OBJ) $(TINYCRYPT_OBJ)
  83. $(LD) -o $@ $^ $(LIBS)
  84. $(SIZE) $@