minitar/Makefile

38 lines
704 B
Makefile
Raw Normal View History

2022-11-05 17:52:51 +00:00
OUTPUT ?= .
LIBNAME ?= libmtar
OBJ ?= obj
2022-11-05 17:52:51 +00:00
SRC := src
CC ?= gcc
AR ?= ar
CFLAGS ?= -O2 -Wall -Wextra
CFLAGS := ${CFLAGS} -I.
2022-11-05 17:56:57 +00:00
DESTDIR ?= /usr/local
2022-11-05 17:52:51 +00:00
2022-11-05 19:10:48 +00:00
OBJS := $(OBJ)/tar.o \
$(OBJ)/util.o
2022-11-05 17:52:51 +00:00
build: $(OBJS)
@echo -- Creating $(LIBNAME).a
@mkdir -p $(OUTPUT)
$(AR) rcs $(OUTPUT)/$(LIBNAME).a $(OBJS)
$(OBJ)/%.o: $(SRC)/%.c
2022-11-05 17:52:51 +00:00
@echo -- Compiling $^
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $^
install:
@echo -- Installing $(LIBNAME).a
@mkdir -p $(DESTDIR)
2022-11-05 17:56:57 +00:00
cp $(OUTPUT)/$(LIBNAME).a $(DESTDIR)/lib
cp ./minitar.h $(DESTDIR)/include
2022-11-05 17:52:51 +00:00
clean:
rm -f $(OBJ)/*.o
2022-11-05 17:52:51 +00:00
rm -f $(OUTPUT)/$(LIBNAME).a
uninstall:
@echo -- Removing $(LIBNAME).a
2022-11-05 17:56:57 +00:00
rm -f $(DESTDIR)/lib/$(LIBNAME).a
rm -f $(DESTDIR)/include/minitar.h