"clean up" makefile
will need to rework it again later
This commit is contained in:
parent
ac6c61e10a
commit
0e9a7d6bd8
1 changed files with 14 additions and 12 deletions
26
Makefile
26
Makefile
|
@ -8,34 +8,36 @@ CFLAGS += -Wconversion -Wunreachable-code
|
|||
CFLAGS += -D_GNU_SOURCE
|
||||
LDFLAGS =
|
||||
|
||||
SRC = modfetch.c semver.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
NAME = modfetch
|
||||
|
||||
PROG = modfetch.c
|
||||
LIB = semver.c
|
||||
OBJ = $(PROG:.c=.o) $(LIB:.c=.o)
|
||||
BIN = target
|
||||
TEMPMOD = $(wildcard modules/*.c)
|
||||
MOD = $(TEMPMOD:modules/%=%)
|
||||
PROGRAM = modfetch
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: dirs modules $(PROGRAM)
|
||||
all: dirs modules $(NAME)
|
||||
|
||||
modules: dirs $(MOD:.c=.so)
|
||||
|
||||
dirs:
|
||||
mkdir -p ./$(BIN)
|
||||
mkdir -p $(BIN)
|
||||
|
||||
$(PROGRAM): $(addprefix $(BIN)/, $(OBJ))
|
||||
$(CC) -o $(BIN)/$(PROGRAM) $^ $(LDFLAGS)
|
||||
$(NAME): $(OBJ)
|
||||
$(CC) -o $(BIN)/$(NAME) $(addprefix $(BIN)/, $^) $(LDFLAGS)
|
||||
|
||||
%.so: modules/%.c $(LIB)
|
||||
$(CC) -o $(BIN)/$@ $^ -shared -fPIC $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -o $(BIN)/$@ -c $< $(CFLAGS)
|
||||
|
||||
%.so: modules/%.c
|
||||
$(CC) -o $(BIN)/$@ $^ -shared -fPIC $(CFLAGS)
|
||||
|
||||
clean: clean_modules
|
||||
rm -rf $(OBJ)
|
||||
rm -rf $(PROGRAM)
|
||||
rm -rf $(addprefix $(BIN)/, $(OBJ))
|
||||
rm -rf $(BIN)/$(NAME)
|
||||
|
||||
clean_modules:
|
||||
rm -rf $(wildcard $(BIN)/*.so)
|
||||
|
|
Loading…
Reference in a new issue