Makefile 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. TARGET := meh
  2. TESTTARGET := test/test
  3. SRCFILES := $(wildcard src/*.c)
  4. OBJFILES := $(SRCFILES:%.c=%.o)
  5. DEPFILES := $(OBJFILES:%.o=%.d)
  6. TESTCLEAN := $(TESTTARGET) $(TESTTARGET).d $(TESTTARGET).o
  7. CLEANFILES := $(CLEANFILES) $(DEPFILES) $(OBJFILES) test/test.o test/test.d test/test $(TARGET)
  8. LIBS ?= -lX11 -lXext -ljpeg -lpng -lgif
  9. PREFIX ?= /usr/local
  10. BINDIR = $(PREFIX)/bin
  11. DATAROOTDIR = $(PREFIX)/share
  12. MANDIR = $(DATAROOTDIR)/man
  13. # User configuration
  14. CONFIG ?= ../config
  15. -include configs/$(CONFIG).mk
  16. CFLAGS ?= -O3 -DNDEBUG
  17. meh: $(OBJFILES)
  18. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  19. test: $(TESTTARGET)
  20. ./$(TESTTARGET)
  21. test/test: test/test.o $(filter-out src/main.o src/xlib.o, $(OBJFILES))
  22. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  23. -include $(DEPFILES)
  24. %.o: %.c Makefile
  25. $(CC) $(CFLAGS) -MMD -MP -MT "$*.d" -c -o $@ $<
  26. install:
  27. install -Dm 755 meh $(DESTDIR)$(BINDIR)/meh
  28. install -D doc/meh.1 $(DESTDIR)$(MANDIR)/man1/meh.1
  29. # Clean
  30. clean:
  31. $(RM) $(CLEANFILES)
  32. .PHONY: clean test