Article View: comp.os.os2.programmer
Article #2282diffs to compile gnu diff 2.0 with emx-gcc
From: Kent Williams
Date: Sun, 04 Oct 1992 15:27
Date: Sun, 04 Oct 1992 15:27
216 lines
6341 bytes
6341 bytes
For those of you who might be wondering, gnu diff 2.0 compiles up
pretty easy with emx 0.8e. Here is a context diff to the standard
diff-2.0.tar.Z from prep.ai.mit.edu.
1. get diff-2.0.tar.Z from prep.ai.mit.edu, and unpack it.
2. Copy this file into the diff-2.0 directory
3. run
patch < this-file
To install the patches.
4. Edit the makefile.emx and change the bindir make variable to point
where you want to install these programs.
5. run
make -f makefile.emx
Easy as pie.
I started out with the patches.os2 from the gnudiff.zoo file as a reference.
Many of those patches aren't necessary with emx; I had a little trouble using
vfork/exec in diff3 and diff (for paginate) so I converted it to use popen;
someone with more time or inclination could probably get rid of the popen
stuff and just use fork/exec.
I have only done cursory testing. If you find a problem, drop me a line.
Kent Williams
williams@cs.uiowa.edu
diff --context --recursive --new-file diff-2.0/diff3.c diff-2.0.emx/diff3.c
*** diff-2.0/diff3.c Thu Sep 03 12:30:54 1992
--- diff-2.0.emx/diff3.c Sun Oct 04 08:02:26 1992
***************
*** 945,952 ****
* Routines to input and parse two way diffs.
*/
- extern char **environ;
-
#define DIFF_CHUNK_SIZE 10000
struct diff_block *
--- 945,950 ----
***************
*** 1155,1167 ****
--- 1153,1172 ----
char *filea, *fileb;
char **output_placement;
{
+ #if !defined(__EMX__)
char *argv[6];
char **ap;
+ #endif
int fds[2];
char *diff_result;
int current_chunk_size;
int bytes;
int total;
+ #if defined(__EMX__)
+ FILE *pipe;
+ char buffer[256];
+ int wstatus;
+ #else
int pid, w;
int wstatus;
***************
*** 1173,1179 ****
--- 1178,1190 ----
*ap++ = filea;
*ap++ = fileb;
*ap = (char *) 0;
+ #endif
+ #if defined(__EMX__)
+ sprintf(buffer, "%s -a -- %s %s", diff_program, filea, fileb);
+ pipe = popen(buffer, "r");
+ fds[0] = fileno(pipe);
+ #else
if (pipe (fds) < 0)
perror_with_exit ("pipe failed");
***************
*** 1198,1203 ****
--- 1209,1215 ----
perror_with_exit ("fork failed");
close (fds[1]); /* Prevent erroneous lack of EOF */
+ #endif
current_chunk_size = DIFF_CHUNK_SIZE;
diff_result = (char *) xmalloc (current_chunk_size);
total = 0;
***************
*** 1215,1225 ****
*output_placement = diff_result;
do
if ((w = wait (&wstatus)) == -1)
perror_with_exit ("wait failed");
while (w != pid);
!
if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
fatal ("subsidiary diff failed");
--- 1227,1240 ----
*output_placement = diff_result;
+ #if defined(__EMX__)
+ wstatus = pclose(pipe);
+ #else
do
if ((w = wait (&wstatus)) == -1)
perror_with_exit ("wait failed");
while (w != pid);
! #endif
if (! (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) < 2))
fatal ("subsidiary diff failed");
diff --context --recursive --new-file diff-2.0/makefile.emx diff-2.0.emx/makefile.emx
*** diff-2.0/makefile.emx
--- diff-2.0.emx/makefile.emx Sun Oct 04 08:02:30 1992
***************
*** 0 ****
--- 1,30 ----
+ CC = gcc
+ bindir=c:/emx/bin
+ LDFLAGS = $(CFLAGS)
+ CFLAGS = -v -g -DHAVE_MEMCHR=1 -DSTDC_HEADERS=1 -DHAVE_DUP2 \
+ -DDIFF_PROGRAM=\"$(bindir)/diff.exe\" -Dvfork=fork -Dpid_t=int
+ LIBS=-los2
+ %.o : %.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+ objs=diff.o analyze.o io.o context.o \
+ ed.o normal.o util.o dir.o fnmatch.o \
+ regex.o side.o ifdef.o version.o \
+ getopt.o getopt1.o $(ALLOCA)
+
+ all: diff.exe diff3.exe sdiff.exe cmp.exe
+
+ diff.exe: $(objs)
+ $(CC) -o $@ $(LDFLAGS) $(objs) $(LIBS)
+
+ diff3.exe: diff3.o getopt.o getopt1.o version.o $(ALLOCA)
+ $(CC) -o $@ $(LDFLAGS) diff3.o getopt.o getopt1.o version.o $(ALLOCA) $(LIBS)
+
+ sdiff.exe: sdiff.o getopt.o getopt1.o version.o $(ALLOCA)
+ $(CC) -o $@ $(LDFLAGS) sdiff.o getopt.o getopt1.o version.o $(ALLOCA) $(LIBS)
+
+ cmp.exe: cmp.o getopt.o getopt1.o error.o xmalloc.o $(ALLOCA)
+ $(CC) -o $@ $(LDFLAGS) cmp.o getopt.o getopt1.o error.o xmalloc.o $(ALLOCA) $(LIBS)
+
+
+
diff --context --recursive --new-file diff-2.0/system.h diff-2.0.emx/system.h
*** diff-2.0/system.h Fri Sep 11 22:33:20 1992
--- diff-2.0.emx/system.h Sun Oct 04 08:02:34 1992
***************
*** 47,54 ****
--- 47,58 ----
#define O_RDONLY 0
#endif
+ #if !defined(__EMX__)
#if !defined (USG) || defined (_POSIX_VERSION)
#include <sys/wait.h>
+ #endif
+ #else
+ #include <process.h>
#endif
#ifndef WEXITSTATUS
diff --context --recursive --new-file diff-2.0/util.c diff-2.0.emx/util.c
*** diff-2.0/util.c Mon Sep 14 20:15:48 1992
--- diff-2.0.emx/util.c Sun Oct 04 08:02:34 1992
***************
*** 152,160 ****
strcat (name, current_name0);
strcat (name, " ");
strcat (name, current_name1);
-
if (paginate_flag)
{
int pipes[2];
int desc;
--- 152,160 ----
strcat (name, current_name0);
strcat (name, " ");
strcat (name, current_name1);
if (paginate_flag)
{
+ #if !defined(__EMX__)
int pipes[2];
int desc;
***************
*** 186,191 ****
--- 186,195 ----
close (pipes[0]);
outfile = fdopen (pipes[1], "w");
}
+ #else
+ outfile = popen("pr -o -","w");
+ fprintf(outfile,"%s\n",name);
+ #endif
}
else
{
--
Kent Williams -- williams@cs.uiowa.edu Work(335-4496) Home(338-6053)
There used to be an inflammatory quote here.
Technical Details
Message-ID:
<1992Oct4.152735.22067@news.uiowa.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!math.fu-berlin.de!Sirius.dfn.de!darwin.sura.net!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!hobbes.physics.uiowa.edu!news.uiowa.edu!herky.cs.uiowa.edu!williamsShow Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!math.fu-berlin.de!Sirius.dfn.de!darwin.sura.net!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!hobbes.physics.uiowa.edu!news.uiowa.edu!herky.cs.uiowa.edu!williams From: williams@herky.cs.uiowa.edu (Kent Williams) Subject: diffs to compile gnu diff 2.0 with emx-gcc Message-ID: <1992Oct4.152735.22067@news.uiowa.edu> Sender: news@news.uiowa.edu (News) Date: Sun, 4 Oct 1992 15:27:35 GMT Reply-To: williams@herky.cs.uiowa.edu (Kent Williams) Nntp-Posting-Host: herky.cs.uiowa.edu Organization: U of Iowa, Iowa City, IA Lines: 218