From 42c8250815b59203a2b05b2a1aca57721d36b3ae Mon Sep 17 00:00:00 2001 From: night0721 Date: Thu, 16 Jan 2025 21:47:09 +0000 Subject: [PATCH] Update Makefile --- Makefile | 24 +++++++++++++----------- apm.c | 1 - 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index c0ecac7..c47de6a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ .POSIX: -.SUFFIXES: VERSION = 1.0 TARGET = apm @@ -7,20 +6,23 @@ MANPAGE = $(TARGET).1 PREFIX ?= /usr/local BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/share/man/man1 +PKG_CONFIG = pkg-config -LDFLAGS != pkg-config --libs libsodium -CFLAGS = -Os -march=native -mtune=native -pipe -s -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE +PKGS = libsodium +LIBS != $(PKG_CONFIG) --libs $(PKGS) +INCS != $(PKG_CONFIG) --cflags $(PKGS) +CFLAGS += -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE $(INCS) -SRC = apm.c +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< -$(TARGET): $(SRC) - $(CC) $(SRC) -o $@ $(CFLAGS) $(LDFLAGS) +$(TARGET): $(TARGET).o + $(CC) -o $@ $(TARGET).o $(LIBS) dist: mkdir -p $(TARGET)-$(VERSION) cp -R README.md $(MANPAGE) $(TARGET) $(TARGET)-$(VERSION) - tar -cf $(TARGET)-$(VERSION).tar $(TARGET)-$(VERSION) - gzip $(TARGET)-$(VERSION).tar + tar -czf $(TARGET)-$(VERSION).tar.gz $(TARGET)-$(VERSION) rm -rf $(TARGET)-$(VERSION) install: $(TARGET) @@ -32,11 +34,11 @@ install: $(TARGET) chmod 644 $(DESTDIR)$(MANDIR)/$(MANPAGE) uninstall: - rm $(DESTDIR)$(BINDIR)/$(TARGET) - rm $(DESTDIR)$(MANDIR)/$(MANPAGE) + rm -f $(DESTDIR)$(BINDIR)/$(TARGET) + rm -f $(DESTDIR)$(MANDIR)/$(MANPAGE) clean: - rm $(TARGET) + rm -f $(TARGET) *.o all: $(TARGET) diff --git a/apm.c b/apm.c index 83a4524..2e18354 100644 --- a/apm.c +++ b/apm.c @@ -413,5 +413,4 @@ int main(int argc, char *argv[]) } return 0; - }