Advertisement
bueddl

Untitled

Apr 25th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 0.78 KB | None | 0 0
  1. PROJECT=pspctl
  2. PREFIX=
  3. CC=$(PREFIX)gcc
  4. LD=$(PREFIX)gcc
  5. STRIP=$(PREFIX)strip
  6.  
  7. CCFLAGS=-Og -g3 -c -std=c11 -Iincludes
  8. LDFLAGS=
  9.  
  10. OUTDIR = ./bin
  11. MODDIR = $(OUTDIR)/mods
  12. SOURCES = $(wildcard src/*.c)
  13. MODULES_DIRS = $(wildcard src/mods/*)
  14. MODULES = $(patsubst src/mods/%,%,$(MODULES_DIRS))
  15.  
  16. OBJS=$(SOURCES:.c=.o)
  17. BIN=$(OUTDIR)/$(PROJECT)
  18. MODULE_BINS=$(patsubst mod_%,$(MODDIR)/%.so,$(MODULES))
  19.  
  20. PERCENT := %
  21.  
  22. default: $(BIN) $(MODULE_BINS)
  23.  
  24. $(BIN): $(OBJS)
  25.     $(LD) $(LDFLAGS) -o $(BIN) $^
  26.  
  27. $(MODDIR)/%.so: mod_%
  28.     mv $^ $@
  29.  
  30. .SECONDEXPANSION:
  31. mod_%: $$(patsubst $$(PERCENT).c,$$(PERCENT).o,$$(wildcard src/mods/$$@/*.c))
  32.     $(LD) $(LDFLAGS) -shared -o $@ $^
  33.  
  34. %.o: %.c
  35.     $(CC) $(CCFLAGS) $< -o $@
  36.  
  37. clean:
  38.     find src -type f -iname '*.o' -delete
  39.     rm $(BIN)
  40.     rm $(MODULE_BINS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement