Advertisement
Guest User

Untitled

a guest
Oct 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.23 KB | None | 0 0
  1. #COPYRIGHT Hova
  2. #VERSION 2.0
  3.  
  4. #Detecting your operating system
  5. UNAME=$(shell uname) #Calling shell command "uname"
  6. ifeq ($(UNAME), Darwin) #Checking if MacOS
  7.         CC=clang #Compiler/linker in use
  8.         UNIFLAGS=-pedantic -Wall -fsanitize=address -g #Universal flags
  9. endif
  10.  
  11. ifneq (,$(filter $(UNAME), Linux FreeBSD)) #Checking if Linux or FreeBSD
  12.         CC=gcc #Compiler/linker in use
  13.         UNIFLAGS=-pedantic -Wall -g #Universal flags
  14. endif
  15.  
  16. #Other parameters indifferent to OS
  17. SRCDIRS=src src/parse #Source directories and subdirectories
  18. CFLAGS=-c #Compiler flags
  19. BUILDDIR=build #Object files' directory
  20. LNFLAGS=-o #Linker flags
  21. DISTDIR=dist #Executable's directory
  22. SRCEXT=.c #Source files' extension
  23. OBJEXT=.o #Object files' extension
  24. EXECUTABLE=myshell #Executable's name
  25.  
  26. #Build prosess itself
  27. all: *$(OBJEXT) #Final linking
  28.         mkdir -p $(DISTDIR)
  29.         $(CC) $(BUILDDIR)/$^ $(UNIFLAGS) $(LNFLAGS) $(DISTDIR)/$(EXECUTABLE)
  30.  
  31. *$(OBJEXT): build #Building object files
  32.         mkdir -p $(BUILDDIR)
  33.         mv $@ $(BUILDDIR)
  34.  
  35. build: $(SRCDIRS) #Compiling source
  36.         for dir in $^; do $(CC) $$dir/*$(SRCEXT) $(UNIFLAGS) $(CFLAGS); done
  37.  
  38. clean: #Removing object files
  39.         rm -rf $(BUILDDIR)
  40.  
  41. .PHONY: build clean #Making these targents independent from files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement