From ecf066dcb379ac035cc1a9f37541849b9eeb8175 Mon Sep 17 00:00:00 2001 From: murat Date: Tue, 26 May 2026 18:22:17 +0300 Subject: [PATCH] init Makefile i used chatgpt for it please don't take my life i still don't know make --- Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b62aa08 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +APP := fetchit +SRC := main.cpp +BUILD_DIR := build +DIST_DIR := dist + +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin +DESTDIR ?= + +CXX ?= g++ +CXXFLAGS ?= -O2 -Wall -Wextra -std=c++17 -pipe +LDFLAGS ?= -static-libstdc++ -static-libgcc + +VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null) + +.PHONY: all build run install uninstall clean dist release + +all: build + +build: | $(BUILD_DIR) +build: $(BUILD_DIR)/$(APP) + +$(BUILD_DIR)/$(APP): $(SRC) | $(BUILD_DIR) + $(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +run: build + ./$(BUILD_DIR)/$(APP) + +install: | $(BUILD_DIR) +install: build + install -d "$(DESTDIR)$(BINDIR)" + install -m 0755 $(BUILD_DIR)/$(APP) "$(DESTDIR)$(BINDIR)/$(APP)" + +uninstall: + rm -f "$(DESTDIR)$(BINDIR)/$(APP)" + +clean: + rm -f $(BUILD_DIR)/$(APP) + +dist: | $(BUILD_DIR) $(DIST_DIR) +dist: build + tar -C $(BUILD_DIR) -czf $(DIST_DIR)/$(APP)-$(VERSION)-linux-x86_64-gnu.tar.gz $(APP) + +$(DIST_DIR): + mkdir -p $(DIST_DIR) + +release: clean build dist