apfsprogs: create archive of libraries on build

Instead of linking each library file by itself, assemble an archive with
all the common library code.  Use this to simplify the fsck Makefile,
which no longer needs to relink every single time.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
This commit is contained in:
Ernesto A. Fernández
2019-05-25 15:40:17 -03:00
parent 9cb0b2f572
commit 9fd5a22c02
3 changed files with 9 additions and 6 deletions
+1
View File
@@ -1,6 +1,7 @@
*.swp *.swp
*.d *.d
*.o *.o
*.a
/apfsck/apfsck /apfsck/apfsck
/mkapfs/mkapfs /mkapfs/mkapfs
/tags /tags
+4 -4
View File
@@ -4,7 +4,7 @@ OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d) DEPS = $(SRCS:.c=.d)
LIBDIR = ../lib LIBDIR = ../lib
LIBS = $(LIBDIR)/checksum.o $(LIBDIR)/unicode.o LIBRARY = $(LIBDIR)/libapfs.a
BINDIR = ~/bin BINDIR = ~/bin
MANDIR = ~/share/man/man8 MANDIR = ~/share/man/man8
@@ -13,13 +13,13 @@ SPARSE_VERSION := $(shell sparse --version 2>/dev/null)
override CFLAGS += -Wall -I$(CURDIR)/../include override CFLAGS += -Wall -I$(CURDIR)/../include
apfsck: $(OBJS) libraries apfsck: $(OBJS) $(LIBRARY)
@echo ' Linking...' @echo ' Linking...'
@gcc $(CFLAGS) -o apfsck $(OBJS) $(LIBS) @gcc $(CFLAGS) -o apfsck $(OBJS) $(LIBRARY)
@echo ' Build complete' @echo ' Build complete'
# Build the common libraries # Build the common libraries
libraries: FORCE $(LIBRARY): FORCE
@echo ' Building libraries...' @echo ' Building libraries...'
@$(MAKE) -C $(LIBDIR) --silent --no-print-directory @$(MAKE) -C $(LIBDIR) --silent --no-print-directory
@echo ' Library build complete' @echo ' Library build complete'
+4 -2
View File
@@ -6,7 +6,9 @@ SPARSE_VERSION := $(shell sparse --version 2>/dev/null)
override CFLAGS += -Wall -I$(CURDIR)/../include override CFLAGS += -Wall -I$(CURDIR)/../include
all: $(OBJS) libapfs.a: $(OBJS)
@echo ' Assembling library archive...'
@ar rcs $@ $^
%.o: %.c %.o: %.c
@echo ' Compiling $<...' @echo ' Compiling $<...'
@@ -18,4 +20,4 @@ endif
-include $(DEPS) -include $(DEPS)
clean: clean:
rm -f $(OBJS) $(DEPS) rm -f $(OBJS) $(DEPS) libapfs.a