From 4959bb8a6196d3df9b6785014545550244a0af77 Mon Sep 17 00:00:00 2001 From: Lakindu Akash Date: Sun, 4 Oct 2020 15:52:25 +0530 Subject: [PATCH] Transfer build system from cmake to make --- Makefile | 24 ++++++++++++-------- src/Makefile | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 src/Makefile diff --git a/Makefile b/Makefile index 3b2376b..ea8d962 100644 --- a/Makefile +++ b/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 diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..a14acae --- /dev/null +++ b/src/Makefile @@ -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 \ No newline at end of file