From 7f5fc4356b8e371304936bde421ef96f2a0ce207 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 19 Aug 2014 11:16:01 -0400 Subject: [PATCH 1/8] generate pkg-config files --- configure/Makefile | 43 +++++++++++++++++++++++++++++++++ configure/epics-base-arch.pc.in | 24 ++++++++++++++++++ configure/epics-base.pc.in | 22 +++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 configure/epics-base-arch.pc.in create mode 100644 configure/epics-base.pc.in diff --git a/configure/Makefile b/configure/Makefile index 86c59048e..6c4faf688 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -23,5 +23,48 @@ CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG*)) CONFIGS += $(subst ../,,$(wildcard ../RELEASE*)) CONFIGS += $(subst ../,,$(wildcard ../RULES*)) +ifdef T_A +ifeq ($(BUILD_CLASS)$(POSIX),HOSTYES) + +FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION)) + +INSTALL_PC ?= $(INSTALL_LOCATION)/lib/pkgconfig + +DIRECTORY_TARGETS += $(INSTALL_PC) + +C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CPPFLAGS)))) +C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CFLAGS)))) + +MVARS += FINAL_LOCATION OS_CLASS CMPLR_CLASS C_CFLAGS LDFLAGS LDLIBS +MVARS += EPICS_VERSION EPICS_REVISION EPICS_MODIFICATION EPICS_MODIFICATION + +EXPANDFLAGS += $(foreach var,$(MVARS),-D$(var)="$(strip $($(var)))") + +endif +endif + include $(TOP)/configure/RULES +ifdef T_A +ifeq ($(BUILD_CLASS)$(POSIX),HOSTYES) + +epics-base-$(T_A).pc: ../epics-base-arch.pc.in +epics-base.pc: ../epics-base.pc.in + +epics-base-$(T_A).pc epics-base.pc: + $(ECHO) "Expanding $< to $@" + @$(RM) $@ + @$(EXPAND_TOOL) $(EXPANDFLAGS) $($@_EXPANDFLAGS) $< $@ + +$(INSTALL_PC)/%: % + $(ECHO) "Installing pkgconfig file $@" + @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) + +buildInstall: $(INSTALL_PC)/epics-base-$(T_A).pc + +ifeq ($(T_A),$(EPICS_HOST_ARCH)) +buildInstall: $(INSTALL_PC)/epics-base.pc +endif + +endif +endif diff --git a/configure/epics-base-arch.pc.in b/configure/epics-base-arch.pc.in new file mode 100644 index 000000000..b5807abd9 --- /dev/null +++ b/configure/epics-base-arch.pc.in @@ -0,0 +1,24 @@ +# non-standard variables +top=@FINAL_LOCATION@ +arch=@ARCH@ +os_class=@OS_CLASS@ +cmplr_class=@CMPLR_CLASS@ + +includedir_osi=${top}/include +includedir_osd=${top}/include/os/@OS_CLASS@ +includedir_comp=${top}/include/compiler/@CMPLR_CLASS@ + +includedirs=${includedir_osi} ${includedir_osd} ${includedir_comp} + +# standard variables +prefix=@FINAL_LOCATION@ +exec_prefix=@FINAL_LOCATION@ +bindir=${top}/bin/@ARCH@ +libdir=${top}/lib/@ARCH@ + +Name: epics-base-@ARCH@ +Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_MODIFICATION@ +Description: EPICS Base for @ARCH@ +Cflags: -I${includedir_osi} -I${includedir_osd} -I${includedir_comp} @C_CFLAGS@ +Libs: -L${libdir} @LDFLAGS@ +Libs.private: @LDLIBS@ diff --git a/configure/epics-base.pc.in b/configure/epics-base.pc.in new file mode 100644 index 000000000..274594a82 --- /dev/null +++ b/configure/epics-base.pc.in @@ -0,0 +1,22 @@ +# non-standard variables +top=@FINAL_LOCATION@ +arch=@ARCH@ +os_class=@OS_CLASS@ +cmplr_class=@CMPLR_CLASS@ + +includedir_osi=${top}/include +includedir_osd=${top}/include/os/@OS_CLASS@ +includedir_comp=${top}/include/os/@CMPLR_CLASS@ + +includedirs=${includedir_osi} ${includedir_osd} ${includedir_comp} + +# standard variables +prefix=@FINAL_LOCATION@ +exec_prefix=@FINAL_LOCATION@ +bindir=${top}/bin/@ARCH@ +libdir=${top}/lib/@ARCH@ + +Name: epics-base +Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_MODIFICATION@ +Description: EPICS Base for the host arch +Requires: epics-base-@ARCH@ = @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_MODIFICATION@ From 92f5e5775d339e780fbb590b5c5baf028c623149 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 19 Sep 2014 16:37:56 -0500 Subject: [PATCH 2/8] Restructured patch. * Move the construction of the .pc files into src/tools * Make more use of the built-in rules for variable substitution * Make PKGCONFIG an Makefile variable for installing .pc files * Use EPICS_PATCH_LEVEL for the final digit in the version number --- configure/CONFIG_FILE_TYPE | 3 ++ configure/Makefile | 43 ------------------- configure/RULES_EXPAND | 4 +- src/tools/Makefile | 19 ++++++++ .../tools/epics-base-arch.pc@ | 2 +- .../tools/epics-base.pc@ | 4 +- 6 files changed, 28 insertions(+), 47 deletions(-) rename configure/epics-base-arch.pc.in => src/tools/epics-base-arch.pc@ (97%) rename configure/epics-base.pc.in => src/tools/epics-base.pc@ (90%) diff --git a/configure/CONFIG_FILE_TYPE b/configure/CONFIG_FILE_TYPE index 0501e1949..c15f4b783 100644 --- a/configure/CONFIG_FILE_TYPE +++ b/configure/CONFIG_FILE_TYPE @@ -60,6 +60,9 @@ INSTALL_EDL = $(INSTALL_LOCATION)/edl FILE_TYPE += PERL_MODULES INSTALL_PERL_MODULES = $(INSTALL_LOCATION_LIB)/perl +FILE_TYPE += PKGCONFIG +INSTALL_PKGCONFIG = $(INSTALL_LOCATION_LIB)/pkgconfig + INSTALLS_CFG = $(CFG:%= $(INSTALL_CFG)/%) DIRECTORY_TARGETS += $(foreach type, $(FILE_TYPE),$(INSTALL_$(type))) diff --git a/configure/Makefile b/configure/Makefile index 6c4faf688..86c59048e 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -23,48 +23,5 @@ CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG*)) CONFIGS += $(subst ../,,$(wildcard ../RELEASE*)) CONFIGS += $(subst ../,,$(wildcard ../RULES*)) -ifdef T_A -ifeq ($(BUILD_CLASS)$(POSIX),HOSTYES) - -FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION)) - -INSTALL_PC ?= $(INSTALL_LOCATION)/lib/pkgconfig - -DIRECTORY_TARGETS += $(INSTALL_PC) - -C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CPPFLAGS)))) -C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CFLAGS)))) - -MVARS += FINAL_LOCATION OS_CLASS CMPLR_CLASS C_CFLAGS LDFLAGS LDLIBS -MVARS += EPICS_VERSION EPICS_REVISION EPICS_MODIFICATION EPICS_MODIFICATION - -EXPANDFLAGS += $(foreach var,$(MVARS),-D$(var)="$(strip $($(var)))") - -endif -endif - include $(TOP)/configure/RULES -ifdef T_A -ifeq ($(BUILD_CLASS)$(POSIX),HOSTYES) - -epics-base-$(T_A).pc: ../epics-base-arch.pc.in -epics-base.pc: ../epics-base.pc.in - -epics-base-$(T_A).pc epics-base.pc: - $(ECHO) "Expanding $< to $@" - @$(RM) $@ - @$(EXPAND_TOOL) $(EXPANDFLAGS) $($@_EXPANDFLAGS) $< $@ - -$(INSTALL_PC)/%: % - $(ECHO) "Installing pkgconfig file $@" - @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) - -buildInstall: $(INSTALL_PC)/epics-base-$(T_A).pc - -ifeq ($(T_A),$(EPICS_HOST_ARCH)) -buildInstall: $(INSTALL_PC)/epics-base.pc -endif - -endif -endif diff --git a/configure/RULES_EXPAND b/configure/RULES_EXPAND index c103fe95c..5cf24bd06 100644 --- a/configure/RULES_EXPAND +++ b/configure/RULES_EXPAND @@ -2,6 +2,8 @@ ifeq ($(findstring Host,$(VALID_BUILDS)),Host) +vpath %@ $(USR_VPATH) $(ALL_SRC_DIRS) + # Default settings EXPAND_TOOL ?= $(PERL) $(TOOLS)/expandVars.pl @@ -12,7 +14,7 @@ EXPANDED = $(EXPAND:%@=%) buildInstall: $(EXPANDED) -$(EXPANDED): %: ../%@ +$(EXPANDED): %: %@ $(ECHO) "Expanding $< to $@" @$(RM) $@ @$(EXPAND_TOOL) $(EXPANDFLAGS) $($@_EXPANDFLAGS) $< $@ diff --git a/src/tools/Makefile b/src/tools/Makefile index 496b0e4d1..0c7dce2c0 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -51,5 +51,24 @@ PERL_SCRIPTS += dbdExpand.pl PERL_SCRIPTS += dbdToHtml.pl PERL_SCRIPTS += registerRecordDeviceDriver.pl +# Build Package Config Files + +FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION)) +C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CPPFLAGS)))) +C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CFLAGS)))) +PKGVARS += FINAL_LOCATION OS_CLASS CMPLR_CLASS C_CFLAGS LDFLAGS LDLIBS +PKGVARS += EPICS_VERSION EPICS_REVISION EPICS_MODIFICATION EPICS_PATCH_LEVEL + +EXPANDFLAGS += $(foreach var,$(PKGVARS),-D$(var)="$(strip $($(var)))") +PKGCONFIG += epics-base.pc +PKGCONFIG += epics-base-$(T_A).pc + +EXPAND += $(PKGCONFIG:%=%@) +CLEANS += epics-base-$(T_A).pc@ + include $(TOP)/configure/RULES +epics-base-$(T_A).pc@: ../epics-base-arch.pc@ + @$(RM) $@ + @$(CP) $< $@ + diff --git a/configure/epics-base-arch.pc.in b/src/tools/epics-base-arch.pc@ similarity index 97% rename from configure/epics-base-arch.pc.in rename to src/tools/epics-base-arch.pc@ index b5807abd9..c75d02684 100644 --- a/configure/epics-base-arch.pc.in +++ b/src/tools/epics-base-arch.pc@ @@ -17,7 +17,7 @@ bindir=${top}/bin/@ARCH@ libdir=${top}/lib/@ARCH@ Name: epics-base-@ARCH@ -Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_MODIFICATION@ +Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_PATCH_LEVEL@ Description: EPICS Base for @ARCH@ Cflags: -I${includedir_osi} -I${includedir_osd} -I${includedir_comp} @C_CFLAGS@ Libs: -L${libdir} @LDFLAGS@ diff --git a/configure/epics-base.pc.in b/src/tools/epics-base.pc@ similarity index 90% rename from configure/epics-base.pc.in rename to src/tools/epics-base.pc@ index 274594a82..08cfdcc33 100644 --- a/configure/epics-base.pc.in +++ b/src/tools/epics-base.pc@ @@ -17,6 +17,6 @@ bindir=${top}/bin/@ARCH@ libdir=${top}/lib/@ARCH@ Name: epics-base -Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_MODIFICATION@ +Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_PATCH_LEVEL@ Description: EPICS Base for the host arch -Requires: epics-base-@ARCH@ = @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_MODIFICATION@ +Requires: epics-base-@ARCH@ = @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_PATCH_LEVEL@ From b1918c1e311e139ab0f2c8294dd5c8bb45c7cec4 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 25 Sep 2014 11:50:13 -0400 Subject: [PATCH 3/8] allow expandVars for all targets --- configure/RULES_EXPAND | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configure/RULES_EXPAND b/configure/RULES_EXPAND index 5cf24bd06..274b0532d 100644 --- a/configure/RULES_EXPAND +++ b/configure/RULES_EXPAND @@ -1,7 +1,5 @@ # /configure/RULES_EXPAND -ifeq ($(findstring Host,$(VALID_BUILDS)),Host) - vpath %@ $(USR_VPATH) $(ALL_SRC_DIRS) # Default settings @@ -25,5 +23,3 @@ expand_clean: @$(RM) $(EXPANDED) .PHONY : expand_clean - -endif From 2f577c136cb1829c8f652a0fd8dda6760a6dd14d Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 25 Sep 2014 13:24:41 -0400 Subject: [PATCH 4/8] expandVars.pl: correctly handle macro values containing '='. --- src/tools/expandVars.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/expandVars.pl b/src/tools/expandVars.pl index 5015fe07a..4e81ac4e4 100644 --- a/src/tools/expandVars.pl +++ b/src/tools/expandVars.pl @@ -49,7 +49,7 @@ expandRelease(\%vars); $vars{'ARCH'} = $opt_a if $opt_a; while ($_ = shift @opt_D) { - my ($var, $val) = split /=/; + my ($var, $val) = split(/=/, $_, 2); $vars{$var} = $val; print "$var = $val\n" if $opt_d; } From 5e9b225a2eae785dccb0206b40657d67a5759e05 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 25 Sep 2014 14:04:10 -0400 Subject: [PATCH 5/8] src/tools: ensure epics-base.pc is generated only for EPICS_HOST_ARCH --- src/tools/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/Makefile b/src/tools/Makefile index 0c7dce2c0..e597e68d2 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -60,8 +60,10 @@ PKGVARS += FINAL_LOCATION OS_CLASS CMPLR_CLASS C_CFLAGS LDFLAGS LDLIBS PKGVARS += EPICS_VERSION EPICS_REVISION EPICS_MODIFICATION EPICS_PATCH_LEVEL EXPANDFLAGS += $(foreach var,$(PKGVARS),-D$(var)="$(strip $($(var)))") -PKGCONFIG += epics-base.pc PKGCONFIG += epics-base-$(T_A).pc +ifeq ($(T_A),$(EPICS_HOST_ARCH)) +PKGCONFIG += epics-base.pc +endif EXPAND += $(PKGCONFIG:%=%@) CLEANS += epics-base-$(T_A).pc@ From 3fe84c5ace3ca0b24c0b58bded5c2761e3aa7ce6 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 25 Sep 2014 16:49:40 -0400 Subject: [PATCH 6/8] src/tools: export additional variables to pkg-config No need for new names/capitalization --- src/tools/Makefile | 2 ++ src/tools/epics-base-arch.pc@ | 43 ++++++++++++++++++++++++----------- src/tools/epics-base.pc@ | 33 ++++++++++++++++----------- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/tools/Makefile b/src/tools/Makefile index e597e68d2..cd364519d 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -58,6 +58,8 @@ C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CPPFLAGS)))) C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CFLAGS)))) PKGVARS += FINAL_LOCATION OS_CLASS CMPLR_CLASS C_CFLAGS LDFLAGS LDLIBS PKGVARS += EPICS_VERSION EPICS_REVISION EPICS_MODIFICATION EPICS_PATCH_LEVEL +PKGVARS += CC CCC CPP AR LD +PKGVARS += EPICS_BASE_IOC_LIBS EXPANDFLAGS += $(foreach var,$(PKGVARS),-D$(var)="$(strip $($(var)))") PKGCONFIG += epics-base-$(T_A).pc diff --git a/src/tools/epics-base-arch.pc@ b/src/tools/epics-base-arch.pc@ index c75d02684..8e30cd30e 100644 --- a/src/tools/epics-base-arch.pc@ +++ b/src/tools/epics-base-arch.pc@ @@ -1,20 +1,37 @@ -# non-standard variables -top=@FINAL_LOCATION@ -arch=@ARCH@ -os_class=@OS_CLASS@ -cmplr_class=@CMPLR_CLASS@ +# standard variables +prefix=@FINAL_LOCATION@ +exec_prefix=${prefix} +bindir=${prefix}/bin/@ARCH@ +libdir=${prefix}/lib/@ARCH@ -includedir_osi=${top}/include -includedir_osd=${top}/include/os/@OS_CLASS@ -includedir_comp=${top}/include/compiler/@CMPLR_CLASS@ +# non-standard variables + +# EPICS Base install location +FINAL_LOCATION=${prefix} +ARCH=@ARCH@ +OS_CLASS=@OS_CLASS@ +CMPLR_CLASS=@CMPLR_CLASS@ + +EPICS_BASE_IOC_LIBS=@EPICS_BASE_IOC_LIBS@ + +# Directories + +includedir_osi=${prefix}/include +includedir_osd=${prefix}/include/os/@OS_CLASS@ +includedir_comp=${prefix}/include/compiler/@CMPLR_CLASS@ includedirs=${includedir_osi} ${includedir_osd} ${includedir_comp} -# standard variables -prefix=@FINAL_LOCATION@ -exec_prefix=@FINAL_LOCATION@ -bindir=${top}/bin/@ARCH@ -libdir=${top}/lib/@ARCH@ +dbddir=${prefix}/dbd +dbdir=${prefix}/db + +# Tool chain + +CC=@CC@ +CXX=@CCC@ +CPP=@CPP@ +AR=@AR@ +LD=@LD@ Name: epics-base-@ARCH@ Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_PATCH_LEVEL@ diff --git a/src/tools/epics-base.pc@ b/src/tools/epics-base.pc@ index 08cfdcc33..c1540666a 100644 --- a/src/tools/epics-base.pc@ +++ b/src/tools/epics-base.pc@ @@ -1,20 +1,27 @@ -# non-standard variables -top=@FINAL_LOCATION@ -arch=@ARCH@ -os_class=@OS_CLASS@ -cmplr_class=@CMPLR_CLASS@ +# standard variables +prefix=@FINAL_LOCATION@ +exec_prefix=${prefix} +bindir=${prefix}/bin/@ARCH@ +libdir=${prefix}/lib/@ARCH@ -includedir_osi=${top}/include -includedir_osd=${top}/include/os/@OS_CLASS@ -includedir_comp=${top}/include/os/@CMPLR_CLASS@ +# non-standard variables + +# EPICS Base install location +FINAL_LOCATION=${prefix} +ARCH=@ARCH@ +OS_CLASS=@OS_CLASS@ +CMPLR_CLASS=@CMPLR_CLASS@ + +# Directories + +includedir_osi=${prefix}/include +includedir_osd=${prefix}/include/os/@OS_CLASS@ +includedir_comp=${prefix}/include/compiler/@CMPLR_CLASS@ includedirs=${includedir_osi} ${includedir_osd} ${includedir_comp} -# standard variables -prefix=@FINAL_LOCATION@ -exec_prefix=@FINAL_LOCATION@ -bindir=${top}/bin/@ARCH@ -libdir=${top}/lib/@ARCH@ +dbddir=${prefix}/dbd +dbdir=${prefix}/db Name: epics-base Version: @EPICS_VERSION@.@EPICS_REVISION@.@EPICS_MODIFICATION@.@EPICS_PATCH_LEVEL@ From 7a3e52b647dce16e6281966b7f532af0799cd1f5 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 25 Sep 2014 16:49:44 -0400 Subject: [PATCH 7/8] comment in configure/RULES_EXPAND --- configure/RULES_EXPAND | 1 + 1 file changed, 1 insertion(+) diff --git a/configure/RULES_EXPAND b/configure/RULES_EXPAND index 274b0532d..ca087aadc 100644 --- a/configure/RULES_EXPAND +++ b/configure/RULES_EXPAND @@ -8,6 +8,7 @@ EXPAND_TOOL ?= $(PERL) $(TOOLS)/expandVars.pl EXPANDFLAGS += -t $(INSTALL_LOCATION) -a $(T_A) EXPANDFLAGS += $(addprefix -D ,$(EXPAND_VARS)) +# The names of files to be expanded must end with '@' EXPANDED = $(EXPAND:%@=%) buildInstall: $(EXPANDED) From c078a9cef896eefd722dd64b75baab87cf7cb7a2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 25 Sep 2014 16:24:23 -0500 Subject: [PATCH 8/8] Replaced split with a single regex --- src/tools/expandVars.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/expandVars.pl b/src/tools/expandVars.pl index 4e81ac4e4..76e35e259 100644 --- a/src/tools/expandVars.pl +++ b/src/tools/expandVars.pl @@ -49,9 +49,9 @@ expandRelease(\%vars); $vars{'ARCH'} = $opt_a if $opt_a; while ($_ = shift @opt_D) { - my ($var, $val) = split(/=/, $_, 2); - $vars{$var} = $val; - print "$var = $val\n" if $opt_d; + m/^ (\w+) \s* = \s* (.*) $/x; + $vars{$1} = $2; + print "$1 = $2\n" if $opt_d; } # Do it!