Skip to content
Snippets Groups Projects
Makefile 933 B
Newer Older
  • Learn to ignore specific revisions
  • TARGET=cryptops-api
    
    CFLAGS=-O0 -g -Wall -D_GNU_SOURCE -Iincludes -Isrc
    LFLAGS=-L./libraries -lcryptsetup -lc -lulfius -lyder -lorcania -ljansson
    
    CC=gcc
    
    LINKER=gcc
    
    SRCDIR   = src
    OBJDIR   = obj
    BINDIR   = bin
    
    DEPS=$(wildcard $(SRCDIR)/*/*.c) $(wildcard $(SRCDIR)/*.c)
    
    
    SOURCES  := $(SRCDIR)/$(TARGET).c
    OBJECTS  := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
    
    $(BINDIR)/$(TARGET): $(BINDIR)
    $(BINDIR):
    	mkdir -p $(BINDIR)
    
    # Make binary linking .o files and libraries
    
    $(BINDIR)/$(TARGET): $(OBJECTS)
    	@$(LINKER) $(OBJECTS) $(LFLAGS) -o $@
    	@echo "Linking complete."
    
    
    # Compile an object for a c file in SRCDIR
    
    $(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS)
    
    	mkdir -p $(OBJDIR)
    
    	@$(CC) $(CFLAGS) -c $< -o $@
    	@echo "Compiled "$<" successfully."
    
    # Remove intermediate files
    
    .PHONY: clean
    
    clean:
    
    	@echo "Cleanup complete."
    
    
    # Remove all compiled files
    
    .PHONY: remove
    remove: clean
    
    	@echo "Executable removed."