Advertisement
Guest User

Makefile example

a guest
Jul 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.21 KB | None | 0 0
  1. # File: Makefile
  2. # Name: IJC DU_2 1) 2)
  3. # Author:
  4. # Make: GNU Make 4.2.1
  5. # Compiled C: gcc 7.3.1
  6. # Compiled C++: g++ 7.3.1
  7. #
  8.  
  9. CC=gcc
  10. CXX=g++
  11. CFLAGS= -std=c99 -Werror -Wall -Wextra -pedantic -g
  12. CXXFLAGS= -std=c++11 -Wall -pedantic -g
  13.  
  14. libsrc := $(shell ls htab_*.c)
  15. libsrc +=libhtab.c
  16. libobj := $(libsrc:.c=.o)
  17. libsharedobj := $(patsubst %.o,%-shared.o, $(libobj))
  18.  
  19.  
  20. .PHONY: all clean cleanall zip
  21. all: tail tail2 wordcount wordcount-dynamic libhtab.a libhtab.so
  22.  
  23. tail: tail.c
  24.  
  25. tail2: tail2.cc
  26.  
  27. wordcount: wordcount.o io.o libhtab.a
  28.     $(CC) $(CFLAGS) -o $@ $^
  29.  
  30. wordcount-dynamic: wordcount.o io.o libhtab.so
  31.     $(CC) $(CFLAGS) wordcount.o io.o -o $@ -L. -lhtab
  32.    
  33. io.o: io.c io.h
  34.  
  35. wordcount.o: wordcount.c htab.h io.h
  36.  
  37. $(libobj): htab.h
  38.  
  39. libhtab.so: $(libsharedobj)
  40.     $(CC) $(CFLAGS) -shared -fPIC -o $@ $(libsharedobj)
  41.  
  42. htab_%-shared.o: htab_%.c htab.h
  43.     $(CC) $(CFLAGS) -fPIC -c $< -o $@
  44.  
  45. libhtab-shared.o: libhtab.c htab.h
  46.     $(CC) $(CFLAGS) -fPIC -c $< -o $@
  47.  
  48. libhtab.a: $(libobj)
  49.     ar crs $@ $(libobj)
  50.     ranlib $@
  51.  
  52. clean:
  53.     rm -f *.o
  54.  
  55. cleanall: clean
  56.     rm -f wordcount-dynamic wordcount tail tail2 libhtab.a libhtab.so
  57.  
  58. LOGIN= xpatri00
  59. zip: *.c *.cc *.h Makefile
  60.     zip $(LOGIN).zip $^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement