Skip to content

Commit

Permalink
Makefile: give up on auto deps
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Oct 17, 2024
1 parent 3a53d21 commit c99ef71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ distclean: clean
SOURCES = $(SRC)/xchange.c $(SRC)/xstruct.c $(SRC)/xlookup.c $(SRC)/xjson.c

# Generate a list of object (obj/*.o) files from the input sources
OBJECTS := $(subst $(SRC),$(OBJ),$(SOURCES))
OBJECTS := $(subst .c,.o,$(OBJECTS))
OBJECTS := $(subst .c,.o,$(subst $(SRC),$(OBJ),$(SOURCES)))

$(LIB)/libxchange.so: $(LIB)/libxchange.so.$(SO_VERSION)

Expand Down
16 changes: 4 additions & 12 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
# Generic build targets and recipes for xchange.
#
# You can include this in your Makefile also.
# ============================================================================


# Regular object files
$(OBJ)/%.o: %.c dep/%.d $(OBJ) Makefile

$(OBJ)/%.o: %.c $(OBJ) Makefile
$(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<

# Share library recipe
Expand All @@ -27,13 +26,13 @@ $(LIB)/%.a:
ranlib $@

# Create sub-directories for build targets
dep $(OBJ) $(LIB) $(BIN) apidoc:
$(OBJ) $(LIB) $(BIN) apidoc:
mkdir $@

# Remove intermediate files locally
.PHONY: clean-local
clean-local:
rm -rf obj dep
rm -rf obj

# Remove all locally built files, effectively restoring the repo to its
# pristine state
Expand Down Expand Up @@ -61,11 +60,4 @@ dox: README.md Doxyfile apidoc $(SRC) $(INC)
@echo " [doxygen]"
@$(DOXYGEN)

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

0 comments on commit c99ef71

Please sign in to comment.