Skip to content

Commit

Permalink
Merge pull request #65 from lakinduakash/dev
Browse files Browse the repository at this point in the history
Transfer build system from cmake to make
  • Loading branch information
lakinduakash authored Oct 4, 2020
2 parents f4a048b + 8644ec3 commit 0234225
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 164 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.4.1
- image: ubuntu:latest
steps:
- checkout
- run: echo "A first hello"
- run: ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo Europe/Minsk > /etc/timezone
- run: DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y libgtk-3-dev build-essential gcc g++ pkg-config make hostapd
- run: make && make install
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
.idea
.vscode
src/cmake-build-debug
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ before_install:
- sudo apt-get install -y build-essential libgtk-3-dev

script:
- make
- sudo PATH="$HOME/usr/bin:$PATH" make install
- echo "Finished"
# - make
# - sudo PATH="$HOME/usr/bin:$PATH" make install
- echo "Test Finished"
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
all:
@echo "Run 'make install' for installation."
@echo "Run 'make uninstall' for uninstallation."
mkdir -p build
cd build && cmake -G "CodeBlocks - Unix Makefiles" ../src
@echo "Run 'sudo make install' for installation."
@echo "Run 'sudo make uninstall' for uninstallation."
cd src && $(MAKE)

install:
@echo "Installing"
cd build && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR) -G "CodeBlocks - Unix Makefiles" ../src
$(MAKE) -C src/scripts install
$(MAKE) -C build install_build
@echo "Installing..."
cd src && $(MAKE) install

uninstall:
$(MAKE) -C src/scripts uninstall
$(MAKE) -C build uninstall_build
@echo "Uninstalling..."
cd src && $(MAKE) uninstall

clean-old:
cd src && $(MAKE) clean-old

.PHONY: clean

clean:
cd src && $(MAKE) clean
15 changes: 15 additions & 0 deletions Makefile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all:
@echo "Run 'make install' for installation."
@echo "Run 'make uninstall' for uninstallation."
mkdir -p build
cd build && cmake -G "CodeBlocks - Unix Makefiles" ../src

install:
@echo "Installing"
cd build && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR) -G "CodeBlocks - Unix Makefiles" ../src
$(MAKE) -C src/scripts install
$(MAKE) -C build install_build

uninstall:
$(MAKE) -C src/scripts uninstall
$(MAKE) -C build uninstall_build
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Update
* Config files are wriiten to /etc/wh.config (Previously, configurations were wriiten to home directory as `.wh.config`).
* `.desktop` file is added. So You can start from app launcher
* Use `make` to build instead of `cmake`

### Features

Expand Down Expand Up @@ -46,9 +47,8 @@ install it using your distro's package manager_
* dnsmasq
* iptables

#### For building from source
#### To build from source

* cmake (https://cmake.org)
* make
* gcc and g++
* build-essential
Expand All @@ -59,14 +59,15 @@ install it using your distro's package manager_
On Ubuntu or debian install dependencies by,

```bash
sudo apt install -y libgtk-3-dev build-essential cmake gcc g++ pkg-config make hostapd
sudo apt install -y libgtk-3-dev build-essential gcc g++ pkg-config make hostapd
```

## Installation

**Note: If you have installed previous version of this project make sure to uninstall it by checking out to the previous version (v2.1.1 or below).
Also you can use `sudo make clean-old` without checking out to the previous version. After that install the binaries. Otherwise your system might left orphaned binaries and files.**


## Installation

git clone https://github.com/lakinduakash/linux-wifi-hotspot
cd linux-wifi-hotspot

Expand All @@ -81,6 +82,7 @@ sudo apt install -y libgtk-3-dev build-essential cmake gcc g++ pkg-config make h
## Uninstallation
sudo make uninstall


## Running
You can run it from terminal or from application menu.

Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12)
project(wihotspot_gui)
project(wihotspot-gui)

include(FindPkgConfig)
pkg_check_modules(GTK gtk+-3.0 REQUIRED)
Expand All @@ -10,7 +10,7 @@ include_directories(${X11_INCLUDE_DIRS})
set(CMAKE_C_STANDARD 99)
set (CMAKE_CXX_STANDARD 11)

add_executable(wihotspot_gui ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h ui/util.c ui/util.h)
add_executable(wihotspot-gui ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h ui/util.c ui/util.h)

target_link_libraries(${PROJECT_NAME} ${GTK_LIBRARIES} ${X11_LIBRARIES})

Expand Down
62 changes: 62 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
CC=gcc
PKGCONFIG = $(shell which pkg-config)

CFLAGS=`pkg-config --cflags gtk+-3.0`
LIBS=`pkg-config --libs gtk+-3.0 --libs x11` -lstdc++

APP_NAME="wihotspot"
APP_GUI_BINARY="wihotspot-gui"

PREFIX=/usr
BINDIR=$(PREFIX)/bin
APP_DIR=$(PREFIX)/share/$(APP_NAME)

ODIR=../build

GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)

BUILT_SRC = resources.c

_OBJ = main.o ui.o h_prop.o util.o read_config.o $(BUILT_SRC:.c=.o)
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))

all: resources.c $(ODIR)/wihotspot-gui

resources.c: ui/glade/wifih.gresource.xml ui/glade/wifih.ui
$(GLIB_COMPILE_RESOURCES) ui/glade/wifih.gresource.xml --target=ui/$@ --sourcedir=ui/glade --generate-source

$(ODIR)/%.o: ui/%.c
$(CC) -c -o $@ $< $(CFLAGS)

$(ODIR)/%.o: ui/%.cpp
g++ -c -o $@ $<

$(ODIR)/wihotspot-gui: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)

install: $(ODIR)/wihotspot-gui
mkdir -p $(DESTDIR)$(APP_DIR)
install -Dm644 desktop/hotspot.png $(DESTDIR)$(APP_DIR)/hotspot.png
install -Dm644 desktop/wifihotspot.desktop $(DESTDIR)$(APP_DIR)/$(APP_NAME).desktop
install -Dm644 desktop/wifihotspot.desktop $(DESTDIR)$(PREFIX)/share/applications/$(APP_NAME).desktop
install -Dm755 $(ODIR)/wihotspot-gui $(DESTDIR)$(BINDIR)/$(APP_GUI_BINARY)
cd scripts && $(MAKE) install

uninstall:
rm -rf $(DESTDIR)$(APP_DIR)
rm -f $(DESTDIR)$(PREFIX)/share/applications/$(APP_NAME).desktop
rm -f $(DESTDIR)$(BINDIR)/$(APP_GUI_BINARY)
cd scripts && $(MAKE) uninstall

clean-old:
rm -rf $(DESTDIR)/usr/share/wihotspot_gui
rm -rf $(DESTDIR)/usr/share/wihotspot
rm -f $(DESTDIR)/usr/bin/wihotspot_gui
rm -f $(DESTDIR)/usr/bin/wihotspot

.PHONY: clean

clean:
rm -f $(ODIR)/*.o
rm -f ui/$(BUILT_SRC)
rm -f $(ODIR)/wihotspot-gui
4 changes: 2 additions & 2 deletions src/desktop/wifihotspot.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Name=WifiHotspot
Icon=/usr/share/wihotspot_gui/hotspot.png
Name=Wifi Hotspot
Icon=/usr/share/wihotspot/hotspot.png
Exec=sh -c 'env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot'
Terminal=false
Categories=System
Expand Down
22 changes: 0 additions & 22 deletions src/makefile.old

This file was deleted.

2 changes: 1 addition & 1 deletion src/scripts/wihotspot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

# Start wihotspot_gui as root user
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot_gui
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/wihotspot-gui
60 changes: 0 additions & 60 deletions src/ui/glade/main.ui

This file was deleted.

9 changes: 9 additions & 0 deletions src/ui/glade/wifih.gresource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/wihotspot">
<file preprocess="xml-stripblanks">wifih.ui</file>
</gresource>
<gresource prefix="/css">
<file>style.css</file>
</gresource>
</gresources>
Loading

0 comments on commit 0234225

Please sign in to comment.