Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #COPYRIGHT Hova
- #VERSION 2.0
- #Detecting your operating system
- UNAME=$(shell uname) #Calling shell command "uname"
- ifeq ($(UNAME), Darwin) #Checking if MacOS
- CC=clang #Compiler/linker in use
- UNIFLAGS=-pedantic -Wall -fsanitize=address -g #Universal flags
- endif
- ifneq (,$(filter $(UNAME), Linux FreeBSD)) #Checking if Linux or FreeBSD
- CC=gcc #Compiler/linker in use
- UNIFLAGS=-pedantic -Wall -g #Universal flags
- endif
- #Other parameters indifferent to OS
- SRCDIRS=src src/parse #Source directories and subdirectories
- CFLAGS=-c #Compiler flags
- BUILDDIR=build #Object files' directory
- LNFLAGS=-o #Linker flags
- DISTDIR=dist #Executable's directory
- SRCEXT=.c #Source files' extension
- OBJEXT=.o #Object files' extension
- EXECUTABLE=myshell #Executable's name
- #Build prosess itself
- all: *$(OBJEXT) #Final linking
- mkdir -p $(DISTDIR)
- $(CC) $(BUILDDIR)/$^ $(UNIFLAGS) $(LNFLAGS) $(DISTDIR)/$(EXECUTABLE)
- *$(OBJEXT): build #Building object files
- mkdir -p $(BUILDDIR)
- mv $@ $(BUILDDIR)
- build: $(SRCDIRS) #Compiling source
- for dir in $^; do $(CC) $$dir/*$(SRCEXT) $(UNIFLAGS) $(CFLAGS); done
- clean: #Removing object files
- rm -rf $(BUILDDIR)
- .PHONY: build clean #Making these targents independent from files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement