Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Update Makefile #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
CC := gcc
LIB_DIRECTORY := -L/usr/lib/arm-linux-gnueabihf
# Default to the host architecture
ARCH ?= $(shell uname -m)

ifeq ($(ARCH),x86_64)
CC := gcc
else ifeq ($(ARCH),arm)
CC := arm-linux-gnueabihf-gcc
CFLAGS += -marm
else ifeq ($(ARCH),aarch64)
CC := aarch64-linux-gnu-gcc
endif

LIB_DIRECTORY := -L/usr/lib/$(ARCH)-linux-gnu
INC_DIRECTORY := -I/usr/include/bluetooth
LIB := /usr/lib/arm-linux-gnueabihf/libbluetooth.a
CFLAGS := -Wall -fPIC
LIB := -lbluetooth
CFLAGS += -Wall -fPIC

.c.o:
$(CC) $(INC_DIRECTORY) $(CFLAGS) -c $<
Expand All @@ -11,11 +22,11 @@ all:
make tool
make lib

tool: bletool.o
gcc -o bletool $(INC_DIRECTORY) $(LIB_DIRECTORY) $< -lbluetooth
tool: bletool.o
$(CC) -o bletool $(INC_DIRECTORY) $(LIB_DIRECTORY) $< $(LIB)

lib: bletool.o
gcc $(CFLAGS) -shared -o libbletool.so $< $(LIB)
lib: bletool.o
$(CC) $(CFLAGS) -shared -o libbletool.so $< $(LIB_DIRECTORY) $(LIB)
install -m 644 libbletool.so ../

clean:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Raw BLE advertisement tool
This tool is for receiving/sending raw BLE advertisement messages.
The project is based on the Linux Bluetooth protocol stack, [BlueZ](http://www.bluez.org/).

The <Makefile> is configured for Raspberry Pi 3 and LIB_DIRECTORY needs to be set properly for other environments.
The <Makefile> is configured for Raspberry Pi 3 and 4, also X86_64 Ubuntu 22.04.

## Preparation
Install dependencies.

```
sudo apt update && sudo apt-get -y install libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libical-dev libreadline-dev libudev-dev libusb-dev make bluetooth bluez-utils libbluetooth-dev
sudo apt update && sudo apt-get -y install libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libical-dev libreadline-dev libudev-dev libusb-dev make bluetooth libbluetooth-dev
```

## Compilation
Expand Down