Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Makefile problems #10

Open
burgerrg opened this issue Sep 27, 2019 · 3 comments
Open

Makefile problems #10

burgerrg opened this issue Sep 27, 2019 · 3 comments

Comments

@burgerrg
Copy link

v1.1.0 on Ubuntu 18.04.3 after a clean checkout and make all:

$ make
make -C vendor/newrelic/axiom
make[1]: Entering directory '/home/rgburger/newrelic/vendor/newrelic/axiom'
cat: ../../VERSION: No such file or directory
make[1]: Leaving directory '/home/rgburger/newrelic/vendor/newrelic/axiom'
make -C src static
make[1]: Entering directory '/home/rgburger/newrelic/src'
make[1]: Leaving directory '/home/rgburger/newrelic/src'
ar -M < make/combine.mri
  • The Makefile is looking for VERSION in the wrong directories.
  • There should be no need to run ar again.
@burgerrg
Copy link
Author

Here's one way to fix the VERSION problem in vendor/newrelic/make/version.mk:

-AGENT_VERSION := $(shell if test -f VERSION; then cat VERSION; elif test -f ../VERSION; then cat ../VERSION; else cat ../../VERSION; fi).$(BUILD_NUMBER)
+AGENT_VERSION := $(shell cat $$(git rev-parse --show-toplevel)/VERSION).$(BUILD_NUMBER)

@burgerrg
Copy link
Author

Here's one way to fix the unnecessary work in Makefile when make is called a second time without any changes:

@@ -37,28 +37,29 @@ PCRE_CFLAGS := $(shell pcre-config --cflags)
 AGENT_VERSION := $(shell if test -f VERSION; then cat VERSION; fi)
 VERSION_FLAGS += -DNEWRELIC_VERSION=$(AGENT_VERSION)
 
 export AGENT_VERSION VERSION_FLAGS
 
+.PHONY: all
 all: libnewrelic.a newrelic-daemon
 
 ifeq (Darwin,$(UNAME))
 #
 # This rule builds a static axiom library and a static C SDK library, and
 # then uses macOS's special libtool to smoosh them together into a single,
 # beautiful library.
 #
 LIBTOOL := /usr/bin/libtool
 
-libnewrelic.a: axiom src-static
+libnewrelic.a: vendor/newrelic/axiom/libaxiom.a src/libnewrelic.a
 	$(LIBTOOL) -static -o $@ vendor/newrelic/axiom/libaxiom.a src/libnewrelic.a
 else
 #
 # This rule builds a static axiom library and a static C SDK library, and
 # then uses GNU ar's MRI support to smoosh them together into a single,
 # beautiful library.
-libnewrelic.a: make/combine.mri axiom src-static
+libnewrelic.a: make/combine.mri vendor/newrelic/axiom/libaxiom.a src/libnewrelic.a
 	$(AR) -M < $<
 endif
 
 .PHONY: static
 static: libnewrelic.a
@@ -77,21 +78,19 @@ tests: vendor libnewrelic.a
 
 .PHONY: vendor
 vendor:
 	$(MAKE) -C vendor
 
-.PHONY: axiom vendor/newrelic/axiom/libaxiom.a
-axiom: vendor/newrelic/axiom/libaxiom.a
-
 vendor/newrelic/axiom/libaxiom.a: export CFLAGS := $(C_AGENT_CFLAGS) -DNR_CAGENT
 vendor/newrelic/axiom/libaxiom.a:
 	$(MAKE) -C vendor/newrelic/axiom
 
 .PHONY: axiom-clean
 axiom-clean:
 	$(MAKE) -C vendor/newrelic/axiom clean
 
+.PHONY: daemon
 daemon: newrelic-daemon
 
 newrelic-daemon:
 	$(MAKE) USE_SYSTEM_CERTS=1 -C vendor/newrelic daemon
 	cp vendor/newrelic/bin/daemon newrelic-daemon
@@ -113,12 +112,11 @@ valgrind: vendor libnewrelic.a
 # the static library and have gcc wrap it in the appropriate shared library
 # goop.
 libnewrelic.so: libnewrelic.a
 	$(CC) -shared -pthread $(PCRE_CFLAGS) -ldl -o $@ -Wl,--whole-archive $^  -Wl,--no-whole-archive
 
-.PHONY: src-static
-src-static:
+src/libnewrelic.a:
 	$(MAKE) -C src static
 
 .PHONY: src-clean
 src-clean:
 	$(MAKE) -C src clean

@Fahmy-Mohammed
Copy link
Contributor

Hi Bob! Thank you for finding this. We'll have a look and include it in the next release.

@jodeev jodeev added this to Triage - tag + prioritize in PHP/C Engineering Board Oct 21, 2020
@Miriam-R Miriam-R moved this from Triage - tag + prioritize. to Backlog - Issues without a committed date. in PHP/C Engineering Board Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
PHP/C Engineering Board
  
Backlog - Issues without a committed ...
Development

No branches or pull requests

2 participants