mirror of
https://github.com/lakinduakash/linux-wifi-hotspot.git
synced 2024-11-24 21:20:12 +00:00
Merge pull request #65 from lakinduakash/dev
Transfer build system from cmake to make
This commit is contained in:
commit
0234225342
@ -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
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
build
|
||||
.idea
|
||||
.vscode
|
||||
src/cmake-build-debug
|
@ -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
Makefile
24
Makefile
@ -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
Makefile.cmake
Normal file
15
Makefile.cmake
Normal file
@ -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
|
14
README.md
14
README.md
@ -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
|
||||
|
||||
@ -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
|
||||
@ -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.**
|
||||
|
||||
|
||||
git clone https://github.com/lakinduakash/linux-wifi-hotspot
|
||||
cd linux-wifi-hotspot
|
||||
|
||||
@ -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.
|
||||
|
||||
|
@ -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)
|
||||
@ -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})
|
||||
|
||||
|
62
src/Makefile
Normal file
62
src/Makefile
Normal file
@ -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
|
@ -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
|
||||
|
@ -1,22 +0,0 @@
|
||||
CC=gcc
|
||||
CFLAGS=`pkg-config --cflags gtk+-3.0`
|
||||
|
||||
ODIR=../build
|
||||
|
||||
LIBS=`pkg-config --libs gtk+-3.0`
|
||||
|
||||
|
||||
_OBJ = main.o
|
||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||
|
||||
|
||||
$(ODIR)/%.o: ui/%.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
wihotspot: $(OBJ)
|
||||
$(CC) -o ui/$@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(ODIR)/*.o
|
@ -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
|
||||
|
@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.0"/>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">10</property>
|
||||
<property name="title">Grid</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="quit">
|
||||
<property name="label">Quit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">False</property>
|
||||
<signal name="clicked" handler="quit_clicked_cb" object="window" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label" translatable="yes">button</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="button1" object="window" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_new">
|
||||
<property name="label" translatable="yes">button</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="ss" object="window" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
9
src/ui/glade/wifih.gresource.xml
Normal file
9
src/ui/glade/wifih.gresource.xml
Normal file
@ -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>
|
102
src/ui/ui.c
102
src/ui/ui.c
@ -145,28 +145,30 @@ static void loadStyles(){
|
||||
screen = gdk_display_get_default_screen (display);
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
const char *style_file;
|
||||
// const char *style_file;
|
||||
//
|
||||
// const char* debug_style_file="glade/style.css";
|
||||
// const char* prod_style_file="/usr/share/wihotspot_gui/glade/style.css";
|
||||
// FILE *file;
|
||||
//
|
||||
// if ((file = fopen(debug_style_file, "r"))){
|
||||
// fclose(file);
|
||||
// style_file = debug_style_file;
|
||||
// gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(provider),"glade/style.css",NULL);
|
||||
//
|
||||
// }
|
||||
// else if ((file = fopen(prod_style_file, "r"))){
|
||||
// fclose(file);
|
||||
// style_file = prod_style_file;
|
||||
//
|
||||
// } else{
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(provider),style_file,NULL);
|
||||
|
||||
const char* debug_style_file="glade/style.css";
|
||||
const char* prod_style_file="/usr/share/wihotspot_gui/glade/style.css";
|
||||
|
||||
FILE *file;
|
||||
|
||||
if ((file = fopen(debug_style_file, "r"))){
|
||||
fclose(file);
|
||||
style_file = debug_style_file;
|
||||
gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(provider),"glade/style.css",NULL);
|
||||
|
||||
}
|
||||
else if ((file = fopen(prod_style_file, "r"))){
|
||||
fclose(file);
|
||||
style_file = prod_style_file;
|
||||
|
||||
} else{
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_css_provider_load_from_path(GTK_CSS_PROVIDER(provider),style_file,NULL);
|
||||
//Load css description from built resource - need to generate compiled source with glib-compile-resource
|
||||
gtk_css_provider_load_from_resource(GTK_CSS_PROVIDER(provider),"/css/style.css");
|
||||
}
|
||||
|
||||
static void init_style_contexts(){
|
||||
@ -326,52 +328,36 @@ static void *update_freq_toggle(){
|
||||
int initUi(int argc, char *argv[]){
|
||||
|
||||
XInitThreads();
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
|
||||
// const char* debug_glade_file="glade/wifih.ui";
|
||||
// const char* prod_glade_file="/usr/share/wihotspot_gui/glade/wifih.ui";
|
||||
//
|
||||
// DIR* dir = opendir("mydir");
|
||||
// if (dir)
|
||||
// {
|
||||
// /* Directory exists. */
|
||||
// closedir(dir);
|
||||
// FILE *file;
|
||||
// if ((file = fopen(debug_glade_file, "r"))){
|
||||
// fclose(file);
|
||||
// if (gtk_builder_add_from_file(builder, debug_glade_file, &error) == 0) {
|
||||
// g_printerr("Error loading file: %s\n", error->message);
|
||||
// g_clear_error(&error);
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
// else if (ENOENT == errno)
|
||||
// {
|
||||
// /* Directory does not exist. */
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// /* opendir() failed for some other reason. */
|
||||
// else if ((file = fopen(prod_glade_file, "r"))){
|
||||
// fclose(file);
|
||||
// if (gtk_builder_add_from_file(builder, prod_glade_file, &error) == 0) {
|
||||
// g_printerr("Error loading file: %s\n", error->message);
|
||||
// g_clear_error(&error);
|
||||
// return 1;
|
||||
// }
|
||||
// } else{
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
const char* debug_glade_file="glade/wifih.ui";
|
||||
const char* prod_glade_file="/usr/share/wihotspot_gui/glade/wifih.ui";
|
||||
|
||||
FILE *file;
|
||||
builder = gtk_builder_new();
|
||||
|
||||
if ((file = fopen(debug_glade_file, "r"))){
|
||||
fclose(file);
|
||||
if (gtk_builder_add_from_file(builder, debug_glade_file, &error) == 0) {
|
||||
g_printerr("Error loading file: %s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((file = fopen(prod_glade_file, "r"))){
|
||||
fclose(file);
|
||||
if (gtk_builder_add_from_file(builder, prod_glade_file, &error) == 0) {
|
||||
g_printerr("Error loading file: %s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
return 1;
|
||||
}
|
||||
} else{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Load ui description from built resource - need to generate compiled source with glib-compile-resource
|
||||
gtk_builder_add_from_resource(builder,"/org/gtk/wihotspot/wifih.ui",&error);
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object(builder, "window");
|
||||
|
Loading…
Reference in New Issue
Block a user