init Makefile

i used chatgpt for it please don't take my life i still don't know make
This commit is contained in:
2026-05-26 18:22:17 +03:00
parent e6e5648a2d
commit ecf066dcb3
+50
View File
@@ -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