#
#  Makefile
#  
#  Copyright 2026
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
# 

PROJECT_NAME=argsparse

CC=gcc
OPTIONS=-O2 -Wall -ansi
OUTPUT_NAME=$(PROJECT_NAME)
COPY=cp
INPUT_NAME=$(PROJECT_NAME).c
REMOVE=rm
INSTALL_NAME=/usr/local/bin/$(PROJECT_NAME)
MODE=chmod +x
RUN_OF=./
PROJECT_FILES=project_files
ECHO=echo
TOUCH=touch

.PHONY: clear run install uninstall $(OUTPUT_NAME)

$(OUTPUT_NAME): $(INPUT_NAME)
	$(CC) $(OPTIONS) $(INPUT_NAME) -o $(OUTPUT_NAME)
	$(COPY) -r $(PROJECT_FILES) ~/.$(PROJECT_NAME)
	$(REMOVE) -f ~/.$(PROJECT_NAME)/WARNING.txt
clear:
	$(REMOVE) -f $(OUTPUT_NAME)
	$(REMOVE) -f $(API_OUT_NAME)
run:
	$(MODE) $(OUTPUT_NAME)
	$(RUN_OF)$(OUTPUT_NAME)
install:
	$(COPY) $(OUTPUT_NAME) $(INSTALL_NAME)
	$(COPY) -r $(PROJECT_FILES) ~/.$(PROJECT_NAME)
	$(REMOVE) -f ~/.$(PROJECT_NAME)/WARNING.txt
uninstall:
	$(REMOVE) $(INSTALL_NAME)
	$(TOUCH) ~/.$(PROJECT_NAME)/WARNING.txt
	$(ECHO) Warning! If you have already uninstalled the "$(PROJECT_NAME)" program, please delete this folder. > ~/.$(PROJECT_NAME)/WARNING.txt
