Skip to content

Commit

Permalink
Add installation option to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
botantony authored Jan 27, 2025
1 parent d26f836 commit cfc0e10
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ PLATFORM ?= $(shell uname -s)
BUILD_PATH ?= build
OBJ_PATH ?= obj

# installation prefix
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
BINDIR ?= $(PREFIX)/bin

# platform specific settings:
ifeq ($(PLATFORM), Linux)
LDFLAGS = -lm -ldl
Expand Down Expand Up @@ -47,6 +53,33 @@ exe: $(UMKA_EXE)
clean:
$(RM) $(BUILD_PATH) $(OBJ_PATH) -r

install: all
@echo "Installing to the following directories:"
@echo " Libraries: $(DESTDIR)$(LIBDIR)"
@echo " Includes: $(DESTDIR)$(INCLUDEDIR)"
@echo " Binaries: $(DESTDIR)$(BINDIR)"
@mkdir -p -- $(DESTDIR)$(LIBDIR)
@mkdir -p -- $(DESTDIR)$(BINDIR)
@mkdir -p -- $(DESTDIR)$(INCLUDEDIR)
@echo "Copying files..."
@cp $(UMKA_LIB_STATIC) $(DESTDIR)$(LIBDIR)/
@cp $(UMKA_LIB_DYNAMIC) $(DESTDIR)$(LIBDIR)/
@cp $(UMKA_EXE) $(DESTDIR)$(BINDIR)/
@cp $(APIS) $(DESTDIR)$(INCLUDEDIR)/
@echo "Installation complete!"

uninstall:
@echo "Uninstalling following files:"
@echo " $(DESTDIR)$(LIBDIR)/libumka.a"
@echo " $(DESTDIR)$(LIBDIR)/libumka.so"
@echo " $(DESTDIR)$(BINDIR)/umka"
@echo " $(DESTDIR)$(INCLUDEDIR)/umka_api.h"
@rm -f -- $(DESTDIR)$(LIBDIR)/libumka.a
@rm -f -- $(DESTDIR)$(LIBDIR)/libumka.so
@rm -f -- $(DESTDIR)$(BINDIR)/umka
@rm -f -- $(DESTDIR)$(INCLUDEDIR)/umka_api.h
@echo "Uninstallation complete!"

$(UMKA_LIB_STATIC): $(OBJS_STATIC)
@echo AR $@
@mkdir -p -- $(BUILD_PATH)/include/
Expand Down

0 comments on commit cfc0e10

Please sign in to comment.