From: mig@cunixb.cc.columbia.edu (Meir I Green)
Subject: Help with gcc and gmake
Reply-To: mig@cunixb.cc.columbia.edu (Meir I Green)
Organization: Columbia University, New York
Date: Fri, 11 Dec 1992 16:46:09 GMT

I am trying to compile jpegV4 for OS/2 2.0.
Unfortunately, I don't have the docs for gmake or gcc :-)
I just hacked the makefile until it compiled.
Both cjpeg and djpeg compile, but as jcmain and jdmain.

There are no errors during compilation, but the programs create
corrupt jpg and gif files when tested.

Can someone tell me what I am doing worng?
Did I do something wrong with the makefile, or should I try a
different compiler option...?

Maybe I don't understand the compiling/linking process?
Please email advice!

Thank you very much!
Meir

-----
[G:\pics]ls -alg yoda.gif
-rw-a--   189828 Jan 03  1991 yoda.gif

[G:\pics]cjpeg -verbose -quality 50 yoda.gif > tmp.jpg
cjpeg -verbose -quality 50 yoda.gif > tmp.jpg
Independent JPEG Group's CJPEG, version 4 10-Dec-92
Copyright (C) 1992, Thomas G. Lane
640x480x256 GIF image

[G:\pics]djpeg -verbose tmp.jpg > tmp.gif
Independent JPEG Group's DJPEG, version 4 10-Dec-92
Copyright (C) 1992, Thomas G. Lane
Start of Image
JFIF APP0 marker, density 1x1  0
Define Quantization Table 0  precision 0
Corrupt JPEG data: 1 extraneous bytes before marker 0xdb
Define Quantization Table 1  precision 0
Start Of Frame 0xc0: width=640, height=480, components=3
    Component 1: 2hx2v q=0
    Component 2: 1hx1v q=1
    Component 3: 1hx1v q=1
Define Huffman Table 0x00
Define Huffman Table 0x10
Define Huffman Table 0x01
Define Huffman Table 0x11
Start Of Scan: 3 components
    c1: [dc=0 ac=0]
    c2: [dc=1 ac=1]
    c3: [dc=1 ac=1]
End Of Image

[G:\pics]
-----
# Makefile for Independent JPEG Group's software

# Makefile for OS/2 2.0 with gcc and gmake
#
# Meir Green (mig@columbia.edu)
# 12-10-92
#
# You need to "copy jmemnobs.c jmemsys.c"
# and "copy makefile.os2 makefile"
# Then type "gmake" or "make"
# Press enter when prompted to continue linking (link386)
#

# This makefile is suitable for Unix-like systems with ANSI-capable compilers.
# If you have a non-ANSI compiler, makefile.unix is a better starting point.

# Read SETUP instructions before saying "make" !!

# The name of your C compiler:
CC= gcc

# You may need to adjust these cc options:
CFLAGS= -c -O2

# in particular:
#   add -dbsd if on a pure bsd system (see jinclude.h).
#   add -dmem_stats to enable gathering of memory usage statistics.
#   you may also want to add -dtwo_file_commandline or -d switches for other
#   symbols listed in jconfig.h, if you prefer not to change jconfig.h.

# link-time cc options:
ldflags=

# To link any special libraries, add the necessary -l commands here.
# In particular, on some versions of HP-UX (and probably other SysV-derived
# systems) there is a faster alternate malloc(3) library that you can use
# by adding "-lmalloc" to this line.
LDLIBS= 

# miscellaneous OS-dependent stuff
# linker
LN= link386
# file deletion command
RM= del
# library (.a) file creation command
AR= ar rc
# second step in .a creation (use "touch" if not needed)
AR2= ranlib
# copy command
CP= copy


# source files (independently compilable files)
SOURCES= jbsmooth.c jcarith.c jccolor.c jcdeflts.c jcexpand.c jchuff.c \
        jcmain.c jcmaster.c jcmcu.c jcpipe.c jcsample.c jdarith.c jdcolor.c \
        jddeflts.c jdhuff.c jdmain.c jdmaster.c jdmcu.c jdpipe.c jdsample.c \
        jerror.c jquant1.c jquant2.c jfwddct.c jrevdct.c jutils.c jmemmgr.c \
        jrdjfif.c jrdgif.c jrdppm.c jrdrle.c jrdtarga.c jwrjfif.c jwrgif.c \
        jwrppm.c jwrrle.c jwrtarga.c
# virtual source files (not present in distribution file, see SETUP)
# VIRTSOURCES= jmemsys.c
# Use jmemnobs.sys
VIRTSOURCES= jmemsys.c
# system-dependent implementations of virtual source files
SYSDEPFILES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemdos.h \
        jmemdosa.asm
# files included by source files
INCLUDES= jinclude.h jconfig.h jpegdata.h jversion.h jmemsys.h
# documentation, test, and support files
DOCS= README SETUP USAGE CHANGELOG cjpeg.1 djpeg.1 architecture codingrules
MAKEFILES= makefile.ansi makefile.unix makefile.manx makefile.sas \
        makcjpeg.st makdjpeg.st makljpeg.st makefile.mc5 makefile.mc6 \
        makefile.bcc makefile.mms makefile.vms makvms.opt
OTHERFILES= ansi2knr.c ckconfig.c example.c
TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg
DISTFILES= $(DOCS) $(MAKEFILES) $(SOURCES) $(SYSDEPFILES) $(INCLUDES) \
        $(OTHERFILES) $(TESTFILES)
# objectfiles common to cjpeg and djpeg
COMOBJECTS= jutils.o jerror.o jmemmgr.o jmemsys.o
# compression objectfiles
CLIBOBJECTS= jcmaster.o jcdeflts.o jcarith.o jccolor.o jcexpand.o jchuff.o \
        jcmcu.o jcpipe.o jcsample.o jfwddct.o jwrjfif.o jrdgif.o jrdppm.o \
        jrdrle.o jrdtarga.o
COBJECTS= jcmain.o $(CLIBOBJECTS) $(COMOBJECTS)
# decompression objectfiles
DLIBOBJECTS= jdmaster.o jddeflts.o jbsmooth.o jdarith.o jdcolor.o jdhuff.o \
        jdmcu.o jdpipe.o jdsample.o jquant1.o jquant2.o jrevdct.o jrdjfif.o \
        jwrgif.o jwrppm.o jwrrle.o jwrtarga.o
DOBJECTS= jdmain.o $(DLIBOBJECTS) $(COMOBJECTS)
LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS)


all: cjpeg djpeg
# By default, libjpeg.a is not built unless you explicitly request it.
# You can add libjpeg.a to the line above if you want it built by default.


cjpeg: $(COBJECTS)
	$(CC) $(CFLAGS) cjpeg $(VIRTSOURCES) $(SOURCES) $(LDLIBS)
	$(CP) *.obj *.o
	$(LN) $(LDFLAGS) $(COBJECTS) $(LDLIBS)
	$(CP) jcmain.exe cjpeg.exe
	$(RM) jcmain.exe


djpeg: $(DOBJECTS)
	$(CC) $(CFLAGS) djpeg $(VIRTSOURCES) $(SOURCES) $(LDLIBS)
	$(CP) *.obj *.o
	$(LN) $(LDFLAGS) $(DOBJECTS) $(LDLIBS)
	$(CP) jdmain.exe djpeg.exe
	$(RM) jdmain.exe

# libjpeg.a is useful if you are including the JPEG software in a larger
# program; you'd include it in your link, rather than the individual modules.
libjpeg.a: $(LIBOBJECTS)
	$(RM) libjpeg.a
	$(AR) libjpeg.a  $(LIBOBJECTS)
	$(AR2) libjpeg.a

jmemsys.c:
	echo You must select a system-dependent jmemsys.c file.
	echo Please read the SETUP directions.
	exit 1

clean:
	$(RM) *.o cjpeg djpeg libjpeg.a core testout.*

distribute:
	$(RM) jpegsrc.tar*
	tar cvf jpegsrc.tar $(DISTFILES)
	compress -v jpegsrc.tar

test: cjpeg djpeg
	$(RM) testout.ppm testout.gif testout.jpg
	./djpeg testorig.jpg >testout.ppm
	./djpeg -gif testorig.jpg >testout.gif
	./cjpeg testimg.ppm >testout.jpg
	cmp testimg.ppm testout.ppm
	cmp testimg.gif testout.gif
	cmp testimg.jpg testout.jpg


jbsmooth.o : jbsmooth.c jinclude.h jconfig.h jpegdata.h 
jcarith.o : jcarith.c jinclude.h jconfig.h jpegdata.h 
jccolor.o : jccolor.c jinclude.h jconfig.h jpegdata.h 
jcdeflts.o : jcdeflts.c jinclude.h jconfig.h jpegdata.h 
jcexpand.o : jcexpand.c jinclude.h jconfig.h jpegdata.h 
jchuff.o : jchuff.c jinclude.h jconfig.h jpegdata.h 
jcmain.o : jcmain.c jinclude.h jconfig.h jpegdata.h jversion.h 
jcmaster.o : jcmaster.c jinclude.h jconfig.h jpegdata.h 
jcmcu.o : jcmcu.c jinclude.h jconfig.h jpegdata.h 
jcpipe.o : jcpipe.c jinclude.h jconfig.h jpegdata.h 
jcsample.o : jcsample.c jinclude.h jconfig.h jpegdata.h 
jdarith.o : jdarith.c jinclude.h jconfig.h jpegdata.h 
jdcolor.o : jdcolor.c jinclude.h jconfig.h jpegdata.h 
jddeflts.o : jddeflts.c jinclude.h jconfig.h jpegdata.h 
jdhuff.o : jdhuff.c jinclude.h jconfig.h jpegdata.h 
jdmain.o : jdmain.c jinclude.h jconfig.h jpegdata.h jversion.h 
jdmaster.o : jdmaster.c jinclude.h jconfig.h jpegdata.h 
jdmcu.o : jdmcu.c jinclude.h jconfig.h jpegdata.h 
jdpipe.o : jdpipe.c jinclude.h jconfig.h jpegdata.h 
jdsample.o : jdsample.c jinclude.h jconfig.h jpegdata.h 
jerror.o : jerror.c jinclude.h jconfig.h jpegdata.h 
jquant1.o : jquant1.c jinclude.h jconfig.h jpegdata.h 
jquant2.o : jquant2.c jinclude.h jconfig.h jpegdata.h 
jfwddct.o : jfwddct.c jinclude.h jconfig.h jpegdata.h 
jrevdct.o : jrevdct.c jinclude.h jconfig.h jpegdata.h 
jutils.o : jutils.c jinclude.h jconfig.h jpegdata.h 
jmemmgr.o : jmemmgr.c jinclude.h jconfig.h jpegdata.h jmemsys.h 
jrdjfif.o : jrdjfif.c jinclude.h jconfig.h jpegdata.h 
jrdgif.o : jrdgif.c jinclude.h jconfig.h jpegdata.h 
jrdppm.o : jrdppm.c jinclude.h jconfig.h jpegdata.h 
jrdrle.o : jrdrle.c jinclude.h jconfig.h jpegdata.h 
jrdtarga.o : jrdtarga.c jinclude.h jconfig.h jpegdata.h 
jwrjfif.o : jwrjfif.c jinclude.h jconfig.h jpegdata.h 
jwrgif.o : jwrgif.c jinclude.h jconfig.h jpegdata.h 
jwrppm.o : jwrppm.c jinclude.h jconfig.h jpegdata.h 
jwrrle.o : jwrrle.c jinclude.h jconfig.h jpegdata.h 
jwrtarga.o : jwrtarga.c jinclude.h jconfig.h jpegdata.h 
jmemsys.o : jmemsys.c jinclude.h jconfig.h jpegdata.h jmemsys.h
 * * * * *  =================== Internet   mig@cunixb.cc.columbia.edu
* * * * * * == Meir I. Green == AmateurPkt N2JPG@W2XO.PA.USA.NOAM
 * * * * *  = mig@columbia.edu= Amateur IP N2JPG@uhm.ampr.org
* * * * * * =================== BC-Goliath green@smtplink.barnard.columbia.edu