From d5bffdb13d44a5e0c183b786b62f3cc58e169444 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 28 Jul 2009 21:08:37 +0000 Subject: [PATCH] Can't portably pass filesystem paths as command-line macros to C. Generate a header file instead and include that. --- src/softIoc/Makefile | 6 +++--- src/softIoc/makeInstallDir.pl | 31 +++++++++++++++++++++++++++++++ src/softIoc/softMain.cpp | 10 +++++----- 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 src/softIoc/makeInstallDir.pl diff --git a/src/softIoc/Makefile b/src/softIoc/Makefile index 21eafa983..c6bad5562 100644 --- a/src/softIoc/Makefile +++ b/src/softIoc/Makefile @@ -16,9 +16,6 @@ softIoc_DBD += base.dbd softIoc_DBD += dlload.dbd softIoc_DBD += system.dbd -ABS_INSTALL_DIR = $(shell $(PERL) $(TOOLS)/fullPathName.pl -e $(INSTALL_LOCATION)) -USR_CXXFLAGS += -DEPICS_BASE="$(ABS_INSTALL_DIR)" - softIoc_SRCS += softIoc_registerRecordDeviceDriver.cpp softIoc_SRCS_DEFAULT += softMain.cpp softIoc_SRCS_vxWorks = -nil- @@ -28,3 +25,6 @@ softIoc_LIBS = $(EPICS_BASE_IOC_LIBS) DB += softIocExit.db include $(TOP)/configure/RULES + +epicsInstallDir.h: + $(PERL) ../makeInstallDir.pl $(INSTALL_LOCATION) > $@ diff --git a/src/softIoc/makeInstallDir.pl b/src/softIoc/makeInstallDir.pl new file mode 100644 index 000000000..88dc8b88c --- /dev/null +++ b/src/softIoc/makeInstallDir.pl @@ -0,0 +1,31 @@ +eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*- + if $running_under_some_shell; # registerRecordDeviceDriver +#************************************************************************* +# Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne +# National Laboratory. +# EPICS BASE is distributed subject to a Software License Agreement found +# in file LICENSE that is included with this distribution. +#************************************************************************* + +use strict; + +use FindBin qw($Bin); +use lib "$Bin/../../lib/perl"; + +use EPICS::Path; + +die "Path to INSTALL_LOCATION missing\n" unless @ARGV == 1; + +my $path = AbsPath(shift); + +$path =~ s/\\/\\\\/gx; + +print "/* THIS IS A GENERATED FILE. DO NOT EDIT! */\n", + "\n", + "#ifndef INC_epicsInstallDir_H\n", + "#define INC_epicsInstallDir_H\n", + "\n", + "#define EPICS_BASE \"$path\"\n", + "\n", + "#endif /* INC_epicsInstallDir_H */\n"; + diff --git a/src/softIoc/softMain.cpp b/src/softIoc/softMain.cpp index 09bada267..786ce1eac 100644 --- a/src/softIoc/softMain.cpp +++ b/src/softIoc/softMain.cpp @@ -70,16 +70,16 @@ #include "asDbLib.h" #include "iocInit.h" #include "iocsh.h" +#include "epicsInstallDir.h" extern "C" int softIoc_registerRecordDeviceDriver(struct dbBase *pdbbase); -#define QUOTE(x) #x -#define DBD_FILE(top) QUOTE(top) "/dbd/softIoc.dbd" -#define EXIT_FILE(top) QUOTE(top) "/db/softIocExit.db" +#define DBD_FILE EPICS_BASE "/dbd/softIoc.dbd" +#define EXIT_FILE EPICS_BASE "/db/softIocExit.db" const char *arg0; -const char *base_dbd = DBD_FILE(EPICS_BASE); -const char *exit_db = EXIT_FILE(EPICS_BASE); +const char *base_dbd = DBD_FILE; +const char *exit_db = EXIT_FILE; static void exitSubroutine(subRecord *precord) {