Transfer build system from cmake to make

This commit is contained in:
Lakindu Akash 2020-10-04 15:52:25 +05:30
parent 3e6910723c
commit 4959bb8a61
No known key found for this signature in database
GPG Key ID: 87D9889F7A634A38
2 changed files with 77 additions and 9 deletions

View File

@ -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

62
src/Makefile Normal file
View 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