From 90e8e3f9bdead5e075b50cd210a55202e7b40057 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 16 Sep 2021 18:21:24 +0200 Subject: Improve makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 19 +++++++++---------- config.mk | 4 +++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a90ce01..da70bbc 100644 --- a/Makefile +++ b/Makefile @@ -58,22 +58,24 @@ MAN3 =\ libsha2_unmarshal.3\ libsha2_update.3 +LOBJ = $(OBJ:.o=.lo) + all: libsha2.a libsha2.$(LIBEXT) test -$(OBJ): $(@:.o=.c) $(HDR) -$(OBJ:.o=.lo): $(@:.lo=.c) $(HDR) +$(OBJ): $(HDR) +$(LOBJ): $(HDR) .c.o: - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) .c.lo: - $(CC) -fPIC -c -o $@ $< $(CFLAGS) + $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) test: test.o libsha2.a $(CC) -o $@ test.o libsha2.a $(LDFLAGS) -libsha2.$(LIBEXT): $(OBJ:.o=.lo) - $(CC) $(LIBFLAGS) -o $@ $(OBJ) $(LDFLAGS) +libsha2.$(LIBEXT): $(LOBJ) + $(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) libsha2.a: $(OBJ) -rm -f -- $@ @@ -86,7 +88,6 @@ check: test install: mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" mkdir -p -- "$(DESTDIR)$(PREFIX)/include" - mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/libsha2" mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man0" mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3" cp -- libsha2.a "$(DESTDIR)$(PREFIX)/lib" @@ -96,7 +97,6 @@ install: cp -- libsha2.h "$(DESTDIR)$(PREFIX)/include" cp -- $(MAN0) "$(DESTDIR)$(MANPREFIX)/man0" cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3" - cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/libsha2" uninstall: -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha2.a" @@ -106,10 +106,9 @@ uninstall: -rm -f -- "$(DESTDIR)$(PREFIX)/include/libsha2.h" -cd -- "$(DESTDIR)$(MANPREFIX)/man0" && rm -f -- $(MAN0) -cd -- "$(DESTDIR)$(MANPREFIX)/man3" && rm -f -- $(MAN3) - -rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/libsha2" clean: - -rm -f -- *.o *.lo *.su *.a *.so test + -rm -f -- *.o *.lo *.su *.a *.$(LIBEXT) test .SUFFIXES: .SUFFIXES: .lo .o .c diff --git a/config.mk b/config.mk index cd79dd2..a2d88f2 100644 --- a/config.mk +++ b/config.mk @@ -1,6 +1,8 @@ PREFIX = /usr MANPREFIX = $(PREFIX)/share/man +CC = cc + CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -CFLAGS = -std=c99 -Wall -Wextra -O3 $(CPPFLAGS) +CFLAGS = -std=c99 -Wall -O3 LDFLAGS = -s -- cgit v1.2.3-70-g09d2