Skip to content

Commit

Permalink
Makefile: No order-only dependencies (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Oct 15, 2024
1 parent 616cdb0 commit 995d8cf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
$(OBJ)/%.o: %.c dep/%.d $(OBJ) Makefile
$(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<

# Share librarry recipe
$(LIB)/%.so.$(SO_VERSION) : | $(LIB) Makefile
# Share library recipe
$(LIB)/%.so.$(SO_VERSION):
@make $(LIB)
$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $^ -shared -fPIC -Wl,-soname,$(subst $(LIB)/,,$@) $(LDFLAGS)

# Unversioned shared libs (for linking against)
$(LIB)/lib%.so:
@if [ ! -e $(LIB) ] ; then mkdir $(LIB); fi
@rm -f $@
ln -sr $< $@

# Static library: *.a
$(LIB)/%.a:
@if [ ! -e $(LIB) ] ; then mkdir $(LIB); fi
@make $(LIB)
ar -rc $@ $^
ranlib $@

Expand Down Expand Up @@ -63,7 +63,8 @@ dox: README.md Doxyfile | apidoc $(SRC) $(INC)

# Automatic dependence on included header files.
.PRECIOUS: dep/%.d
dep/%.d: $(SRC)/%.c | dep
dep/%.d: $(SRC)/%.c
@make dep
@echo " > $@" \
&& $(CC) $(CPPFLAGS) -MM -MG $< > $@.$$$$ \
&& sed 's|\w*\.o[ :]*| $(OBJ)/&|g' < $@.$$$$ > $@; \
Expand Down

0 comments on commit 995d8cf

Please sign in to comment.