Is there any reason to install the headers on non-DASD systems also. I
recall that you were against installing them to preserve consistency.
Since the DASD specific code would not be compiled into the library,
would it not mislead the user if the headers are present? I am
curious. :-)

They don't hurt anything.  It's easier to take this path from my
understanding.

Well it is not a matter of hurting. Is there any reason to provide the
header, when the corresponding code is not being compiled into the
library?

Why is it easier?

I'm using the #ifdef method in 1.8.x because the AM_CONDITIONAL stuff
simply was not working.  If AM_CONDITIONAL is preferred, then I want to
look at it more closely.  What we had wasn't working at all.

That is not the fault of AM_CONDITIONAL. It was because that the test
I had written using AC_EGREP_CPP was wrong. Apparently the best way to
do it is using AC_COMPILE_IFELSE and AC_LANG_PROGRAM.
((http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_chapter/autoconf_15.html
last example on the page)

I have attached a patch. It should work on both S390 and non-s390
machines. Although it puts the DASD specific files in the tarballs,
they are only compiled and installed if __s390__ or __s390x__ are
defined.

Comments?

Happy hacking,
Debarshi
--
GPG key ID: 63D4A5A7
Key server: pgp.mit.edu
diff --git a/configure.ac b/configure.ac
index 5735541..f74eb00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -433,6 +433,15 @@ AC_CHECK_HEADER([execinfo.h], [
 	])
 ])
 
+dnl Checks for #defines.
+AC_COMPILE_IFELSE([
+	AC_LANG_PROGRAM([[
+	#if defined __s390__ || defined __s390x__
+	#  message s390 defined
+	#endif
+	]])], [compile_for_s390="no"], [compile_for_s390="yes"])
+AM_CONDITIONAL([COMPILE_FOR_S390], [test "$compile_for_s390" = "yes"])
+
 dnl check for "check", unit testing library/header
 PKG_CHECK_MODULES([CHECK], [check >= 0.9.3], have_check=yes, have_check=no)
 if test "$have_check" != "yes"; then
diff --git a/include/parted/Makefile.am b/include/parted/Makefile.am
index 3c9b5e5..dd0e1d4 100644
--- a/include/parted/Makefile.am
+++ b/include/parted/Makefile.am
@@ -1,3 +1,9 @@
+if COMPILE_FOR_S390
+S390_HDRS = fdasd.h vtoc.h
+else
+S390_HDRS =
+endif
+
 partedincludedir      =	$(includedir)/parted
 
 partedinclude_HEADERS = gnu.h		\
@@ -13,8 +19,7 @@ partedinclude_HEADERS = gnu.h		\
 			timer.h		\
 			unit.h		\
 			parted.h        \
-			fdasd.h		\
-			vtoc.h
+			$(S390_HDRS)
 
 noinst_HEADERS	      = crc32.h		\
 			endian.h
diff --git a/libparted/labels/Makefile.am b/libparted/labels/Makefile.am
index 5b0aec4..f4d7d14 100644
--- a/libparted/labels/Makefile.am
+++ b/libparted/labels/Makefile.am
@@ -3,14 +3,18 @@
 #
 # This file may be modified and/or distributed without restriction.
 
+if COMPILE_FOR_S390
+S390_SRCS = dasd.c fdasd.c vtoc.c
+else
+S390_SRCS =
+endif
+
 partedincludedir      =	-I$(top_srcdir)/include
 noinst_LTLIBRARIES    =	liblabels.la
 
 liblabels_la_SOURCES  = rdb.c		\
 			bsd.c  		\
-			dasd.c		\
-			fdasd.c		\
-			vtoc.c		\
+			$(S390_SRCS)	\
 			efi_crc32.c	\
 			dos.c  		\
 			dvh.h		\
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index fa7d000..f11bc52 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -47,9 +47,6 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
-/* S390 */
-#if defined (__s390__) || defined (__s390x__)
-
 #define PARTITION_LINUX_SWAP 0x82
 #define PARTITION_LINUX 0x83
 #define PARTITION_LINUX_EXT 0x85
@@ -865,5 +862,3 @@ error:
 	ped_constraint_destroy (constraint_any);
 	return 0;
 }
-
-#endif /* S390 */
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index 6755ee7..198bce2 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -29,9 +29,6 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
-/* S390 */
-#if defined (__s390__) || defined (__s390x__)
-
 static int
 getpos (fdasd_anchor_t *anc, int dsn)
 {
@@ -1051,6 +1048,4 @@ fdasd_add_partition (fdasd_anchor_t *anc, unsigned int start,
 	return p;
 }
 
-#endif /* S390 */
-
 /* vim:set tabstop=4 shiftwidth=4 softtabstop=4: */
diff --git a/libparted/labels/vtoc.c b/libparted/labels/vtoc.c
index 15482c5..bd2c905 100644
--- a/libparted/labels/vtoc.c
+++ b/libparted/labels/vtoc.c
@@ -19,9 +19,6 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
-/* S390 */
-#if defined (__s390__) || defined (__s390x__)
-
 static const unsigned char EBCtoASC[256] =
 {
 /* 0x00  NUL   SOH   STX   ETX  *SEL    HT  *RNL   DEL */
@@ -1155,5 +1152,3 @@ vtoc_set_freespace(format4_label_t *f4, format5_label_t *f5,
 		vtoc_reorganize_FMT5_extents (f5);
 	}
 }
-
-#endif /* S390 */
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to