Makefile 537 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/make -f
  2. #define variables
  3. COMMON_INCLUDE_DIR = ../../
  4. UTIL_INCLUDE_DIR = ../
  5. UTIL_SRC = $(wildcard ./src/*.c)
  6. UTIL_OBJ = $(sort $(UTIL_SRC:.c=.o))
  7. UTIL_LIB = ./src/libutil.a
  8. #set additional compiler flag
  9. CFLAGS += -D_CRT_SECURE_NO_WARNINGS
  10. #target part
  11. $(UTIL_OBJ): %.o: %.c
  12. $(CC) $(CFLAGS) -I$(COMMON_INCLUDE_DIR) \
  13. -I$(UTIL_INCLUDE_DIR) \
  14. -c $^ -o $@
  15. $(UTIL_LIB): $(UTIL_OBJ)
  16. $(AR) rc $(UTIL_LIB) $(UTIL_OBJ)
  17. ranlib $(UTIL_LIB)
  18. build: all
  19. all: $(UTIL_LIB)
  20. install:
  21. clean:
  22. rm -f $(UTIL_OBJ) $(UTIL_LIB)