Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Load configuration from ./configure
  2. include config.mk
  3. TARGET = visual-renamer
  4. SRC = src/main.cpp
  5. OBJ = $(SRC:.cpp=.o)
  6. # Default target
  7. all: check_config $(TARGET)
  8. # Check if config.mk exists
  9. check_config:
  10. @if [ ! -f config.mk ]; then \
  11. echo "Error: config.mk not found. Please run ./configure first."; \
  12. exit 1; \
  13. fi
  14. # Link the executable
  15. $(TARGET): $(OBJ)
  16. @echo "Linking $(TARGET)..."
  17. @$(CXX) $(OBJ) -o $(TARGET) $(LIBS)
  18. @echo "Build complete."
  19. # Compile source files
  20. .cpp.o:
  21. @echo "Compiling $<..."
  22. @$(CXX) $(CXXFLAGS) -c $< -o $@
  23. # Install to system
  24. install: all
  25. @echo "Installing to $(PREFIX)/bin..."
  26. @mkdir -p $(PREFIX)/bin
  27. @cp $(TARGET) $(PREFIX)/bin/
  28. @chmod 755 $(PREFIX)/bin/$(TARGET)
  29. @echo "creating desktop entry..."
  30. @mkdir -p $(HOME)/.local/share/applications
  31. @echo "[Desktop Entry]" > $(HOME)/.local/share/applications/visual-renamer.desktop
  32. @echo "Type=Application" >> $(HOME)/.local/share/applications/visual-renamer.desktop
  33. @echo "Name=Visual Renamer" >> $(HOME)/.local/share/applications/visual-renamer.desktop
  34. @echo "Exec=$(PREFIX)/bin/$(TARGET)" >> $(HOME)/.local/share/applications/visual-renamer.desktop
  35. @echo "Icon=system-file-manager" >> $(HOME)/.local/share/applications/visual-renamer.desktop
  36. @echo "Categories=Utility;" >> $(HOME)/.local/share/applications/visual-renamer.desktop
  37. @echo "Installation successful!"
  38. # Uninstall
  39. uninstall:
  40. @echo "Removing $(PREFIX)/bin/$(TARGET)..."
  41. @rm -f $(PREFIX)/bin/$(TARGET)
  42. @rm -f $(HOME)/.local/share/applications/visual-renamer.desktop
  43. @echo "Uninstall complete."
  44. # Clean build files
  45. clean:
  46. @echo "Cleaning up..."
  47. @rm -f $(OBJ) $(TARGET) config.mk
  48. .PHONY: all check_config install uninstall clean