Makefile 844 B

12345678910111213141516171819202122232425262728293031323334353637
  1. LIBZ_INCLUDES = /usr/include
  2. LIBA_DIR = liba
  3. LIBA_INCLUDES = $(LIBA_DIR)
  4. LIBA_LIBS = -lz
  5. LIBA_OBJS = $(LIBA_DIR)/a.o
  6. LIBB_DIR = libb
  7. LIBB_OBJS = $(LIBB_DIR)/b.o
  8. LIBB_INCLUDES = $(LIBB_DIR) $(LIBA_INCLUDES)
  9. LIBB_DEPOBJS = $(LIBA_OBJS)
  10. LIBB_LIBS = $(LIBA_LIBS) $(LIBA_OBJS)
  11. PROGRAM_OBJS = prog.o
  12. PROGRAM_INCLUDES = $(LIBB_INCLUDES)
  13. PROGRAM_DEPOBJS = $(LIBB_DEPOBJS) $(LIBB_OBJS)
  14. PROGRAM_LIBS = $(LIBA_LIBS) $(LIBB_LIBS)
  15. PROGRAM = program
  16. all: $(PROGRAM)
  17. $(LIBA_OBJS): $(LIBA_DIR)/a.c $(LIBA_DIR)/a.h
  18. $(CC) -o $@ -c $< $(CFLAGS)
  19. $(LIBB_OBJS): $(LIBB_DIR)/b.cpp $(LIBB_DIR)/b.h $(LIBB_DEPOBJS)
  20. $(CXX) -o $@ -c $< $(CFLAGS)
  21. $(PROGRAM_OBJS): program.c
  22. $(CC) -o $@ -c $< $(CFLAGS) $(foreach incdir, $(LIBB_INCLUDES), -I $(incdir))
  23. $(PROGRAM): $(PROGRAM_OBJS) $(PROGRAM_DEPOBJS)
  24. $(CXX) -o $@ $+ $(LDFLAGS) $(LIBB_LIBS)
  25. clean:
  26. echo TODO