Create makefile with proper install

This commit is contained in:
lakinduakash 2019-04-17 02:21:07 +05:30
parent 3069f56777
commit 8fe3d6dd45
4 changed files with 51 additions and 11 deletions

View File

@ -1,13 +1,14 @@
PREFIX=/usr
MANDIR=$(PREFIX)/share/man
BINDIR=$(PREFIX)/bin
all:
@echo "Run 'make install' for installation."
@echo "Run 'make uninstall' for uninstallation."
mkdir -p build
cd build && cmake -G "CodeBlocks - Unix Makefiles" ../src
$(MAKE) -C build
install:
$(MAKE) -C src/scripts install
$(MAKE) -C build install_build
uninstall:
$(MAKE) -C src/scripts uninstall
$(MAKE) -C build uninstall_build

View File

@ -12,15 +12,35 @@ set (CMAKE_CXX_STANDARD 11)
add_executable(wihotspot 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} )
target_link_libraries(${PROJECT_NAME} ${GTK_LIBRARIES} ${X11_LIBRARIES})
include_directories(/usr/include)
set (source "${CMAKE_SOURCE_DIR}/ui/glade")
set (destination "${CMAKE_CURRENT_BINARY_DIR}/glade")
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${source} ${destination}
DEPENDS ${destination}
COMMENT "symbolic link resources folder from ${source} => ${destination}"
)
set (appdir "/usr/share")
set (appbin "/usr/bin")
add_custom_target(install_build
COMMAND mkdir -p ${appdir}/${PROJECT_NAME}
COMMAND mkdir -p ${appdir}/${PROJECT_NAME}/glade
COMMAND install -Dm755 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} ${appdir}/${PROJECT_NAME}/${PROJECT_NAME}
COMMAND install -Dm755 ${CMAKE_CURRENT_BINARY_DIR}/glade/* ${appdir}/${PROJECT_NAME}/glade/
COMMAND ${CMAKE_COMMAND} -E create_symlink ${appdir}/${PROJECT_NAME}/${PROJECT_NAME} ${appbin}/${PROJECT_NAME}
DEPENDS ${PROJECT_NAME}
COMMENT Installing files...
)
add_custom_target(uninstall_build
COMMAND rm -r ${appdir}/${PROJECT_NAME}
COMMAND rm -f ${appbin}/${PROJECT_NAME}
COMMENT Unstalling files...
)

View File

@ -54,9 +54,7 @@ guint id;
void *stopHp();
void *stopHp() {
static void *stopHp() {
if(running_info[0]!=NULL){
gtk_label_set_label(label_status,"Stopping ...");
start_pb_pulse();
@ -108,12 +106,31 @@ int initUi(int argc, char *argv[]){
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/glade/wifih.ui";
FILE *file;
builder = gtk_builder_new();
if (gtk_builder_add_from_file(builder, "glade/wifih.ui", &error) == 0) {
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;
}
/* Connect signal handlers to the constructed widgets. */
window = gtk_builder_get_object(builder, "window");

View File

@ -32,4 +32,6 @@ static guint start_pb_pulse();
static void on_create_hp_clicked(GtkWidget *widget,gpointer data);
static void *stopHp();
#endif //WIHOTSPOT_UI_H