Skip to content

Commit

Permalink
Generate header dependency files for consistency
Browse files Browse the repository at this point in the history
Original commit message:

Fix segfault on ARMv7

* Do you understand what's happening?
* Do not use . for all-c-files-under, which will cause wrong paths
  • Loading branch information
updateing committed Nov 8, 2016
1 parent 30bc834 commit d0671a0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.o
*.d
.*
minieap
ifaddrs.c
15 changes: 13 additions & 2 deletions append.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ $(LOCAL_MODULE)_PRIV_C_FLAGS := \

$(LOCAL_MODULE)_LDFLAGS := $(LOCAL_LDFLAGS)
$(LOCAL_MODULE)_PRIV_OBJS := $(addprefix $(LOCAL_PATH),$(LOCAL_SRC_FILES:.c=.o))
$(LOCAL_MODULE)_PRIV_DEPS := $(addprefix $(LOCAL_PATH),$(LOCAL_SRC_FILES:.c=.d))

# Use := here!
# And $($(xxx)_suffix), not $(xxx)_suffix
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE) : CFLAGS := $($(LOCAL_MODULE)_PRIV_C_FLAGS)
$($(LOCAL_MODULE)_PRIV_OBJS) : CFLAGS := $($(LOCAL_MODULE)_PRIV_C_FLAGS)
$(LOCAL_MODULE) : $($(LOCAL_MODULE)_PRIV_OBJS)

# sed: change everything before ":" to "${@:.d=.o} $@"
$($(LOCAL_MODULE)_PRIV_DEPS) : CFLAGS := $($(LOCAL_MODULE)_PRIV_C_FLAGS)
$($(LOCAL_MODULE)_PRIV_DEPS) : ${@:.d=.c}
@$(CC) -MM ${@:.d=.c} $(CFLAGS) > $@
@sed -i 's,^.*:,${@:.d=.o} $@ : ,g' $@

# %.o %.d : *.c
-include $($(LOCAL_MODULE)_PRIV_DEPS)

.PHONY: $(LOCAL_MODULE)_clean
$(LOCAL_MODULE)_clean:
# Use patsubst to get correct filenames!
rm -f $($(patsubst %_clean,%,$@)_PRIV_OBJS)
rm -f $($(patsubst %_clean,%,$@)_PRIV_OBJS) $($(patsubst %_clean,%,$@)_PRIV_DEPS)
2 changes: 1 addition & 1 deletion if_impl/minieap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

LOCAL_PATH := $(call my-dir)

LOCAL_SRC_FILES := $(call all-c-files-under,.)
LOCAL_SRC_FILES := $(call all-c-files-under,)
LOCAL_C_INCLUDES :=
LOCAL_CFLAGS :=
LOCAL_LDFLAGS :=
Expand Down
2 changes: 1 addition & 1 deletion minieap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

LOCAL_PATH := $(call my-dir)

LOCAL_SRC_FILES := $(call all-c-files-under,.)
LOCAL_SRC_FILES := $(call all-c-files-under,)
LOCAL_C_INCLUDES :=
LOCAL_CFLAGS :=
LOCAL_LDFLAGS :=
Expand Down
2 changes: 1 addition & 1 deletion packet_plugin/minieap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

LOCAL_PATH := $(call my-dir)

LOCAL_SRC_FILES := $(call all-c-files-under,.)
LOCAL_SRC_FILES := $(call all-c-files-under,)
LOCAL_C_INCLUDES :=
LOCAL_CFLAGS :=
LOCAL_LDFLAGS :=
Expand Down
2 changes: 1 addition & 1 deletion packet_plugin/rjv3/minieap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
LOCAL_PATH := $(call my-dir)

LOCAL_SRC_FILES := \
$(call all-c-files-under,.) \
$(call all-c-files-under,) \
$(call all-c-files-under,rjv3_hashes)
LOCAL_C_INCLUDES := rjv3_hashes
LOCAL_CFLAGS :=
Expand Down
2 changes: 1 addition & 1 deletion util/minieap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

LOCAL_PATH := $(call my-dir)

LOCAL_SRC_FILES := $(filter-out ifaddrs.c, $(call all-c-files-under,.))
LOCAL_SRC_FILES := $(filter-out %ifaddrs.c, $(call all-c-files-under,))
LOCAL_C_INCLUDES :=
LOCAL_CFLAGS :=
LOCAL_LDFLAGS :=
Expand Down

0 comments on commit d0671a0

Please sign in to comment.