Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROJECT=pspctl
- PREFIX=
- CC=$(PREFIX)gcc
- LD=$(PREFIX)gcc
- STRIP=$(PREFIX)strip
- CCFLAGS=-Og -g3 -c -std=c11 -Iincludes
- LDFLAGS=
- OUTDIR = ./bin
- MODDIR = $(OUTDIR)/mods
- SOURCES = $(wildcard src/*.c)
- MODULES_DIRS = $(wildcard src/mods/*)
- MODULES = $(patsubst src/mods/%,%,$(MODULES_DIRS))
- OBJS=$(SOURCES:.c=.o)
- BIN=$(OUTDIR)/$(PROJECT)
- MODULE_BINS=$(patsubst mod_%,$(MODDIR)/%.so,$(MODULES))
- PERCENT := %
- default: $(BIN) $(MODULE_BINS)
- $(BIN): $(OBJS)
- $(LD) $(LDFLAGS) -o $(BIN) $^
- $(MODDIR)/%.so: mod_%
- mv $^ $@
- .SECONDEXPANSION:
- mod_%: $$(patsubst $$(PERCENT).c,$$(PERCENT).o,$$(wildcard src/mods/$$@/*.c))
- $(LD) $(LDFLAGS) -shared -o $@ $^
- %.o: %.c
- $(CC) $(CCFLAGS) $< -o $@
- clean:
- find src -type f -iname '*.o' -delete
- rm $(BIN)
- rm $(MODULE_BINS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement