changeset 2276:104e9e22453b

package file: reorganise and add test program -use separate native build dir -remove patch and use Make variable instead -add test program
author Tony Theodore <tonyt@logyst.com>
date Tue, 13 Mar 2012 23:49:42 +1100
parents 8601be96cfa1
children 06a3683cf20e
files src/file-1-fix-cross-compilation-detection.patch src/file-test.c src/file.mk
diffstat 3 files changed, 25 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/file-1-fix-cross-compilation-detection.patch	Tue Mar 13 03:01:04 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-This file is part of mingw-cross-env.
-See doc/index.html for further information.
-
-diff -Nur file-5.09/magic/Makefile.am file-5.09-mingw-cross-env/magic/Makefile.am
---- file-5.09/magic/Makefile.am	2011-09-08 23:58:42.000000000 +0200
-+++ file-5.09-mingw-cross-env/magic/Makefile.am	2011-10-23 17:31:31.456765605 +0200
-@@ -253,13 +253,8 @@
- 
- # FIXME: Build file natively as well so that it can be used to compile
- # the target's magic file; for now we bail if the local version does not match
--if IS_CROSS_COMPILE
--FILE_COMPILE = file
-+FILE_COMPILE = $(top_builddir)/src/file.local
- FILE_COMPILE_DEP =
--else
--FILE_COMPILE = $(top_builddir)/src/file
--FILE_COMPILE_DEP = $(FILE_COMPILE)
--endif
- 
- ${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
- 	@rm -fr magic
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/file-test.c	Tue Mar 13 23:49:42 2012 +1100
@@ -0,0 +1,14 @@
+/* This file is part of mingw-cross-env.       */
+/* See doc/index.html for further information. */
+
+#include <stdio.h>
+#include <magic.h>
+
+int main(int argc, char *argv[])
+{
+	(void)argc;
+	(void)argv;
+
+	fprintf(stdout, "magic file from %s\n", magic_getpath(NULL, 0));
+	return 0;
+}
\ No newline at end of file
--- a/src/file.mk	Tue Mar 13 03:01:04 2012 +0100
+++ b/src/file.mk	Tue Mar 13 23:49:42 2012 +1100
@@ -24,15 +24,21 @@
     # itself. This must match the source code regarding its
     # version. Therefore we build a native one ourselves first.
 
-    cd '$(1)' && ./configure \
+    cp -Rp '$(1)' '$(1).native'
+    cd '$(1).native' && ./configure \
         --disable-shared
-    $(MAKE) -C '$(1)/src' -j '$(JOBS)' file
-    cp '$(1)/src/file' '$(1)/src/file.local'
+    $(MAKE) -C '$(1).native/src' -j '$(JOBS)' file
 
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
-    $(MAKE) -C '$(1)' clean
-    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+    $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS= FILE_COMPILE='$(1).native/src/file'
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-file.exe' \
+        -lmagic -lgnurx -lshlwapi
 endef