Advertisement
Hydrametr0nice

C Makefile

Apr 17th, 2020
1,620
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TARGET = <target_name>
  2. CC = gcc
  3. CFLAGS = -Wall -ansi -O3
  4. LDFLAGS = -lm
  5. HEADERS = $(wildcard *.h)
  6. OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
  7. VALGRIND = valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all
  8. FILES = ${file}
  9.  
  10. .PHONY: all clean clean2 clearscr debug runv $(TARGET)
  11.  
  12. .DEFAULT_GOAL := $(TARGET)
  13.  
  14. %.o: %.c $(HEADERS)
  15.     $(CC) -c -o $@ $< $(CFLAGS)
  16.  
  17. $(TARGET): $(OBJECTS)
  18.     $(CC) -o $@ $^ $(LDFLAGS)
  19.  
  20. all:    clearscr clean $(TARGET) runv clean2
  21.  
  22. clean:
  23.     -rm -f $(TARGET) *.o core a.out *~
  24.  
  25. clean2:
  26.     -rm -f $(TARGET) *.o core a.out *~
  27.  
  28. clearscr:
  29.     clear
  30.  
  31. debug:
  32.     gdb -args $(TARGET)
  33. # < $(FILES)
  34.  
  35. runv:
  36.     $(VALGRIND) ./$(TARGET)
  37. # < $(FILES)
Advertisement
RAW Paste Data Copied
Advertisement