From 9fae9151acba763f92b5a049bba1a256b3b32642 Mon Sep 17 00:00:00 2001 From: homewsn Date: Wed, 24 Jun 2015 18:57:51 +0300 Subject: [PATCH] New build scheme --- Makefile | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ReadMe.md | 8 ++++--- src/Makefile | 44 ---------------------------------- 3 files changed, 72 insertions(+), 47 deletions(-) create mode 100644 Makefile delete mode 100644 src/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e83598a --- /dev/null +++ b/Makefile @@ -0,0 +1,67 @@ +# +# Copyright (c) 2015 Vladimir Alemasov +# All rights reserved +# +# This program and the accompanying materials are distributed under +# the terms of GNU General Public License version 2 +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +TARGET = whsniff +OBJDIR = obj +SRCDIR = src +SOURCES = $(wildcard $(SRCDIR)/*.c) +HEADERS = $(wildcard $(SRCDIR)/*.h) +OBJECTS = $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o) +DEPS = $(HEADERS) + +INCLPATH = -I. +LIBS = -lusb-1.0 -lrt + +# Installation directories by convention +# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html +PREFIX = /usr/local +EXEC_PREFIX = $(PREFIX) +BINDIR = $(EXEC_PREFIX)/bin +SYSCONFDIR = $(PREFIX)/etc +LOCALSTATEDIR = $(PREFIX)/var + +# main goal +all: $(TARGET) + +# target executable +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) -o $(TARGET) $(OBJECTS) $(LIBPATH) $(LIBS) + +# object files +$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c $(DEPS) | $(OBJDIR) + $(CC) $(CFLAGS) -c $< -o $@ $(INCLPATH) + +# create object files directory +$(OBJDIR): + mkdir -p $(OBJDIR) + +# clean +clean: + rm -rf $(OBJDIR) + +# distclean +distclean: clean + rm -f $(TARGET) + +# install +# http://unixhelp.ed.ac.uk/CGI/man-cgi?install +install: all + install -d -m 755 "$(BINDIR)" + install -m 755 $(TARGET) "$(BINDIR)/" + +# uninstall +uninstall: + rm -f $(BINDIR)/$(TARGET) + +.PHONY: all clean distclean install uninstall diff --git a/ReadMe.md b/ReadMe.md index 351d16b..5852cde 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -16,10 +16,12 @@ Whsniff reads the packets from TI CC2531 USB dongle with [`sniffer_fw_cc2531` fi $ sudo apt-get install libusb-1.0-0-dev ``` -* Build release version: +* Download [the latest release](https://github.com/homewsn/whsniff/releases) in tarball from github and untar it. Then build and install whsniff. ```sh -$ cd path/to/whsniff/Makefile -$ make release +$ curl -L https://github.com/homewsn/whsniff/archive/v1.1.tar.gz | tar zx +$ cd whsniff-1.1 +$ make +$ sudo make install ``` diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 02ba671..0000000 --- a/src/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# make - Ubuntu debug -# make release - Ubuntu release -# make openwrt - OpenWrt release - -TARGET = whsniff -SOURCES = $(wildcard *.c) -HEADERS = $(wildcard *.h) -OBJECTS = $(SOURCES:.c=.o) -DEPS = $(HEADERS) - -# ubuntu -INCLPATH = -I. -LIBPATH = -L/usr/lib -LIBS = -lusb-1.0 -lrt - -# Ubuntu debug -FLAGS = -g -O2 -debug: $(TARGET) - -$(TARGET): $(OBJECTS) $(DEPS) - $(CC) $(LDFLAGS) $(STATIC) -o $(TARGET) $(OBJECTS) $(LIBPATH) $(LIBS) - -$(OBJECTS): $(SOURCES) - $(CC) $(FLAGS) $(CFLAGS) $(DEF) -c $(SOURCES) $(INCLPATH) - - -# Ubuntu release -.PHONY: release -release: FLAGS = -O2 -DNDEBUG -release: $(TARGET) - - -# OpenWrt -.PHONY: openwrt -openwrt: FLAGS = -O2 -openwrt: INCLPATH = $(TARGET_INCLPATH) -openwrt: LIBPATH = $(TARGET_LIBPATH) -openwrt: LIBS = $(TARGET_LIBS) -openwrt: DEF = $(TARGET_DEFS) -openwrt: $(TARGET) - -.PHONY: clean -clean: - rm -f $(OBJECTS) $(TARGET)