Skip to content

Instantly share code, notes, and snippets.

@FdelMazo
Last active November 6, 2018 15:24
Show Gist options
  • Save FdelMazo/5a5a8c34b25137d83b619fd3dc424cf0 to your computer and use it in GitHub Desktop.
Save FdelMazo/5a5a8c34b25137d83b619fd3dc424cf0 to your computer and use it in GitHub Desktop.
EXEC = $(shell basename $(CURDIR))
CFILES = $(wildcard *.c)
HFILES = $(wildcard *.h)
#OFILES = $(patsubst %.c, %.o, $(filter-out $(CFILES), $(wildcard *.c)))
CC = gcc
CFLAGS = -g -std=c99 -Wall -Werror
CFLAGS += -Wconversion -Wno-sign-conversion -Wbad-function-cast -Wshadow
CFLAGS += -Wno-unused-function #Solo para comodidad en pruebas locales
CFLAGS += -Wtype-limits -pedantic
CFLAGS += -Wpointer-arith -Wunreachable-code -Wformat=2
VFLAGS = --leak-check=full --track-origins=yes --show-reachable=yes --error-exitcode=2
GDB_FLAGS = -quiet -ex 'set pagination off' -ex 'set confirm off'
GDB_RAW_FLAGS = -ex 'l 1,30' -ex 'start'
ifdef LOG
LOGGING = 2>&1 | tee $(EXEC).log
endif
.EXPORT_ALL_VARIABLES:
TIME=\nTarda: %Us - Consume: %M KiB
help:
@echo "make build --> Compila el programa"
@echo "make zip --> Crea un zip con los archivos a entregar"
@echo "make run --> Corre el programa"
@echo "make valgrind --> Chequea perdidas de memoria"
@echo "make all --> Corre y chequea memoria"
@echo "make gdb --> Debuggear"
@echo "make gdbtui --> Debuggear con interfaz de usuario"
@echo "make clean --> Limpia el directorio de trabajo"
@echo
@echo "make [run | valgrind] LOG=1 --> Logea todo lo corrido"
@echo "Trabajar con objetos --> Descomentar la macro OFILES y dejar en CFILES solamente al archivo con la funcion main"
zip:
$(MAKE) -s all; test $$? -eq 0
$(MAKE) clean
zip $(EXEC).zip $(CFILES) $(HFILES)
all:
$(MAKE) -s run
$(MAKE) -s valgrind
run: build
time ./$(EXEC) $(LOGGING)
valgrind: build
time valgrind $(VFLAGS) ./$(EXEC) $(LOGGING)
gdb: build
gdb $(GDB_FLAGS) $(GDB_RAW_FLAGS) ./$(EXEC)
gdbtui: build
gdb $(GDB_FLAGS) -tui ./$(EXEC)
clean:
rm -f $(wildcard *.o) $(wildcard *.log) $(EXEC) $(EXEC).zip
partyparrot:
@curl http://parrot.live
batman:
@echo " _==/ | | \==_ "
@echo " /XX/ |\___/| \XX\ "
@echo " /XXXX\ |XXXXX| /XXXX\ "
@echo " |XXXXXX\_ _XXXXXXX_ _/XXXXXX| "
@echo " XXXXXXXXXXXxxxxxxxXXXXXXXXXXXxxxxxxxXXXXXXXXXXX "
@echo " |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| "
@echo " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "
@echo " |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX| "
@echo " XXXXXX/^^^^^\XXXXXXXXXXXXXXXXXXXXX/^^^^^\XXXXXX "
@echo " |XXX| \XXX/^^\XXXXX/^^\XXX/ |XXX| "
@echo " \XX\ \X/ \XXX/ \X/ /XX/ "
@echo " \ \X/ / "
@echo " \/ "
build: $(EXEC)
%.o: %.c %.h
$(CC) $(CFLAGS) -c $<
$(EXEC): $(OFILES) $(CFILES) $(HFILES)
$(CC) $(CFLAGS) $(OFILES) $(CFILES) -o $(EXEC)
.PHONY: build run all zip valgrind gdb clean batman partyparrot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment